diff --git a/core/index.d.ts b/core/index.d.ts index fbfa0812d..ba0a9e4f6 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -547,6 +547,7 @@ interface BaseCompletionOptions { stop?: string[]; maxTokens?: number; numThreads?: number; + keepAlive?: number; } export interface ModelDescription { diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 1f273560d..2267426e8 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -115,7 +115,7 @@ class Ollama extends BaseLLM { const finalOptions: any = { model: this._getModel(), raw: true, - keep_alive: 60 * 30, // 30 minutes + keep_alive: options.keepAlive ?? 60 * 30, // 30 minutes options: { temperature: options.temperature, top_p: options.topP, diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 6bdcb3e82..1ead9e9af 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -54,6 +54,11 @@ "title": "Number of threads", "description": "The number of threads used in the generation process. Only available for Ollama (this is the num_thread parameter)", "type": "integer" + }, + "keepAlive": { + "title": "Ollama keep_alive", + "description": "The number of seconds after no requests are made to unload the model from memory. Defaults to 60*30 = 30min", + "type": "integer" } } },