Documentation
¶
Index ¶
- func ValidateRequest(request EstimateRequest) error
- func WithEstimator(ctx context.Context, estimator Estimator) context.Context
- type Budget
- type Estimate
- type EstimateRequest
- type Estimator
- type InputImage
- type InputPart
- type InputPartType
- type Message
- type Source
- type TiktokenEstimator
- type ToolCall
- type ToolSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRequest ¶
func ValidateRequest(request EstimateRequest) error
Types ¶
type Estimate ¶
type Estimate struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model"`
InputTokens int64 `json:"input_tokens"`
SystemTokens int64 `json:"system_tokens,omitempty"`
MessageTokens int64 `json:"message_tokens,omitempty"`
ToolSchemaTokens int64 `json:"tool_schema_tokens,omitempty"`
OverheadTokens int64 `json:"overhead_tokens,omitempty"`
ContextLimit int64 `json:"context_limit,omitempty"`
MaxOutputTokens int64 `json:"max_output_tokens,omitempty"`
RemainingTokens int64 `json:"remaining_tokens,omitempty"`
Source Source `json:"source"`
Estimated bool `json:"estimated"`
}
type EstimateRequest ¶
type EstimateRequest struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model"`
Messages []Message `json:"messages"`
Tools []ToolSpec `json:"tools,omitempty"`
MaxOutputTokens int64 `json:"max_output_tokens,omitempty"`
ContextLimit int64 `json:"context_limit,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
type Estimator ¶
type Estimator interface {
CountPromptTokens(context.Context, EstimateRequest) (Estimate, error)
}
type InputImage ¶
type InputPart ¶
type InputPart struct {
Type InputPartType `json:"type"`
Text string `json:"text,omitempty"`
Image *InputImage `json:"image,omitempty"`
}
type InputPartType ¶
type InputPartType string
const ( InputPartText InputPartType = "input_text" InputPartImage InputPartType = "input_image" )
type TiktokenEstimator ¶
type TiktokenEstimator struct {
Encoding string
}
func NewTiktokenEstimator ¶
func NewTiktokenEstimator() TiktokenEstimator
func (TiktokenEstimator) CountPromptTokens ¶
func (e TiktokenEstimator) CountPromptTokens(_ context.Context, request EstimateRequest) (Estimate, error)
Click to show internal directories.
Click to hide internal directories.