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.
This commit is contained in:
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::error::OllamaResult;
|
use crate::error::OllamaResult;
|
||||||
use crate::types::common::Options;
|
use crate::types::common::{Options, Think};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
@@ -66,6 +66,11 @@ pub struct ChatRequest {
|
|||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub format: Option<Value>,
|
pub format: Option<Value>,
|
||||||
|
|
||||||
|
/// 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<Think>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChatRequest {
|
impl ChatRequest {
|
||||||
@@ -96,6 +101,7 @@ impl ChatRequestBuilder {
|
|||||||
options: None,
|
options: None,
|
||||||
tools: vec![],
|
tools: vec![],
|
||||||
format: None,
|
format: None,
|
||||||
|
think: None,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,6 +131,11 @@ impl ChatRequestBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn think(mut self, think: Think) -> Self {
|
||||||
|
self.chat_request.think = Some(think);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(self) -> ChatRequest {
|
pub fn build(self) -> ChatRequest {
|
||||||
self.chat_request
|
self.chat_request
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user