Skip to content

Commit f52114d

Browse files
authored
Merge branch 'router-for-me:main' into main
2 parents 12370ee + 5106caf commit f52114d

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

internal/translator/antigravity/openai/chat-completions/antigravity_openai_request.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
192192
} else if content.IsObject() && content.Get("type").String() == "text" {
193193
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
194194
out, _ = sjson.SetBytes(out, "request.systemInstruction.parts.0.text", content.Get("text").String())
195+
} else if content.IsArray() {
196+
contents := content.Array()
197+
if len(contents) > 0 {
198+
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
199+
for j := 0; j < len(contents); j++ {
200+
out, _ = sjson.SetBytes(out, fmt.Sprintf("request.systemInstruction.parts.%d.text", j), contents[j].Get("text").String())
201+
}
202+
}
195203
}
196204
} else if role == "user" || (role == "system" && len(arr) == 1) {
197205
// Build single user content node to avoid splitting into multiple contents

internal/translator/gemini-cli/openai/chat-completions/gemini-cli_openai_request.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo
160160
} else if content.IsObject() && content.Get("type").String() == "text" {
161161
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
162162
out, _ = sjson.SetBytes(out, "request.systemInstruction.parts.0.text", content.Get("text").String())
163+
} else if content.IsArray() {
164+
contents := content.Array()
165+
if len(contents) > 0 {
166+
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
167+
for j := 0; j < len(contents); j++ {
168+
out, _ = sjson.SetBytes(out, fmt.Sprintf("request.systemInstruction.parts.%d.text", j), contents[j].Get("text").String())
169+
}
170+
}
163171
}
164172
} else if role == "user" || (role == "system" && len(arr) == 1) {
165173
// Build single user content node to avoid splitting into multiple contents

internal/translator/gemini/openai/chat-completions/gemini_openai_request.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
178178
} else if content.IsObject() && content.Get("type").String() == "text" {
179179
out, _ = sjson.SetBytes(out, "system_instruction.role", "user")
180180
out, _ = sjson.SetBytes(out, "system_instruction.parts.0.text", content.Get("text").String())
181+
} else if content.IsArray() {
182+
contents := content.Array()
183+
if len(contents) > 0 {
184+
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
185+
for j := 0; j < len(contents); j++ {
186+
out, _ = sjson.SetBytes(out, fmt.Sprintf("request.systemInstruction.parts.%d.text", j), contents[j].Get("text").String())
187+
}
188+
}
181189
}
182190
} else if role == "user" || (role == "system" && len(arr) == 1) {
183191
// Build single user content node to avoid splitting into multiple contents

0 commit comments

Comments
 (0)