aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-ollama.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/module-ollama.js')
-rw-r--r--modules/core/module-ollama.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/modules/core/module-ollama.js b/modules/core/module-ollama.js
new file mode 100644
index 0000000..3eabe19
--- /dev/null
+++ b/modules/core/module-ollama.js
@@ -0,0 +1,52 @@
+// Extracted from newOS4 index.html — OllamaModule
+ class OllamaModule {
+ constructor() { this.commands = {}; this.terminal = null; }
+ getHelpInfo() {
+ return {
+ 'ollama': 'ollama — Open the Ollama model manager UI',
+ 'ollamaconnect': 'ollamaconnect — Connect to the Ollama server',
+ 'ollamadisconnect': 'ollamadisconnect — Disconnect from the Ollama server',
+ 'ollamamodels': 'ollamamodels — List all available models from Ollama',
+ 'ollamasetmodel': 'ollamasetmodel <name> — Set the active Ollama model',
+ 'ollamasetproxy': 'ollamasetproxy [endpoint] — View or change the Ollama endpoint URL',
+ };
+ }
+ registerCommands() {
+ this.commands['ollama'] = () => { this.terminal.openOllamaManager(); };
+ this.commands['ollamaconnect'] = async () => {
+ await this.terminal.ollamaManager.connect();
+ this.terminal.updateOllamaStatus();
+ };
+ this.commands['ollamadisconnect'] = () => {
+ this.terminal.ollamaManager.connected = false;
+ this.terminal.ollamaManager.models = [];
+ this.terminal.print('Ollama disconnected', 'info');
+ this.terminal.updateOllamaStatus();
+ };
+ this.commands['ollamamodels'] = () => {
+ const models = this.terminal.ollamaManager.getModels();
+ if(models.length === 0) return this.terminal.print("No models found. Connect first.");
+ models.forEach(m => this.terminal.print(`${m.name} (${(m.size/1e9).toFixed(1)}GB)`));
+ };
+ this.commands['ollamasetmodel'] = (args) => {
+ if(!args[0]) return this.terminal.print("Usage: ollamasetmodel <name>", 'warning');
+ this.terminal.ollamaManager.setModel(args[0]);
+ };
+ this.commands['ollamasetproxy'] = (args) => {
+ if(!args[0]) {
+ const ep = this.terminal.ollamaManager.endpoint;
+ return this.terminal.print(`Current Ollama endpoint: ${ep}`, 'info');
+ }
+ this.terminal.ollamaManager.setEndpoint(args[0]);
+ this.terminal.print(`Ollama endpoint set to: ${args[0]}`, 'success');
+ };
+ this.commands['ai'] = async (args) => {
+ if(!args[0]) return this.terminal.print("Usage: ai <prompt>", 'warning');
+ await this.terminal.ollamaManager.chat(args.join(' '));
+ };
+ this.commands['ask'] = async (args) => {
+ if(!args[0]) return this.terminal.print("Usage: ask <prompt>", 'warning');
+ await this.terminal.ollamaManager.chat(args.join(' '));
+ };
+ }
+ }