mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
gpts: allow no api key
This commit is contained in:
parent
885c4b9679
commit
3dc0a61acc
4 changed files with 19 additions and 4 deletions
|
|
@ -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"
|
||||
// },
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue