Merge pull request #7389 from fbricon/ollama-thinking

fix: render Ollama thinking messages
This commit is contained in:
Dallin Romney 2025-08-27 10:43:45 -07:00 • committed by GitHub
commit fda0be8c16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,