From eb7660d724478ca5267a5bcff4c80d8f5cbace2a Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Thu, 21 Aug 2025 14:50:34 -0700 Subject: [PATCH] server: add thinking and tool calls to CompletionResponse --- llm/server.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/llm/server.go b/llm/server.go index 664a69fb36..ed5663bd9e 100644 --- a/llm/server.go +++ b/llm/server.go @@ -1374,13 +1374,15 @@ func (d DoneReason) String() string { } type CompletionResponse struct { - Content string `json:"content"` - DoneReason DoneReason `json:"done_reason"` - Done bool `json:"done"` - PromptEvalCount int `json:"prompt_eval_count"` - PromptEvalDuration time.Duration `json:"prompt_eval_duration"` - EvalCount int `json:"eval_count"` - EvalDuration time.Duration `json:"eval_duration"` + Content string `json:"content"` + Thinking string `json:"thinking"` + ToolCalls []api.ToolCall `json:"tool_calls"` + DoneReason DoneReason `json:"done_reason"` + Done bool `json:"done"` + PromptEvalCount int `json:"prompt_eval_count"` + PromptEvalDuration time.Duration `json:"prompt_eval_duration"` + EvalCount int `json:"eval_count"` + EvalDuration time.Duration `json:"eval_duration"` } func (s *llmServer) Completion(ctx context.Context, req CompletionRequest, fn func(CompletionResponse)) error { @@ -1511,10 +1513,8 @@ func (s *llmServer) Completion(ctx context.Context, req CompletionRequest, fn fu return ctx.Err() } - if c.Content != "" { - fn(CompletionResponse{ - Content: c.Content, - }) + if c.Content != "" || c.Thinking != "" || len(c.ToolCalls) > 0 { + fn(c) } if c.Done {