Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions agent/provider/ollama/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ func (c *Client) GenerateWithModel(ctx context.Context, prompt, model string, fo
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return "", fmt.Errorf("decode ollama response: %w", err)
}
c.Logger.Printf("[ollama] generate done, response_len=%d", len(result.Response))
return result.Response, nil
response := result.Response
if response == "" && result.Thinking != "" {
response = result.Thinking
}
c.Logger.Printf("[ollama] generate done, response_len=%d", len(response))
return response, nil
}

// GenerateStream sends a streaming generate request.
Expand Down
2 changes: 2 additions & 0 deletions agent/provider/ollama/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ type GenerateRequest struct {
Stream bool `json:"stream"`
Format any `json:"format,omitempty"`
Options any `json:"options,omitempty"`
Think *bool `json:"think,omitempty"`
}

type GenerateResponse struct {
Response string `json:"response"`
Thinking string `json:"thinking,omitempty"`
Done bool `json:"done"`
}

Expand Down
Loading