mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 20:30:51 +08:00
Merge pull request #441 from huynguyen03dev/fix/claude-to-openai-whitespace-text
fix: filter whitespace-only text in Claude to OpenAI translation
This commit is contained in:
@@ -8,6 +8,7 @@ package claude
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
"github.com/tidwall/sjson"
|
"github.com/tidwall/sjson"
|
||||||
@@ -242,11 +243,12 @@ func convertClaudeContentPart(part gjson.Result) (string, bool) {
|
|||||||
|
|
||||||
switch partType {
|
switch partType {
|
||||||
case "text":
|
case "text":
|
||||||
if !part.Get("text").Exists() {
|
text := part.Get("text").String()
|
||||||
|
if strings.TrimSpace(text) == "" {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
textContent := `{"type":"text","text":""}`
|
textContent := `{"type":"text","text":""}`
|
||||||
textContent, _ = sjson.Set(textContent, "text", part.Get("text").String())
|
textContent, _ = sjson.Set(textContent, "text", text)
|
||||||
return textContent, true
|
return textContent, true
|
||||||
|
|
||||||
case "image":
|
case "image":
|
||||||
|
|||||||
Reference in New Issue
Block a user