fix(openai): preserve temperature for Responses requests

This commit is contained in:
loveuer committed 2026-09-23 17:14:22 +08:00
1 parent 8bac66dd5a
commit 22bf9018a7
2 files changed
+5 -2

No files matched your search

+3
View File
@@ -504,6 +504,9 @@ func (p *Provider) buildResponsesRequestBody(
if maxTokens, ok := common.AsInt(options["max_tokens"]); ok {
requestBody["max_output_tokens"] = maxTokens
}
if temperature, ok := common.AsFloat(options["temperature"]); ok {
requestBody["temperature"] = temperature
}
if cacheKey, ok := options["prompt_cache_key"].(string); ok && cacheKey != "" &&
supportsPromptCacheKey(p.apiBase) {
requestBody["prompt_cache_key"] = cacheKey
+2 -2
View File
@@ -94,8 +94,8 @@ func TestProviderChat_OpenAIUsesResponsesAPI(t *testing.T) {
if requestBody["max_output_tokens"] != float64(256) {
t.Fatalf("max_output_tokens = %v, want 256", requestBody["max_output_tokens"])
}
if _, ok := requestBody["temperature"]; ok {
t.Fatalf("temperature should be omitted from Responses request, got %v", requestBody["temperature"])
if requestBody["temperature"] != 0.2 {
t.Fatalf("temperature = %v, want 0.2", requestBody["temperature"])
}
if requestBody["prompt_cache_key"] != "agent-main" {
t.Fatalf("prompt_cache_key = %v, want agent-main", requestBody["prompt_cache_key"])