fix: claude parallel function calling
This commit is contained in:
@@ -300,6 +300,13 @@ func StreamResponseClaude2OpenAI(reqMode int, claudeResponse *dto.ClaudeResponse
|
|||||||
response.Model = claudeResponse.Model
|
response.Model = claudeResponse.Model
|
||||||
response.Choices = make([]dto.ChatCompletionsStreamResponseChoice, 0)
|
response.Choices = make([]dto.ChatCompletionsStreamResponseChoice, 0)
|
||||||
tools := make([]dto.ToolCallResponse, 0)
|
tools := make([]dto.ToolCallResponse, 0)
|
||||||
|
fcIdx := 0
|
||||||
|
if claudeResponse.Index != nil {
|
||||||
|
fcIdx = *claudeResponse.Index - 1
|
||||||
|
if fcIdx < 0 {
|
||||||
|
fcIdx = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
var choice dto.ChatCompletionsStreamResponseChoice
|
var choice dto.ChatCompletionsStreamResponseChoice
|
||||||
if reqMode == RequestModeCompletion {
|
if reqMode == RequestModeCompletion {
|
||||||
choice.Delta.SetContentString(claudeResponse.Completion)
|
choice.Delta.SetContentString(claudeResponse.Completion)
|
||||||
@@ -319,7 +326,7 @@ func StreamResponseClaude2OpenAI(reqMode int, claudeResponse *dto.ClaudeResponse
|
|||||||
//choice.Delta.SetContentString(claudeResponse.ContentBlock.Text)
|
//choice.Delta.SetContentString(claudeResponse.ContentBlock.Text)
|
||||||
if claudeResponse.ContentBlock.Type == "tool_use" {
|
if claudeResponse.ContentBlock.Type == "tool_use" {
|
||||||
tools = append(tools, dto.ToolCallResponse{
|
tools = append(tools, dto.ToolCallResponse{
|
||||||
Index: common.GetPointer(0),
|
Index: common.GetPointer(fcIdx),
|
||||||
ID: claudeResponse.ContentBlock.Id,
|
ID: claudeResponse.ContentBlock.Id,
|
||||||
Type: "function",
|
Type: "function",
|
||||||
Function: dto.FunctionResponse{
|
Function: dto.FunctionResponse{
|
||||||
@@ -338,7 +345,7 @@ func StreamResponseClaude2OpenAI(reqMode int, claudeResponse *dto.ClaudeResponse
|
|||||||
case "input_json_delta":
|
case "input_json_delta":
|
||||||
tools = append(tools, dto.ToolCallResponse{
|
tools = append(tools, dto.ToolCallResponse{
|
||||||
Type: "function",
|
Type: "function",
|
||||||
Index: common.GetPointer(0),
|
Index: common.GetPointer(fcIdx),
|
||||||
Function: dto.FunctionResponse{
|
Function: dto.FunctionResponse{
|
||||||
Arguments: *claudeResponse.Delta.PartialJson,
|
Arguments: *claudeResponse.Delta.PartialJson,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user