-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Description
Hi,
It looks like the { format : 'json' } option disables the { think: true } option.
For example, in the code below, the model thinks and returns its response as text. It works as expected. I reused the example from the documentation.
import ollama from "npm:ollama";
import process from "node:process";
async function main() {
const response = await ollama.chat({
model: "qwen3:8b",
messages: [
{
role: "user",
content: "What is 10 + 23",
},
],
stream: true,
think: true,
});
let startedThinking = false;
let finishedThinking = false;
for await (const chunk of response) {
if (chunk.message.thinking && !startedThinking) {
startedThinking = true;
process.stdout.write("Thinking:\n========\n\n");
} else if (
chunk.message.content && startedThinking && !finishedThinking
) {
finishedThinking = true;
process.stdout.write("\n\nResponse:\n========\n\n");
}
if (chunk.message.thinking) {
process.stdout.write(chunk.message.thinking);
} else if (chunk.message.content) {
process.stdout.write(chunk.message.content);
}
}
}
main();However, if we add format: 'json' to the options, then the model doesn't think anymore. There are no thoughts anymore.
import ollama from "npm:ollama";
import process from "node:process";
async function main() {
const response = await ollama.chat({
model: "qwen3:8b",
messages: [
{
role: "user",
content: "What is 10 + 23",
},
],
stream: true,
think: true,
format: "json",
});
let startedThinking = false;
let finishedThinking = false;
for await (const chunk of response) {
if (chunk.message.thinking && !startedThinking) {
startedThinking = true;
process.stdout.write("Thinking:\n========\n\n");
} else if (
chunk.message.content && startedThinking && !finishedThinking
) {
finishedThinking = true;
process.stdout.write("\n\nResponse:\n========\n\n");
}
if (chunk.message.thinking) {
process.stdout.write(chunk.message.thinking);
} else if (chunk.message.content) {
process.stdout.write(chunk.message.content);
}
}
}
main();Does anyone have any idea what's going on?
Thank you!
Metadata
Metadata
Assignees
Labels
No labels