Skip to content

Commit eb2549a

Browse files
committed
fix(gemini): update response template to omit finishReason until known
1 parent c419264 commit eb2549a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/translator/openai/gemini/openai_gemini_response.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ func ConvertOpenAIResponseToGemini(_ context.Context, _ string, originalRequestR
9797
var results []string
9898

9999
choices.ForEach(func(choiceIndex, choice gjson.Result) bool {
100-
// Base Gemini response template
101-
template := `{"candidates":[{"content":{"parts":[],"role":"model"},"finishReason":"STOP","index":0}]}`
100+
// Base Gemini response template without finishReason; set when known
101+
template := `{"candidates":[{"content":{"parts":[],"role":"model"},"index":0}]}`
102102

103103
// Set model if available
104104
if model := root.Get("model"); model.Exists() {
@@ -514,8 +514,8 @@ func tryParseNumber(s string) (interface{}, bool) {
514514
func ConvertOpenAIResponseToGeminiNonStream(_ context.Context, _ string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, _ *any) string {
515515
root := gjson.ParseBytes(rawJSON)
516516

517-
// Base Gemini response template
518-
out := `{"candidates":[{"content":{"parts":[],"role":"model"},"finishReason":"STOP","index":0}]}`
517+
// Base Gemini response template without finishReason; set when known
518+
out := `{"candidates":[{"content":{"parts":[],"role":"model"},"index":0}]}`
519519

520520
// Set model if available
521521
if model := root.Get("model"); model.Exists() {

0 commit comments

Comments
 (0)