pub struct Completion {
pub content: String,
pub tool_calls: Vec<ToolCall>,
pub finish_reason: Option<String>,
pub usage: Option<TokenUsage>,
pub reasoning_content: Option<String>,
}Expand description
One step of model output.
Fields§
§content: String§tool_calls: Vec<ToolCall>§finish_reason: Option<String>§usage: Option<TokenUsage>§reasoning_content: Option<String>DeepSeek reasoning/thinking content. Stored in the transcript and echoed back on subsequent requests to satisfy the API contract.
Implementations§
Source§impl Completion
impl Completion
Sourcepub fn extract_inline_reasoning(&mut self)
pub fn extract_inline_reasoning(&mut self)
Normalise chain-of-thought that a model emitted inline in the
content field wrapped in <think>…</think> tags into the
dedicated Completion::reasoning_content channel.
Many DeepSeek-R1 style deployments (and OpenAI-compatible proxies)
don’t populate the separate reasoning_content SSE field; they
stream the thinking inline as <think>…</think> inside content.
Downstream the TUI markdown renderer parses those tags as an HTML
block and silently drops the whole section — so the thinking is
visible while streaming but disappears once the turn finalises and
the assistant block is re-rendered from content.
This moves the inner text into reasoning_content (so the existing
AgentEvent::Reasoning → thinking-block pipeline lights up) and
strips the tags from content (so the answer renders cleanly).
No-op when reasoning_content is already populated (true reasoner
models that use the dedicated field) or when no <think> tag is
present.