fix: 工具调用 arguments 为空时保留 tool_use 块 (#5543)

This commit is contained in:
skynono
2026-06-17 17:07:05 +08:00
committed by GitHub
parent 8d87d5fd8b
commit 502858d35d
+4 -3
View File
@@ -410,9 +410,10 @@ func RequestOpenAI2ClaudeMessage(c *gin.Context, textRequest dto.GeneralOpenAIRe
if message.ToolCalls != nil {
for _, toolCall := range message.ParseToolCalls() {
inputObj := make(map[string]any)
if err := json.Unmarshal([]byte(toolCall.Function.Arguments), &inputObj); err != nil {
common.SysLog("tool call function arguments is not a map[string]any: " + fmt.Sprintf("%v", toolCall.Function.Arguments))
continue
if args := toolCall.Function.Arguments; args != "" {
if err := json.Unmarshal([]byte(args), &inputObj); err != nil {
common.SysLog("tool call function arguments is not a map[string]any: " + fmt.Sprintf("%v", toolCall.Function.Arguments))
}
}
claudeMediaMessages = append(claudeMediaMessages, dto.ClaudeMediaMessage{
Type: "tool_use",