From 0a3cc46a85c06f0da03a9d21507d4752693fdb00 Mon Sep 17 00:00:00 2001 From: Francisco Escher Date: Thu, 30 Nov 2023 12:27:13 -0300 Subject: [PATCH] updates chat completion response --- common.go | 17 +++++++++++++++-- completions.go | 8 ++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/common.go b/common.go index 4bbdda0..c6d2f74 100644 --- a/common.go +++ b/common.go @@ -18,11 +18,24 @@ func (e *Error) Error() string { // Message is the message struct for the chat and completions endpoint type Message struct { - Role string `json:"role,omitempty"` - Content string `json:"content,omitempty"` + Role string `json:"role,omitempty"` + Content string `json:"content,omitempty"` + ToolCalls []ToolCalls `json:"tool_calls,omitempty"` + // FunctionCall is deprecated in favor of ToolCalls FunctionCall *FunctionCall `json:"function_call,omitempty"` } +type ToolCalls struct { + ID string `json:"id,omitempty"` + Type string `json:"type,omitempty"` + Function ToolCallFunction `json:"function,omitempty"` +} + +type ToolCallFunction struct { + Name string `json:"name,omitempty"` + Arguments string `json:"arguments,omitempty"` +} + type FunctionCall struct { Name string `json:"name,omitempty"` Arguments string `json:"arguments,omitempty"` diff --git a/completions.go b/completions.go index a86f5f0..066e67f 100644 --- a/completions.go +++ b/completions.go @@ -76,12 +76,12 @@ type CompletionFunciton struct { type CreateChatCompletionsResponse struct { ID string `json:"id,omitempty"` - Object string `json:"object,omitempty"` + Choices []CreateChatCompletionsChoice `json:"choices,omitempty"` Created int `json:"created,omitempty"` Model string `json:"model,omitempty"` - Choices []CreateChatCompletionsChoice `json:"choices,omitempty"` - Usage CreateChatCompletionsUsave `json:"usage,omitempty"` SystemFingerprint string `json:"system_fingerprint,omitempty"` + Object string `json:"object,omitempty"` + Usage CreateChatCompletionsUsave `json:"usage,omitempty"` } type CreateChatCompletionsChoice struct { @@ -92,8 +92,8 @@ type CreateChatCompletionsChoice struct { } type CreateChatCompletionsUsave struct { - PromptTokens int `json:"prompt_tokens,omitempty"` CompletionTokens int `json:"completion_tokens,omitempty"` + PromptTokens int `json:"prompt_tokens,omitempty"` TotalTokens int `json:"total_tokens,omitempty"` }