Documentation
¶
Index ¶
- Variables
- type CompletionRequest
- type CompletionResponse
- type CostEstimator
- func (ce *CostEstimator) Count(input string) int
- func (ce *CostEstimator) CountMessagesTokens(messages []Message) int
- func (ce *CostEstimator) EstimateCompletionCost(model string, tks int) (float64, error)
- func (ce *CostEstimator) EstimatePromptCost(model string, tks int) (float64, error)
- func (ce *CostEstimator) EstimateTotalCost(model string, promptTks, completionTks int) (float64, error)
- type Error
- type ErrorResponse
- type Message
- type MessageResponseContent
- type MessagesRequest
- type MessagesResponse
- type MessagesStreamBlockDelta
- type MessagesStreamBlockStart
- type MessagesStreamBlockStop
- type MessagesStreamMessageDelta
- type MessagesStreamMessageStart
- type MessagesStreamMessageStop
- type Metadata
- type TokenCounter
Constants ¶
This section is empty.
Variables ¶
View Source
var AnthropicPerMillionTokenCost = map[string]map[string]float64{
"prompt": {
"claude-instant": 0.8,
"claude": 8,
"claude-3-opus": 15,
"claude-3-sonnet": 3,
"claude-3.5-sonnet": 3,
"claude-3-haiku": 0.25,
},
"completion": {
"claude-instant": 2.4,
"claude": 24,
"claude-3-opus": 75,
"claude-3-sonnet": 15,
"claude-3.5-sonnet": 15,
"claude-3-haiku": 1.25,
},
}
Functions ¶
This section is empty.
Types ¶
type CompletionRequest ¶
type CompletionRequest struct {
Model string `json:"model"`
Prompt string `json:"prompt"`
MaxTokensToSample int `json:"max_tokens_to_sample"`
StopSequences []string `json:"stop_sequences,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP int `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Stream bool `json:"stream,omitempty"`
}
type CompletionResponse ¶
type CostEstimator ¶
type CostEstimator struct {
// contains filtered or unexported fields
}
func NewCostEstimator ¶
func NewCostEstimator(tc tokenCounter) *CostEstimator
func (*CostEstimator) Count ¶
func (ce *CostEstimator) Count(input string) int
func (*CostEstimator) CountMessagesTokens ¶ added in v1.14.0
func (ce *CostEstimator) CountMessagesTokens(messages []Message) int
func (*CostEstimator) EstimateCompletionCost ¶
func (ce *CostEstimator) EstimateCompletionCost(model string, tks int) (float64, error)
func (*CostEstimator) EstimatePromptCost ¶
func (ce *CostEstimator) EstimatePromptCost(model string, tks int) (float64, error)
func (*CostEstimator) EstimateTotalCost ¶
func (ce *CostEstimator) EstimateTotalCost(model string, promptTks, completionTks int) (float64, error)
type ErrorResponse ¶
type ErrorResponse struct {
Error *Error `json:"error"`
}
type MessageResponseContent ¶ added in v1.14.0
type MessagesRequest ¶ added in v1.14.0
type MessagesRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"max_tokens"`
StopSequences []string `json:"stop_sequences,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP int `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Stream bool `json:"stream,omitempty"`
}
type MessagesResponse ¶ added in v1.14.0
type MessagesResponse struct {
Id string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []MessageResponseContent `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason"`
StopSequence string `json:"stop_sequence,omitempty"`
Usage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
}
type MessagesStreamBlockDelta ¶ added in v1.14.0
type MessagesStreamBlockDelta struct {
Index int `json:"index"`
Delta MessageResponseContent `json:"delta"`
}
type MessagesStreamBlockStart ¶ added in v1.14.0
type MessagesStreamBlockStart struct {
Index int `json:"index"`
ContentBlock MessageResponseContent `json:"content_block"`
}
type MessagesStreamBlockStop ¶ added in v1.14.0
type MessagesStreamBlockStop struct {
Index int `json:"index"`
}
type MessagesStreamMessageDelta ¶ added in v1.14.0
type MessagesStreamMessageStart ¶ added in v1.14.0
type MessagesStreamMessageStart struct {
Message MessagesResponse `json:"message"`
}
type MessagesStreamMessageStop ¶ added in v1.14.0
type MessagesStreamMessageStop struct {
Type string `json:"type"`
}
type TokenCounter ¶
type TokenCounter struct {
// contains filtered or unexported fields
}
func NewTokenCounter ¶
func NewTokenCounter() (*TokenCounter, error)
func (*TokenCounter) Count ¶
func (tc *TokenCounter) Count(input string) int
Click to show internal directories.
Click to hide internal directories.