mirror of
https://github.com/ollama/ollama.git
synced 2025-11-11 17:46:53 +01:00
server: add thinking and tool calls to CompletionResponse
This commit is contained in:
@@ -1374,13 +1374,15 @@ func (d DoneReason) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CompletionResponse struct {
|
type CompletionResponse struct {
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
DoneReason DoneReason `json:"done_reason"`
|
Thinking string `json:"thinking"`
|
||||||
Done bool `json:"done"`
|
ToolCalls []api.ToolCall `json:"tool_calls"`
|
||||||
PromptEvalCount int `json:"prompt_eval_count"`
|
DoneReason DoneReason `json:"done_reason"`
|
||||||
PromptEvalDuration time.Duration `json:"prompt_eval_duration"`
|
Done bool `json:"done"`
|
||||||
EvalCount int `json:"eval_count"`
|
PromptEvalCount int `json:"prompt_eval_count"`
|
||||||
EvalDuration time.Duration `json:"eval_duration"`
|
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 {
|
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()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Content != "" {
|
if c.Content != "" || c.Thinking != "" || len(c.ToolCalls) > 0 {
|
||||||
fn(CompletionResponse{
|
fn(c)
|
||||||
Content: c.Content,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Done {
|
if c.Done {
|
||||||
|
|||||||
Reference in New Issue
Block a user