Refactor Query function to include token usage in response

This commit is contained in:
kardolus
2024-04-20 12:08:33 -04:00
parent 154f0331a4
commit ca2e544603
5 changed files with 64 additions and 40 deletions

View File

@@ -17,18 +17,20 @@ type Message struct {
}
type CompletionsResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
} `json:"usage"`
ID string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
Usage Usage `json:"usage"`
Choices []Choice `json:"choices"`
}
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
}
type Choice struct {
Message Message `json:"message"`
FinishReason string `json:"finish_reason"`