mirror of
https://github.com/coaidev/coai.git
synced 2025-05-23 15:00:14 +09:00
support tools calling in chat_completions relay
This commit is contained in:
parent
c5ab97a94e
commit
dfec399d3d
@ -119,7 +119,11 @@ func sendTranshipmentResponse(c *gin.Context, form RelayForm, messages []globals
|
||||
Choices: []Choice{
|
||||
{
|
||||
Index: 0,
|
||||
Message: globals.Message{Role: globals.Assistant, Content: buffer.ReadWithDefault(defaultMessage)},
|
||||
Message: globals.Message{
|
||||
Role: globals.Assistant,
|
||||
Content: buffer.ReadWithDefault(defaultMessage),
|
||||
ToolCalls: buffer.GetToolCalls(),
|
||||
},
|
||||
FinishReason: "stop",
|
||||
},
|
||||
},
|
||||
@ -133,6 +137,11 @@ func sendTranshipmentResponse(c *gin.Context, form RelayForm, messages []globals
|
||||
}
|
||||
|
||||
func getStreamTranshipmentForm(id string, created int64, form RelayForm, data string, buffer *utils.Buffer, end bool, err error) RelayStreamResponse {
|
||||
var toolsCalling *globals.ToolCalls
|
||||
if end {
|
||||
toolsCalling = buffer.GetToolCalls()
|
||||
}
|
||||
|
||||
return RelayStreamResponse{
|
||||
Id: fmt.Sprintf("chatcmpl-%s", id),
|
||||
Object: "chat.completion.chunk",
|
||||
@ -144,6 +153,7 @@ func getStreamTranshipmentForm(id string, created int64, form RelayForm, data st
|
||||
Delta: globals.Message{
|
||||
Role: globals.Assistant,
|
||||
Content: data,
|
||||
ToolCalls: toolsCalling,
|
||||
},
|
||||
FinishReason: utils.Multi[interface{}](end, "stop", nil),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user