mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(translator): add check for empty text to prevent invalid serialization in gemini and antigravity
This commit is contained in:
@@ -169,7 +169,10 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
switch item.Get("type").String() {
|
switch item.Get("type").String() {
|
||||||
case "text":
|
case "text":
|
||||||
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".text", item.Get("text").String())
|
text := item.Get("text").String()
|
||||||
|
if text != "" {
|
||||||
|
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".text", text)
|
||||||
|
}
|
||||||
p++
|
p++
|
||||||
case "image_url":
|
case "image_url":
|
||||||
imageURL := item.Get("image_url.url").String()
|
imageURL := item.Get("image_url.url").String()
|
||||||
@@ -213,7 +216,10 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
for _, item := range content.Array() {
|
for _, item := range content.Array() {
|
||||||
switch item.Get("type").String() {
|
switch item.Get("type").String() {
|
||||||
case "text":
|
case "text":
|
||||||
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".text", item.Get("text").String())
|
text := item.Get("text").String()
|
||||||
|
if text != "" {
|
||||||
|
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".text", text)
|
||||||
|
}
|
||||||
p++
|
p++
|
||||||
case "image_url":
|
case "image_url":
|
||||||
// If the assistant returned an inline data URL, preserve it for history fidelity.
|
// If the assistant returned an inline data URL, preserve it for history fidelity.
|
||||||
|
|||||||
@@ -166,7 +166,10 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
switch item.Get("type").String() {
|
switch item.Get("type").String() {
|
||||||
case "text":
|
case "text":
|
||||||
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".text", item.Get("text").String())
|
text := item.Get("text").String()
|
||||||
|
if text != "" {
|
||||||
|
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".text", text)
|
||||||
|
}
|
||||||
p++
|
p++
|
||||||
case "image_url":
|
case "image_url":
|
||||||
imageURL := item.Get("image_url.url").String()
|
imageURL := item.Get("image_url.url").String()
|
||||||
@@ -211,6 +214,10 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
for _, item := range content.Array() {
|
for _, item := range content.Array() {
|
||||||
switch item.Get("type").String() {
|
switch item.Get("type").String() {
|
||||||
case "text":
|
case "text":
|
||||||
|
text := item.Get("text").String()
|
||||||
|
if text != "" {
|
||||||
|
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".text", text)
|
||||||
|
}
|
||||||
p++
|
p++
|
||||||
case "image_url":
|
case "image_url":
|
||||||
// If the assistant returned an inline data URL, preserve it for history fidelity.
|
// If the assistant returned an inline data URL, preserve it for history fidelity.
|
||||||
|
|||||||
Reference in New Issue
Block a user