Enhance OpenAI Provider Request Body with Thinking Parameter
- Added support for a new "thinking" parameter in the request body for models that support reasoning/thinking mode, improving functionality. - Updated the request body construction to include debugging output for the full request body, aiding in troubleshooting and development. - Ensured that the model and other settings are retrieved from the connector, maintaining consistency in configuration handling.
This commit is contained in:
parent
042066e6b3
commit
994950f273
1 changed files with 18 additions and 1 deletions
|
|
@ -1039,13 +1039,19 @@ func (p *Provider) buildRequestBody(messages []context.Message, options *context
|
|||
return nil, fmt.Errorf("options are required")
|
||||
}
|
||||
|
||||
// Get model from connector settings
|
||||
// Get model and other settings from connector
|
||||
setting := p.Connector.Setting()
|
||||
model, ok := setting["model"].(string)
|
||||
if !ok || model == "" {
|
||||
return nil, fmt.Errorf("model is not set in connector")
|
||||
}
|
||||
|
||||
// Get thinking setting from connector (for models that support reasoning/thinking mode)
|
||||
var thinkingSetting interface{}
|
||||
if thinking, exists := setting["thinking"]; exists {
|
||||
thinkingSetting = thinking
|
||||
}
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, 0, len(messages))
|
||||
for _, msg := range messages {
|
||||
|
|
@ -1202,6 +1208,17 @@ func (p *Provider) buildRequestBody(messages []context.Message, options *context
|
|||
body["audio"] = options.Audio
|
||||
}
|
||||
|
||||
// Add thinking parameter for models that support reasoning/thinking mode
|
||||
if thinkingSetting != nil {
|
||||
body["thinking"] = thinkingSetting
|
||||
fmt.Printf("[DEBUG] Adding thinking parameter to request: %+v\n", thinkingSetting)
|
||||
}
|
||||
|
||||
// Debug: Print full request body
|
||||
if bodyJSON, err := jsoniter.MarshalIndent(body, "", " "); err == nil {
|
||||
fmt.Printf("[DEBUG] Request body:\n%s\n", string(bodyJSON))
|
||||
}
|
||||
|
||||
return body, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue