mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-19 08:58:37 +00:00
Merge pull request #1967 from MomentDerek/main
fix: Gemini missing func name for multi-streaming tool calls (except the first)
This commit is contained in:
@@ -961,9 +961,15 @@ func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *
|
|||||||
// send first response
|
// send first response
|
||||||
emptyResponse := helper.GenerateStartEmptyResponse(id, createAt, info.UpstreamModelName, nil)
|
emptyResponse := helper.GenerateStartEmptyResponse(id, createAt, info.UpstreamModelName, nil)
|
||||||
if response.IsToolCall() {
|
if response.IsToolCall() {
|
||||||
emptyResponse.Choices[0].Delta.ToolCalls = make([]dto.ToolCallResponse, 1)
|
if len(emptyResponse.Choices) > 0 && len(response.Choices) > 0 {
|
||||||
emptyResponse.Choices[0].Delta.ToolCalls[0] = *response.GetFirstToolCall()
|
toolCalls := response.Choices[0].Delta.ToolCalls
|
||||||
emptyResponse.Choices[0].Delta.ToolCalls[0].Function.Arguments = ""
|
copiedToolCalls := make([]dto.ToolCallResponse, len(toolCalls))
|
||||||
|
for idx := range toolCalls {
|
||||||
|
copiedToolCalls[idx] = toolCalls[idx]
|
||||||
|
copiedToolCalls[idx].Function.Arguments = ""
|
||||||
|
}
|
||||||
|
emptyResponse.Choices[0].Delta.ToolCalls = copiedToolCalls
|
||||||
|
}
|
||||||
finishReason = constant.FinishReasonToolCalls
|
finishReason = constant.FinishReasonToolCalls
|
||||||
err = handleStream(c, info, emptyResponse)
|
err = handleStream(c, info, emptyResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user