From 8c09fdd3fd71c3a7d160ca6677af4c59e13e5552 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Mon, 25 Aug 2025 10:39:24 -0700 Subject: [PATCH] Add Ollama Turbo support and update request handling in interpreter Signed-off-by: Matt Williams --- providers.json | 12 ++++++++++++ src/utils/interpreter.ts | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/providers.json b/providers.json index a90dd63a..7e18e2f2 100644 --- a/providers.json +++ b/providers.json @@ -68,6 +68,18 @@ { "id": "Llama-3.3-70B-Instruct", "name": "Llama 3.3 70B" } ] }, + "ollamaturbo": { + "id": "ollamaturbo", + "name": "Ollama Turbo", + "apiKeyUrl": "https://ollama.com/settings/keys", + "apiKeyRequired": true, + "modelsList": "https://ollama.com/models", + "baseUrl": "https://ollama.com/api/chat", + "popularModels": [ + { "id": "gpt-oss:20b", "name": "GPT OSS 20B" }, + { "id": "gpt-oss:120b", "name": "GPT OSS 120B" } + ] + }, "ollama": { "id": "ollama", "name": "Ollama", diff --git a/src/utils/interpreter.ts b/src/utils/interpreter.ts index 1778efd5..94f179f3 100644 --- a/src/utils/interpreter.ts +++ b/src/utils/interpreter.ts @@ -110,16 +110,36 @@ export async function sendToLLM(promptContext: string, content: string, promptVa { role: 'user', content: ` "${promptContext}" "${JSON.stringify(promptContent)}"` - } - ] - }; - headers = { - ...headers, - 'HTTP-Referer': 'https://obsidian.md/', - 'X-Title': 'Obsidian Web Clipper', - 'Authorization': `Bearer ${provider.apiKey}` - }; - } else if (provider.name.toLowerCase().includes('ollama')) { + } + ] + }; + headers = { + ...headers, + 'HTTP-Referer': 'https://obsidian.md/', + 'X-Title': 'Obsidian Web Clipper', + 'Authorization': `Bearer ${provider.apiKey}` + }; + } else if (provider.name.toLowerCase().includes("turbo")) { + requestUrl = provider.baseUrl; + requestBody = { + model: model.providerModelId, + messages: [ + { role: 'system', content: systemContent }, + { role: 'user', content: `${promptContext}` }, + { role: 'user', content: `${JSON.stringify(promptContent)}` } + ], + format: 'json', + num_ctx: 120000, + temperature: 0.5, + stream: false + }; + headers = { + ...headers, + 'HTTP-Referer': 'https://obsidian.md/', + 'X-Title': 'Obsidian Web Clipper', + 'Authorization': `Bearer ${provider.apiKey}` + }; + } else if (provider.name.toLowerCase().includes('ollama') && !provider.name.toLowerCase().includes("turbo")) { requestUrl = provider.baseUrl; requestBody = { model: model.providerModelId,