Unified · Split
| @@ -8,7 +8,6 @@ package chat_completions · 7 unmodified lines | ||
| 8 | 8 | import ( |
| 9 | 9 | "bytes" |
| 10 | 10 | "context" |
| 11 | − "encoding/json" | |
| 12 | 11 | "fmt" |
| 13 | 12 | "strings" |
| 14 | 13 | "sync/atomic" |
| @@ -187,18 +186,11 @@ func ConvertAntigravityResponseToOpenAI(_ context.Context, _ string, originalReq · 172 unmodified lines | ||
| 187 | 186 | template, _ = sjson.SetRaw(template, "choices.0.delta.images", `[]`) |
| 188 | 187 | } |
| 189 | 188 | imageIndex := len(gjson.Get(template, "choices.0.delta.images").Array()) |
| 190 | − imagePayload, err := json.Marshal(map[string]any{ | |
| 191 | − "index": imageIndex, | |
| 192 | − "type": "image_url", | |
| 193 | − "image_url": map[string]string{ | |
| 194 | − "url": imageURL, | |
| 195 | − }, | |
| 196 | − }) | |
| 197 | − if err != nil { | |
| 198 | − continue | |
| 199 | − } | |
| 189 | + imagePayload := `{"type":"image_url","image_url":{"url":""}}` | |
| 190 | + imagePayload, _ = sjson.Set(imagePayload, "index", imageIndex) | |
| 191 | + imagePayload, _ = sjson.Set(imagePayload, "image_url.url", imageURL) | |
| 200 | 192 | template, _ = sjson.Set(template, "choices.0.delta.role", "assistant") |
| 201 | − template, _ = sjson.SetRaw(template, "choices.0.delta.images.-1", string(imagePayload)) | |
| 193 | + template, _ = sjson.SetRaw(template, "choices.0.delta.images.-1", imagePayload) | |
| 202 | 194 | } |
| 203 | 195 | } |
| 204 | 196 | } |
| @@ -8,7 +8,6 @@ package chat_completions · 7 unmodified lines | ||
| 8 | 8 | import ( |
| 9 | 9 | "bytes" |
| 10 | 10 | "context" |
| 11 | − "encoding/json" | |
| 12 | 11 | "fmt" |
| 13 | 12 | "strings" |
| 14 | 13 | "sync/atomic" |
| @@ -176,18 +175,11 @@ func ConvertCliResponseToOpenAI(_ context.Context, _ string, originalRequestRawJ · 161 unmodified lines | ||
| 176 | 175 | template, _ = sjson.SetRaw(template, "choices.0.delta.images", `[]`) |
| 177 | 176 | } |
| 178 | 177 | imageIndex := len(gjson.Get(template, "choices.0.delta.images").Array()) |
| 179 | − imagePayload, err := json.Marshal(map[string]any{ | |
| 180 | − "index": imageIndex, | |
| 181 | − "type": "image_url", | |
| 182 | − "image_url": map[string]string{ | |
| 183 | − "url": imageURL, | |
| 184 | − }, | |
| 185 | − }) | |
| 186 | − if err != nil { | |
| 187 | − continue | |
| 188 | − } | |
| 178 | + imagePayload := `{"type":"image_url","image_url":{"url":""}}` | |
| 179 | + imagePayload, _ = sjson.Set(imagePayload, "index", imageIndex) | |
| 180 | + imagePayload, _ = sjson.Set(imagePayload, "image_url.url", imageURL) | |
| 189 | 181 | template, _ = sjson.Set(template, "choices.0.delta.role", "assistant") |
| 190 | − template, _ = sjson.SetRaw(template, "choices.0.delta.images.-1", string(imagePayload)) | |
| 182 | + template, _ = sjson.SetRaw(template, "choices.0.delta.images.-1", imagePayload) | |
| 191 | 183 | } |
| 192 | 184 | } |
| 193 | 185 | } |
| @@ -8,7 +8,6 @@ package chat_completions · 7 unmodified lines | ||
| 8 | 8 | import ( |
| 9 | 9 | "bytes" |
| 10 | 10 | "context" |
| 11 | − "encoding/json" | |
| 12 | 11 | "fmt" |
| 13 | 12 | "strings" |
| 14 | 13 | "sync/atomic" |
| @@ -188,18 +187,11 @@ func ConvertGeminiResponseToOpenAI(_ context.Context, _ string, originalRequestR · 173 unmodified lines | ||
| 188 | 187 | template, _ = sjson.SetRaw(template, "choices.0.delta.images", `[]`) |
| 189 | 188 | } |
| 190 | 189 | imageIndex := len(gjson.Get(template, "choices.0.delta.images").Array()) |
| 191 | − imagePayload, err := json.Marshal(map[string]any{ | |
| 192 | − "index": imageIndex, | |
| 193 | − "type": "image_url", | |
| 194 | − "image_url": map[string]string{ | |
| 195 | − "url": imageURL, | |
| 196 | − }, | |
| 197 | − }) | |
| 198 | − if err != nil { | |
| 199 | − continue | |
| 200 | − } | |
| 190 | + imagePayload := `{"type":"image_url","image_url":{"url":""}}` | |
| 191 | + imagePayload, _ = sjson.Set(imagePayload, "index", imageIndex) | |
| 192 | + imagePayload, _ = sjson.Set(imagePayload, "image_url.url", imageURL) | |
| 201 | 193 | template, _ = sjson.Set(template, "choices.0.delta.role", "assistant") |
| 202 | − template, _ = sjson.SetRaw(template, "choices.0.delta.images.-1", string(imagePayload)) | |
| 194 | + template, _ = sjson.SetRaw(template, "choices.0.delta.images.-1", imagePayload) | |
| 203 | 195 | } |
| 204 | 196 | } |
| 205 | 197 | } |
| @@ -331,18 +323,11 @@ func ConvertGeminiResponseToOpenAINonStream(_ context.Context, _ string, origina · 125 unmodified lines | ||
| 331 | 323 | template, _ = sjson.SetRaw(template, "choices.0.message.images", `[]`) |
| 332 | 324 | } |
| 333 | 325 | imageIndex := len(gjson.Get(template, "choices.0.message.images").Array()) |
| 334 | − imagePayload, err := json.Marshal(map[string]any{ | |
| 335 | − "index": imageIndex, | |
| 336 | − "type": "image_url", | |
| 337 | − "image_url": map[string]string{ | |
| 338 | − "url": imageURL, | |
| 339 | − }, | |
| 340 | − }) | |
| 341 | − if err != nil { | |
| 342 | − continue | |
| 343 | − } | |
| 326 | + imagePayload := `{"type":"image_url","image_url":{"url":""}}` | |
| 327 | + imagePayload, _ = sjson.Set(imagePayload, "index", imageIndex) | |
| 328 | + imagePayload, _ = sjson.Set(imagePayload, "image_url.url", imageURL) | |
| 344 | 329 | template, _ = sjson.Set(template, "choices.0.message.role", "assistant") |
| 345 | − template, _ = sjson.SetRaw(template, "choices.0.message.images.-1", string(imagePayload)) | |
| 330 | + template, _ = sjson.SetRaw(template, "choices.0.message.images.-1", imagePayload) | |
| 346 | 331 | } |
| 347 | 332 | } |
| 348 | 333 | } |