Add SystemFingerprint and chatMsg.ToolCallID field (#543)
* fix ToolChoiche typo * add tool_call_id to ChatCompletionMessage * add /chat system_fingerprint response field * check empty ToolCallID JSON marshaling and add omitempty for tool_call_id * messages also required; don't omitempty * add Type to ToolCall, required by the API * fix test, omitempty for response_format ptr * fix casing of role values in comments
This commit is contained in:
27
chat.go
27
chat.go
@@ -62,11 +62,17 @@ type ChatCompletionMessage struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
FunctionCall *FunctionCall `json:"function_call,omitempty"`
|
||||
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
||||
|
||||
// For Role=assistant prompts this may be set to the tool calls generated by the model, such as function calls.
|
||||
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
||||
|
||||
// For Role=tool prompts this should be set to the ID given in the assistant's prior request to call a tool.
|
||||
ToolCallID string `json:"tool_call_id,omitempty"`
|
||||
}
|
||||
|
||||
type ToolCall struct {
|
||||
ID string `json:"id"`
|
||||
Type ToolType `json:"type"`
|
||||
Function FunctionCall `json:"function"`
|
||||
}
|
||||
|
||||
@@ -84,7 +90,7 @@ const (
|
||||
)
|
||||
|
||||
type ChatCompletionResponseFormat struct {
|
||||
Type ChatCompletionResponseFormatType `json:"type"`
|
||||
Type ChatCompletionResponseFormatType `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// ChatCompletionRequest represents a request structure for chat completion API.
|
||||
@@ -112,7 +118,7 @@ type ChatCompletionRequest struct {
|
||||
FunctionCall any `json:"function_call,omitempty"`
|
||||
Tools []Tool `json:"tools,omitempty"`
|
||||
// This can be either a string or an ToolChoice object.
|
||||
ToolChoiche any `json:"tool_choice,omitempty"`
|
||||
ToolChoice any `json:"tool_choice,omitempty"`
|
||||
}
|
||||
|
||||
type ToolType string
|
||||
@@ -126,7 +132,7 @@ type Tool struct {
|
||||
Function FunctionDefinition `json:"function,omitempty"`
|
||||
}
|
||||
|
||||
type ToolChoiche struct {
|
||||
type ToolChoice struct {
|
||||
Type ToolType `json:"type"`
|
||||
Function ToolFunction `json:"function,omitempty"`
|
||||
}
|
||||
@@ -182,12 +188,13 @@ type ChatCompletionChoice struct {
|
||||
|
||||
// ChatCompletionResponse represents a response structure for chat completion API.
|
||||
type ChatCompletionResponse struct {
|
||||
ID string `json:"id"`
|
||||
Object string `json:"object"`
|
||||
Created int64 `json:"created"`
|
||||
Model string `json:"model"`
|
||||
Choices []ChatCompletionChoice `json:"choices"`
|
||||
Usage Usage `json:"usage"`
|
||||
ID string `json:"id"`
|
||||
Object string `json:"object"`
|
||||
Created int64 `json:"created"`
|
||||
Model string `json:"model"`
|
||||
Choices []ChatCompletionChoice `json:"choices"`
|
||||
Usage Usage `json:"usage"`
|
||||
SystemFingerprint string `json:"system_fingerprint"`
|
||||
|
||||
httpHeader
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user