diff --git a/.config/ags/modules/.configuration/default_options.jsonc b/.config/ags/modules/.configuration/default_options.jsonc index 8a4f790c..61c01d2c 100644 --- a/.config/ags/modules/.configuration/default_options.jsonc +++ b/.config/ags/modules/.configuration/default_options.jsonc @@ -20,6 +20,7 @@ // "description": "A model added by the user", // "base_url": "http://localhost:11434/v1/chat/completions", // "key_get_url": "", + // "requires_key": false, // "key_file": "api_key_file.txt", // "model": "model-name" // }, diff --git a/.config/ags/modules/sideleft/apis/chatgpt.js b/.config/ags/modules/sideleft/apis/chatgpt.js index 2adc489a..e0db9968 100644 --- a/.config/ags/modules/sideleft/apis/chatgpt.js +++ b/.config/ags/modules/sideleft/apis/chatgpt.js @@ -216,7 +216,9 @@ export const OpenaiApiKeyInstructions = () => Box({ transitionDuration: userOptions.animations.durationLarge, setup: (self) => self .hook(GPTService, (self, hasKey) => { - self.revealChild = (GPTService.key.length == 0); + self.revealChild = ( + GPTService.providers[GPTService.providerID]["requires_key"] + && GPTService.key.length == 0); }, 'hasKey') , child: Button({ @@ -259,6 +261,11 @@ export const chatContent = Box({ if (!message) return; box.add(ChatMessage(message, `Model (${GPTService.providers[GPTService.providerID]['name']})`)) }, 'newMsg') + .hook(GPTService, (self, hasKey) => { + self.revealChild = ( + GPTService.providers[GPTService.providerID]["requires_key"] + && GPTService.key.length == 0); + }, 'providerChanged') , }); @@ -291,9 +298,11 @@ export const chatGPTCommands = Box({ export const sendMessage = (text) => { // Check if text or API key is empty if (text.length == 0) return; - if (GPTService.key.length == 0) { + if (GPTService.providers[GPTService.providerID]["requires_key"] + && GPTService.key.length == 0 + && !text.startsWith('/key')) { GPTService.key = text; - chatContent.add(SystemMessage(`Key saved to\n\`${GPTService.keyPath}\``, 'API Key', ChatGPTView)); + chatContent.add(SystemMessage(`Key saved to \`${GPTService.keyPath}\`\nUpdate anytime with \`/key YOUR_API_KEY\`.`, 'API Key', ChatGPTView)); text = ''; return; } diff --git a/.config/ags/modules/sideleft/apis/gemini.js b/.config/ags/modules/sideleft/apis/gemini.js index ddc8da5d..d29cd763 100644 --- a/.config/ags/modules/sideleft/apis/gemini.js +++ b/.config/ags/modules/sideleft/apis/gemini.js @@ -220,7 +220,7 @@ export const sendMessage = (text) => { if (text.length == 0) return; if (GeminiService.key.length == 0) { GeminiService.key = text; - chatContent.add(SystemMessage(`Key saved to\n\`${GeminiService.keyPath}\``, 'API Key', GeminiView)); + chatContent.add(SystemMessage(`Key saved to \`${GeminiService.keyPath}\`\nUpdate anytime with /key YOUR_API_KEY.`, 'API Key', GeminiView)); text = ''; return; } diff --git a/.config/ags/services/gpt.js b/.config/ags/services/gpt.js index 81193603..3475f954 100644 --- a/.config/ags/services/gpt.js +++ b/.config/ags/services/gpt.js @@ -13,6 +13,7 @@ const PROVIDERS = Object.assign({ "description": getString('Ollama - Llama-3.2'), "base_url": 'http://localhost:11434/v1/chat/completions', "key_get_url": "", + "requires_key": false, "key_file": "ollama_key.txt", "model": "llama3.2", }, @@ -23,6 +24,7 @@ const PROVIDERS = Object.assign({ "base_url": "http://localhost:11434/v1/chat/completions", "key_get_url": "", "key_file": "ollama_key.txt", + "requires_key": false, "model": "deepseek-r1", }, "ollama_gemma3": { @@ -32,6 +34,7 @@ const PROVIDERS = Object.assign({ "base_url": "http://localhost:11434/v1/chat/completions", "key_get_url": "", "key_file": "ollama_key.txt", + "requires_key": false, "model": "gemma3", }, "openrouter": { @@ -40,6 +43,7 @@ const PROVIDERS = Object.assign({ "description": getString('A unified interface for LLMs'), "base_url": "https://openrouter.ai/api/v1/chat/completions", "key_get_url": "https://openrouter.ai/keys", + "requires_key": true, "key_file": "openrouter_key.txt", "model": "meta-llama/llama-3-70b-instruct", }, @@ -49,6 +53,7 @@ const PROVIDERS = Object.assign({ "description": getString('Official OpenAI API.\nPricing: Free for the first $5 or 3 months, whichever is less.'), "base_url": "https://api.openai.com/v1/chat/completions", "key_get_url": "https://platform.openai.com/api-keys", + "requires_key": true, "key_file": "openai_key.txt", "model": "gpt-3.5-turbo", },