From 35a7fd13f6136ae164ea7d9ed99bc98d96d64593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cipriani=20Bandarra?= Date: Fri, 30 Jan 2026 19:41:41 +0000 Subject: [PATCH] Add think field to ChatRequest The Ollama API supports the think parameter for both generate and chat endpoints. ChatRequest was missing it while GenerateRequest already had it. Added the field, builder method, and doc comment to bring chat to parity with generate. --- src/types/chat.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/types/chat.rs b/src/types/chat.rs index 0aade37..db1f16e 100644 --- a/src/types/chat.rs +++ b/src/types/chat.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use crate::error::OllamaResult; -use crate::types::common::Options; +use crate::types::common::{Options, Think}; #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] @@ -66,6 +66,11 @@ pub struct ChatRequest { #[serde(skip_serializing_if = "Option::is_none")] pub format: Option, + + /// When set, returns separate thinking output in addition to content. Can be a boolean + /// (true/false) or a string ("high", "medium", "low") for supported models. + #[serde(skip_serializing_if = "Option::is_none")] + pub think: Option, } impl ChatRequest { @@ -96,6 +101,7 @@ impl ChatRequestBuilder { options: None, tools: vec![], format: None, + think: None, }, } } @@ -125,6 +131,11 @@ impl ChatRequestBuilder { self } + pub fn think(mut self, think: Think) -> Self { + self.chat_request.think = Some(think); + self + } + pub fn build(self) -> ChatRequest { self.chat_request }