Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ const (
ChatMessagePartTypeImageURL ChatMessagePartType = "image_url"
)

// CacheControlConfig for anthropic prompt cache control.
type CacheControlConfig struct {
Type string `json:"type,omitempty"`
TTL string `json:"ttl,omitempty"`
}

type ChatMessagePart struct {
Type ChatMessagePartType `json:"type,omitempty"`
Text string `json:"text,omitempty"`
ImageURL *ChatMessageImageURL `json:"image_url,omitempty"`
Type ChatMessagePartType `json:"type,omitempty"`
Text string `json:"text,omitempty"`
ImageURL *ChatMessageImageURL `json:"image_url,omitempty"`
CacheControl *CacheControlConfig `json:"cache_control,omitempty"`
}

type ChatCompletionMessage struct {
Expand Down Expand Up @@ -344,8 +351,9 @@ const (
)

type Tool struct {
Type ToolType `json:"type"`
Function *FunctionDefinition `json:"function,omitempty"`
Type ToolType `json:"type"`
Function *FunctionDefinition `json:"function,omitempty"`
CacheControl *CacheControlConfig `json:"cache_control,omitempty"`
}

type ToolChoice struct {
Expand Down
1 change: 1 addition & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Usage struct {
TotalTokens int `json:"total_tokens"`
PromptTokensDetails *PromptTokensDetails `json:"prompt_tokens_details"`
CompletionTokensDetails *CompletionTokensDetails `json:"completion_tokens_details"`
CacheReadInputTokens int `json:"cache_read_input_tokens"`
}

// CompletionTokensDetails Breakdown of tokens used in a completion.
Expand Down
Loading