diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-17 22:59:56 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-17 22:59:56 +0300 |
| commit | 0df6aba990ffd6eb42a14295249fefed1ac7adb5 (patch) | |
| tree | 8f992b6b0f703e15050bd2f3bc962440988b69d9 | |
| parent | 69e26ae14248e0c6e5ad6926097d5f48c7f2f2a2 (diff) | |
chore: commit uncommitted changes before version bump
| -rw-r--r-- | internal/llm/openai.go | 8 | ||||
| -rw-r--r-- | internal/llm/openai_request_test.go | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/internal/llm/openai.go b/internal/llm/openai.go index 8b00335..8a0d6d7 100644 --- a/internal/llm/openai.go +++ b/internal/llm/openai.go @@ -218,6 +218,14 @@ func buildOAChatRequest(o Options, messages []Message, defaultTemp *float64, str if len(o.Stop) > 0 { req.Stop = o.Stop } + // Enforce gpt-5 temperature constraints: only default (1.0) is supported. + if requiresMaxCompletionTokens(o.Model) { + if req.Temperature == nil || *req.Temperature != 1.0 { + t := 1.0 + req.Temperature = &t + logging.Logf("llm/openai ", "forcing temperature=1.0 for model=%s (gpt-5 constraint)", o.Model) + } + } return req } diff --git a/internal/llm/openai_request_test.go b/internal/llm/openai_request_test.go index f9925f9..001e3b7 100644 --- a/internal/llm/openai_request_test.go +++ b/internal/llm/openai_request_test.go @@ -22,6 +22,16 @@ func TestBuildOAChatRequest_MaxTokensKeyByModel(t *testing.T) { } } +func TestBuildOAChatRequest_TemperatureForcedForGpt5(t *testing.T) { + msgs := []Message{{Role: "user", Content: "hi"}} + // Explicit temp 0.2 → should be forced to 1.0 for gpt-5 + r := buildOAChatRequest(Options{Model: "gpt-5.0", Temperature: 0.2, MaxTokens: 50}, msgs, nil, false) + b, _ := json.Marshal(r) + if !contains(string(b), "\"temperature\":1") { + t.Fatalf("expected forced temperature 1.0 for gpt-5, got %s", string(b)) + } +} + func contains(s, sub string) bool { for i := 0; i+len(sub) <= len(s); i++ { if s[i:i+len(sub)] == sub { |
