fix: default empty input_json_delta arguments to {} for tool call parsing

This commit is contained in:
Seefs
2026-03-02 15:51:55 +08:00
parent da11617776
commit 2df604bbad
2 changed files with 45 additions and 1 deletions

View File

@@ -451,11 +451,17 @@ func StreamResponseClaude2OpenAI(claudeResponse *dto.ClaudeResponse) *dto.ChatCo
choice.Delta.Content = claudeResponse.Delta.Text
switch claudeResponse.Delta.Type {
case "input_json_delta":
arguments := "{}"
if claudeResponse.Delta.PartialJson != nil {
if partial := strings.TrimSpace(*claudeResponse.Delta.PartialJson); partial != "" {
arguments = partial
}
}
tools = append(tools, dto.ToolCallResponse{
Type: "function",
Index: common.GetPointer(fcIdx),
Function: dto.FunctionResponse{
Arguments: *claudeResponse.Delta.PartialJson,
Arguments: arguments,
},
})
case "signature_delta":