mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-09 09:19:54 +00:00
reasoning effort control
This commit is contained in:
27
chat.go
27
chat.go
@@ -16,10 +16,16 @@ type Message struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type Reasoning struct {
|
||||
Effort string `json:"effort"`
|
||||
Tokens int `json:"tokens"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
Prompt string `json:"prompt"`
|
||||
Model string `json:"model"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
Reasoning Reasoning `json:"reasoning"`
|
||||
Messages []Message `json:"messages"`
|
||||
}
|
||||
|
||||
@@ -39,6 +45,21 @@ func (r *Request) Parse() (*openrouter.ChatCompletionRequest, error) {
|
||||
|
||||
request.Temperature = float32(r.Temperature)
|
||||
|
||||
if model.Reasoning {
|
||||
request.Reasoning = &openrouter.ChatCompletionReasoning{}
|
||||
|
||||
switch r.Reasoning.Effort {
|
||||
case "high", "medium", "low":
|
||||
request.Reasoning.Effort = &r.Reasoning.Effort
|
||||
default:
|
||||
if r.Reasoning.Tokens <= 0 || r.Reasoning.Tokens > 1024*1024 {
|
||||
return nil, fmt.Errorf("invalid reasoning tokens (1-1048576): %d", r.Reasoning.Tokens)
|
||||
}
|
||||
|
||||
request.Reasoning.MaxTokens = &r.Reasoning.Tokens
|
||||
}
|
||||
}
|
||||
|
||||
prompt, err := BuildPrompt(r.Prompt, model)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -61,12 +82,6 @@ func (r *Request) Parse() (*openrouter.ChatCompletionRequest, error) {
|
||||
})
|
||||
}
|
||||
|
||||
h := "high"
|
||||
|
||||
request.Reasoning = &openrouter.ChatCompletionReasoning{
|
||||
Effort: &h,
|
||||
}
|
||||
|
||||
return &request, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user