remove omitempty for toolcall index (#3148)

Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
rinfx
2025-11-24 16:14:00 +08:00
committed by GitHub
parent b2b4f72775
commit 7a504fd67d
2 changed files with 4 additions and 7 deletions

View File

@@ -107,9 +107,8 @@ func (b *bedrockProvider) convertEventFromBedrockToOpenAI(ctx wrapper.HttpContex
chatChoice.Delta.Content = nil
chatChoice.Delta.ToolCalls = []toolCall{
{
Id: bedrockEvent.Start.ToolUse.ToolUseID,
Index: 0,
Type: "function",
Id: bedrockEvent.Start.ToolUse.ToolUseID,
Type: "function",
Function: functionCall{
Name: bedrockEvent.Start.ToolUse.Name,
Arguments: "",
@@ -138,8 +137,7 @@ func (b *bedrockProvider) convertEventFromBedrockToOpenAI(ctx wrapper.HttpContex
if bedrockEvent.Delta.ToolUse != nil {
chatChoice.Delta.ToolCalls = []toolCall{
{
Index: 0,
Type: "function",
Type: "function",
Function: functionCall{
Arguments: bedrockEvent.Delta.ToolUse.Input,
},
@@ -168,7 +166,6 @@ func (b *bedrockProvider) convertEventFromBedrockToOpenAI(ctx wrapper.HttpContex
TotalTokens: bedrockEvent.Usage.TotalTokens,
}
}
openAIFormattedChunkBytes, _ := json.Marshal(openAIFormattedChunk)
var openAIChunk strings.Builder
openAIChunk.WriteString(ssePrefix)

View File

@@ -393,7 +393,7 @@ func (m *chatMessage) ParseContent() []chatMessageContent {
}
type toolCall struct {
Index int `json:"index,omitempty"`
Index int `json:"index"`
Id string `json:"id,omitempty"`
Type string `json:"type"`
Function functionCall `json:"function"`