fix
This commit is contained in:
@@ -179,6 +179,52 @@ func TestOpenAIClient_doComplete_emptyContentWithReasoningJSON(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenAIClient_doComplete_gpt56LunaUsesMaxCompletionTokens(t *testing.T) {
|
||||
t.Parallel()
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var req map[string]any
|
||||
_ = json.NewDecoder(r.Body).Decode(&req)
|
||||
if _, ok := req["temperature"]; ok {
|
||||
t.Errorf("temperature must be omitted for gpt-5.6-luna")
|
||||
}
|
||||
if _, ok := req["max_tokens"]; ok {
|
||||
t.Errorf("max_tokens must be omitted for gpt-5.6-luna")
|
||||
}
|
||||
gotMax, _ := req["max_completion_tokens"].(float64)
|
||||
if int(gotMax) != MaxTokensEnhance {
|
||||
t.Errorf("max_completion_tokens=%v want %d", gotMax, MaxTokensEnhance)
|
||||
}
|
||||
if req["reasoning_effort"] != "low" {
|
||||
t.Errorf("reasoning_effort=%v want low", req["reasoning_effort"])
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"model": "gpt-5.6-luna",
|
||||
"choices": []map[string]any{{
|
||||
"finish_reason": "stop",
|
||||
"message": map[string]any{
|
||||
"role": "assistant",
|
||||
"content": `{"name":"Acme Monitor","description":"<h1>Acme Monitor</h1><p>IPS panel for office use.</p>"}`,
|
||||
},
|
||||
}},
|
||||
"usage": map[string]int{"prompt_tokens": 20, "completion_tokens": 40, "total_tokens": 60},
|
||||
})
|
||||
}))
|
||||
defer srv.Close()
|
||||
c := NewOpenAIClient("test-key", srv.URL, "gpt-5.6-luna", 0, 1)
|
||||
c.HTTPClient = srv.Client()
|
||||
comp, err := c.CompleteWithOptions(context.Background(), "sys", "user", CompleteOptions{
|
||||
MaxTokens: MaxTokensEnhance,
|
||||
Temperature: DefaultStructuredTemp,
|
||||
ReasoningEffort: "low",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(comp.Text, "Acme Monitor") {
|
||||
t.Fatalf("text=%q", comp.Text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenAIClient_doComplete_emptyContentLengthRetriesWithBudget(t *testing.T) {
|
||||
t.Parallel()
|
||||
calls := 0
|
||||
|
||||
Reference in New Issue
Block a user