ai: add keepAlive config option for ollama models

This commit is contained in:
end-4
2025-04-06 11:11:55 +02:00
parent 9345bce878
commit 3480fc0f68
2 changed files with 15 additions and 14 deletions
@@ -6,6 +6,7 @@
"defaultGPTProvider": "openai", "defaultGPTProvider": "openai",
"defaultTemperature": 0.5, "defaultTemperature": 0.5,
"enhancements": true, "enhancements": true,
"keep_alive": -1, // For ollama. -1 means forever
"useHistory": false, "useHistory": false,
"safety": true, "safety": true,
"writingCursor": " ...", // Warning: Using weird characters can mess up Markdown rendering "writingCursor": " ...", // Warning: Using weird characters can mess up Markdown rendering
+14 -14
View File
@@ -7,15 +7,6 @@ import Soup from 'gi://Soup?version=3.0';
import { fileExists } from '../modules/.miscutils/files.js'; import { fileExists } from '../modules/.miscutils/files.js';
const PROVIDERS = Object.assign({ const PROVIDERS = Object.assign({
"openai": {
"name": "OpenAI",
"logo_name": "openai-symbolic",
"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",
"key_file": "openai_key.txt",
"model": "gpt-3.5-turbo",
},
"ollama": { "ollama": {
"name": "Ollama - Llama 3", "name": "Ollama - Llama 3",
"logo_name": "ollama-symbolic", "logo_name": "ollama-symbolic",
@@ -52,6 +43,15 @@ const PROVIDERS = Object.assign({
"key_file": "openrouter_key.txt", "key_file": "openrouter_key.txt",
"model": "meta-llama/llama-3-70b-instruct", "model": "meta-llama/llama-3-70b-instruct",
}, },
"openai": {
"name": "OpenAI - GPT-3.5",
"logo_name": "openai-symbolic",
"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",
"key_file": "openai_key.txt",
"model": "gpt-3.5-turbo",
},
}, userOptions.ai.extraGptModels) }, userOptions.ai.extraGptModels)
// Custom prompt // Custom prompt
@@ -249,11 +249,11 @@ class GPTService extends Service {
const aiResponse = new GPTMessage('assistant', '', true, false) const aiResponse = new GPTMessage('assistant', '', true, false)
const body = { const body = {
model: PROVIDERS[this._currentProvider]['model'], "model": PROVIDERS[this._currentProvider]['model'],
messages: this._messages.map(msg => { let m = { role: msg.role, content: msg.content }; return m; }), "messages": this._messages.map(msg => { let m = { role: msg.role, content: msg.content }; return m; }),
temperature: this._temperature, "temperature": this._temperature,
// temperature: 2, // <- Nuts "stream": true,
stream: true, "keep_alive": userOptions.ai.keepAlive,
}; };
const proxyResolver = new Gio.SimpleProxyResolver({ 'default-proxy': userOptions.ai.proxyUrl }); const proxyResolver = new Gio.SimpleProxyResolver({ 'default-proxy': userOptions.ai.proxyUrl });
const session = new Soup.Session({ 'proxy-resolver': proxyResolver }); const session = new Soup.Session({ 'proxy-resolver': proxyResolver });