feat: xunfei support functions

This commit is contained in:
MartialBE
2024-01-02 22:40:47 +08:00
committed by Buer
parent 3b8ae9a6cd
commit e052009eba
4 changed files with 95 additions and 30 deletions

View File

@@ -5,13 +5,24 @@ const (
ContentTypeImageURL = "image_url"
)
type ChatCompletionToolCallsFunction struct {
Name string `json:"name"`
Arguments string `json:"arguments"`
}
type ChatCompletionToolCalls struct {
Id string `json:"id"`
Type string `json:"type"`
Function ChatCompletionToolCallsFunction `json:"function"`
}
type ChatCompletionMessage struct {
Role string `json:"role"`
Content any `json:"content"`
Name *string `json:"name,omitempty"`
FunctionCall any `json:"function_call,omitempty"`
ToolCalls any `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Role string `json:"role"`
Content any `json:"content,omitempty"`
Name *string `json:"name,omitempty"`
FunctionCall *ChatCompletionToolCallsFunction `json:"function_call,omitempty"`
ToolCalls []*ChatCompletionToolCalls `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
func (m ChatCompletionMessage) StringContent() string {
@@ -112,12 +123,23 @@ type ChatCompletionRequest struct {
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
LogitBias any `json:"logit_bias,omitempty"`
User string `json:"user,omitempty"`
Functions any `json:"functions,omitempty"`
Functions []*ChatCompletionFunction `json:"functions,omitempty"`
FunctionCall any `json:"function_call,omitempty"`
Tools any `json:"tools,omitempty"`
Tools []*ChatCompletionTool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
}
type ChatCompletionFunction struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters any `json:"parameters"`
}
type ChatCompletionTool struct {
Type string `json:"type"`
Function ChatCompletionFunction `json:"function"`
}
type ChatCompletionChoice struct {
Index int `json:"index"`
Message ChatCompletionMessage `json:"message"`