From 5624de2912d1bb91a3e39f724d379ae590eac4a2 Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Mon, 25 Aug 2025 16:02:59 +0200 Subject: [PATCH] fix: render Ollama thinking messages Signed-off-by: Fred Bricon --- core/llm/llms/Ollama.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index a1c4c2046..078e31781 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -9,6 +9,7 @@ import { CompletionOptions, LLMOptions, ModelInstaller, + ThinkingChatMessage, } from "../../index.js"; import { renderChatMessage } from "../../util/messageContent.js"; import { getRemoteModelInfo } from "../../util/ollamaHelper.js"; @@ -18,6 +19,7 @@ type OllamaChatMessage = { role: ChatMessageRole; content: string; images?: string[] | null; + thinking?: string; tool_calls?: { function: { name: string; @@ -430,6 +432,13 @@ class Ollama extends BaseLLM implements ModelInstaller { ); } if (res.message.role === "assistant") { + if (res.message.thinking) { + const thinkingMessage: ThinkingChatMessage = { + role: "thinking", + content: res.message.thinking, + }; + return thinkingMessage; + } const chatMessage: ChatMessage = { role: "assistant", content: res.message.content,