correct output
This commit is contained in:
parent
7950053972
commit
23ff673bdc
@ -1403,19 +1403,18 @@ func (s *Server) ChatHandler(c *gin.Context) {
|
|||||||
if (req.Stream == nil || *req.Stream) && len(resp.Message.ToolCalls) > 0 {
|
if (req.Stream == nil || *req.Stream) && len(resp.Message.ToolCalls) > 0 {
|
||||||
toolCh := make(chan any)
|
toolCh := make(chan any)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer close(toolCh)
|
||||||
toolCalls := resp.Message.ToolCalls
|
toolCalls := resp.Message.ToolCalls
|
||||||
for _, toolCall := range toolCalls[:len(toolCalls)-1] {
|
for _, toolCall := range toolCalls {
|
||||||
chunk := api.ChatResponse{
|
toolCh <- api.ChatResponse{
|
||||||
Model: resp.Model,
|
Model: resp.Model,
|
||||||
CreatedAt: resp.CreatedAt,
|
CreatedAt: resp.CreatedAt,
|
||||||
Message: api.Message{Role: "assistant", ToolCalls: []api.ToolCall{toolCall}},
|
Message: api.Message{Role: "assistant", ToolCalls: []api.ToolCall{toolCall}},
|
||||||
DoneReason: "tool_calls",
|
|
||||||
}
|
}
|
||||||
toolCh <- chunk
|
|
||||||
}
|
}
|
||||||
resp.Message.ToolCalls = []api.ToolCall{toolCalls[len(toolCalls)-1]}
|
resp.Message.ToolCalls = nil
|
||||||
|
resp.DoneReason = "tool_calls"
|
||||||
toolCh <- resp
|
toolCh <- resp
|
||||||
close(toolCh)
|
|
||||||
}()
|
}()
|
||||||
streamResponse(c, toolCh)
|
streamResponse(c, toolCh)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user