mirror of
https://github.com/coaidev/coai.git
synced 2025-05-24 07:20:15 +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{
|
Choices: []Choice{
|
||||||
{
|
{
|
||||||
Index: 0,
|
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",
|
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 {
|
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{
|
return RelayStreamResponse{
|
||||||
Id: fmt.Sprintf("chatcmpl-%s", id),
|
Id: fmt.Sprintf("chatcmpl-%s", id),
|
||||||
Object: "chat.completion.chunk",
|
Object: "chat.completion.chunk",
|
||||||
@ -144,6 +153,7 @@ func getStreamTranshipmentForm(id string, created int64, form RelayForm, data st
|
|||||||
Delta: globals.Message{
|
Delta: globals.Message{
|
||||||
Role: globals.Assistant,
|
Role: globals.Assistant,
|
||||||
Content: data,
|
Content: data,
|
||||||
|
ToolCalls: toolsCalling,
|
||||||
},
|
},
|
||||||
FinishReason: utils.Multi[interface{}](end, "stop", nil),
|
FinishReason: utils.Multi[interface{}](end, "stop", nil),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user