Skip to content

Commit

Permalink
updates chat completion response
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoescher committed Nov 30, 2023
1 parent c5ff0bc commit 0a3cc46
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
17 changes: 15 additions & 2 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
8 changes: 4 additions & 4 deletions completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"`
}

Expand Down

0 comments on commit 0a3cc46

Please sign in to comment.