Skip to content

Commit

Permalink
feat: tool_calls support added to response
Browse files Browse the repository at this point in the history
  • Loading branch information
nurali-techie committed Feb 1, 2025
1 parent 835eaeb commit 11bccbd
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,60 @@ type ChatCompletionsResponse struct {
Model string `json:"model"`
SystemFingerprint string `json:"system_fingerprint"`
Object string `json:"object"`
Usage *Usage `json:"usage"`
Usage *Usage `json:"usage,omitempty"`
}

type Choice struct {
FinishReason string `json:"finish_reason"`
Index int `json:"index"`
Message *Message `json:"message"`
Delta *Delta `json:"delta"` // TODO: VN -- mesage and delta in one struct or diff?
Delta *Delta `json:"delta"`
Logprobs *Logprobs `json:"logprobs"`
}

type Message struct {
Role string `json:"role"` // TODO: VN -- support roles like system, user, assistant, tool
Content string `json:"content"` // TODO: VN -- make it []byte
ReasoningContent string `json:"reasoning_content"` // TODO: VN -- make it []byte
Role string `json:"role"`
Content string `json:"content"`
ReasoningContent string `json:"reasoning_content"`
ToolCalls []*ToolCall `json:"tool_calls"`
}

type ToolCall struct {
Id string `json:"id"`
Type string `json:"type"`
Function ToolFunction `json:"function"`
}

type ToolFunction struct {
Name string `json:"name"`
Arguments string `json:"arguments"`
}

type Delta struct {
Content string `json:"content"` // TODO: VN -- make it []byte
ReasoningContent string `json:"reasoning_content"` // TODO: VN -- make it []byte
Content string `json:"content"`
ReasoningContent string `json:"reasoning_content"`
}

type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
PromptTokensDetails *PromptTokensDetails `json:"prompt_tokens_details"`
PromptCacheHitTokens int `json:"prompt_cache_hit_tokens"`
PromptCacheMissTokens int `json:"prompt_cache_miss_tokens"`
CompletionTokens int `json:"completion_tokens"`
PromptTokens int `json:"prompt_tokens"`
PromptCacheHitTokens int `json:"prompt_cache_hit_tokens"`
PromptCacheMissTokens int `json:"prompt_cache_miss_tokens"`
TotalTokens int `json:"total_tokens"`
PromptTokensDetails PromptTokensDetails `json:"prompt_tokens_details"`
CompletionTokensDetails CompletionTokensDetails `json:"completion_tokens_details"`
}

type PromptTokensDetails struct {
CachedTokens int `json:"cached_tokens"`
}

type CompletionTokensDetails struct {
ReasoningTokens int `json:"reasoning_tokens"`
}

type Logprobs struct {
Content *Content `json:"content"`
Content *[]Content `json:"content"`
}

type Content struct {
Expand Down

0 comments on commit 11bccbd

Please sign in to comment.