1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-09 09:19:54 +00:00

json & web search

This commit is contained in:
Laura
2025-08-11 00:15:58 +02:00
parent 5ae60e0f94
commit a8cbef7c7b
19 changed files with 374 additions and 59 deletions

14
chat.go
View File

@@ -25,6 +25,8 @@ type Request struct {
Prompt string `json:"prompt"`
Model string `json:"model"`
Temperature float64 `json:"temperature"`
JSON bool `json:"json"`
Search bool `json:"search"`
Reasoning Reasoning `json:"reasoning"`
Messages []Message `json:"messages"`
}
@@ -60,6 +62,18 @@ func (r *Request) Parse() (*openrouter.ChatCompletionRequest, error) {
}
}
if model.JSON && r.JSON {
request.ResponseFormat = &openrouter.ChatCompletionResponseFormat{
Type: openrouter.ChatCompletionResponseFormatTypeJSONObject,
}
}
if r.Search {
request.Plugins = append(request.Plugins, openrouter.ChatCompletionPlugin{
ID: openrouter.PluginIDWeb,
})
}
prompt, err := BuildPrompt(r.Prompt, model)
if err != nil {
return nil, err