Documentation
¶
Index ¶
- Constants
- type AnthropicModelProfile
- type AnthropicProvider
- type Capability
- type Condenser
- type CondenserResult
- type ContentBlock
- type ContentBlockType
- type GeminiModelProfile
- type GeminiProvider
- type InvokeModelOption
- func WithModelProfile(profile ModelProfile) InvokeModelOption
- func WithRetryCallback(handler func(ctx context.Context, err error, nextRetry time.Duration)) InvokeModelOption
- func WithStreamHandler(handler func(ctx context.Context, chunk string)) InvokeModelOption
- func WithTools(tools ...native.Tool) InvokeModelOption
- type InvokeModelOptions
- type Message
- type MessageSource
- type Model
- func DefaultAnthropicModel() *Model
- func DefaultGeminiModel() *Model
- func DefaultModel(provider ProviderKind) (*Model, error)
- func SupportedAnthropicModels() []Model
- func SupportedGeminiModels() []Model
- func SupportedModels(provider ProviderKind) []Model
- func SupportedOpenAIModels() []Model
- func SupportedXAIModels() []Model
- type ModelPricing
- type ModelProfile
- type ModelProvider
- type OpenAICompletionProvider
- type OpenAIModelProfile
- type ProviderError
- type ProviderErrorKind
- type ProviderKind
- type ProviderOption
- type ProviderOptions
- type SummarizationCondenser
- type TextBlock
- type ToolCallBlock
- type ToolResultBlock
- type TruncationCondenser
- type Usage
Constants ¶
View Source
const ( AnthropicBudgetModel = "claude-haiku-4-5-20251001" AnthropicDefaultModel = "claude-sonnet-4-5-20250929" AnthropicPlanModel = "claude-opus-4-5-20251101" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnthropicModelProfile ¶
type AnthropicModelProfile struct {
AnthropicVersion string `json:"anthropic_version,omitempty"`
AnthropicBeta []string `json:"anthropic_beta,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int64 `json:"max_tokens,omitempty"`
DefaultTopP float32 `json:"default_top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
EnablePromptCaching bool `json:"enable_prompt_caching,omitempty"`
EnableThinkingMode bool `json:"enable_thinking_mode,omitempty"`
EnableAnalysisMode bool `json:"enable_analysis_mode,omitempty"`
EnableComputerUse bool `json:"enable_computer_use,omitempty"`
}
func (*AnthropicModelProfile) Kind ¶
func (c *AnthropicModelProfile) Kind() ProviderKind
func (*AnthropicModelProfile) Validate ¶
func (c *AnthropicModelProfile) Validate() error
type AnthropicProvider ¶
type AnthropicProvider struct {
// contains filtered or unexported fields
}
func NewAnthropicProvider ¶
func NewAnthropicProvider(apiKey string, opts ...ProviderOption) (*AnthropicProvider, error)
func (*AnthropicProvider) GetXAIModel ¶
func (*AnthropicProvider) InvokeModel ¶
func (p *AnthropicProvider) InvokeModel(ctx context.Context, model, systemPrompt string, messages []*Message, opts ...InvokeModelOption) (*Message, error)
type Capability ¶
type Capability string
const ( CapabilityImage Capability = "image" CapabilityAudio Capability = "audio" CapabilityComputerUse Capability = "computer_use" CapabilityPromptCache Capability = "prompt_cache" CapabilityExtendedThinking Capability = "extended_thinking" )
type Condenser ¶
type Condenser interface {
Condense(ctx context.Context, messages []*Message) (*CondenserResult, error)
}
type CondenserResult ¶
type ContentBlock ¶
type ContentBlock interface {
Type() ContentBlockType
}
type ContentBlockType ¶
type ContentBlockType string
const ( ContentBlockTypeText ContentBlockType = "text" ContentBlockTypeToolRequest ContentBlockType = "tool_request" ContentBlockTypeToolResult ContentBlockType = "tool_result" )
type GeminiModelProfile ¶
type GeminiModelProfile struct {
// API configuration
APIKey string `json:"api_key,omitempty"`
BaseURL string `json:"base_url,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
// Default model parameters
DefaultTemperature *float64 `json:"default_temperature,omitempty"`
DefaultMaxTokens *int32 `json:"default_max_tokens,omitempty"`
DefaultTopP *float32 `json:"default_top_p,omitempty"`
DefaultTopK *int32 `json:"default_top_k,omitempty"`
}
func (*GeminiModelProfile) Kind ¶
func (g *GeminiModelProfile) Kind() ProviderKind
func (*GeminiModelProfile) Validate ¶
func (g *GeminiModelProfile) Validate() error
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
func NewGeminiProvider ¶
func NewGeminiProvider(apiKey string) (*GeminiProvider, error)
func (*GeminiProvider) InvokeModel ¶
func (p *GeminiProvider) InvokeModel(ctx context.Context, model, systemPrompt string, messages []*Message, opts ...InvokeModelOption) (*Message, error)
type InvokeModelOption ¶
type InvokeModelOption func(*InvokeModelOptions)
func WithModelProfile ¶
func WithModelProfile(profile ModelProfile) InvokeModelOption
func WithRetryCallback ¶
func WithStreamHandler ¶
func WithStreamHandler(handler func(ctx context.Context, chunk string)) InvokeModelOption
func WithTools ¶
func WithTools(tools ...native.Tool) InvokeModelOption
type InvokeModelOptions ¶
type InvokeModelOptions struct {
Tools []native.Tool
StreamCallback func(ctx context.Context, chunk string)
RetryCallback func(ctx context.Context, err error, nextRetry time.Duration)
ModelProfile ModelProfile
}
func DefaultOpenAIModelOptions ¶
func DefaultOpenAIModelOptions() *InvokeModelOptions
type Message ¶
type Message struct {
Source MessageSource `json:"source"`
Content []ContentBlock `json:"content"`
Usage Usage `json:"usage"`
}
func NewModelMessage ¶
func NewModelMessage(content []ContentBlock, usage Usage) *Message
type MessageSource ¶
type MessageSource string
const ( MessageSourceUser MessageSource = "user" MessageSourceModel MessageSource = "model" MessageSourceSystem MessageSource = "system" )
type Model ¶
type Model struct {
ID uuid.UUID
Provider ProviderKind
Name string
Capabilities []Capability
ContextWindow int64
Pricing ModelPricing
}
func DefaultAnthropicModel ¶
func DefaultAnthropicModel() *Model
func DefaultGeminiModel ¶
func DefaultGeminiModel() *Model
func DefaultModel ¶
func DefaultModel(provider ProviderKind) (*Model, error)
func SupportedAnthropicModels ¶
func SupportedAnthropicModels() []Model
func SupportedGeminiModels ¶
func SupportedGeminiModels() []Model
func SupportedModels ¶
func SupportedModels(provider ProviderKind) []Model
func SupportedOpenAIModels ¶
func SupportedOpenAIModels() []Model
func SupportedXAIModels ¶
func SupportedXAIModels() []Model
type ModelPricing ¶
type ModelProfile ¶
type ModelProfile interface {
Validate() error
Kind() ProviderKind
}
type ModelProvider ¶
type OpenAICompletionProvider ¶
type OpenAICompletionProvider struct {
// contains filtered or unexported fields
}
func NewOpenAICompletionProvider ¶
func NewOpenAICompletionProvider(apiKey string, opts ...ProviderOption) (*OpenAICompletionProvider, error)
func (*OpenAICompletionProvider) InvokeModel ¶
func (p *OpenAICompletionProvider) InvokeModel(ctx context.Context, model, systemPrompt string, messages []*Message, opts ...InvokeModelOption) (*Message, error)
type OpenAIModelProfile ¶
type OpenAIModelProfile struct {
// API Configuration
APIURL string `json:"api_url,omitempty"`
Organization string `json:"organization,omitempty"`
APIVersion string `json:"api_version,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
// Default Model Parameters
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int64 `json:"max_tokens,omitempty"`
TopP float32 `json:"top_p,omitempty"`
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
PresencePenalty float32 `json:"presence_penalty,omitempty"`
// Feature Flags
EnableJSONMode bool `json:"enable_json_mode,omitempty"`
EnableFunctionCalling bool `json:"enable_function_calling,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
EnableVision bool `json:"enable_vision,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
// Rate Limiting
RequestsPerMinute int `json:"requests_per_minute,omitempty"`
TokensPerMinute int `json:"tokens_per_minute,omitempty"`
}
func (*OpenAIModelProfile) Kind ¶
func (c *OpenAIModelProfile) Kind() ProviderKind
func (*OpenAIModelProfile) Validate ¶
func (c *OpenAIModelProfile) Validate() error
type ProviderError ¶
type ProviderError struct {
Provider string
RetryAfter time.Duration
Err error
Kind ProviderErrorKind
}
func NewAnthropicProviderError ¶
func NewAnthropicProviderError(kind ProviderErrorKind, err error) *ProviderError
func NewProviderError ¶
func NewProviderError(provider string, kind ProviderErrorKind, err error) *ProviderError
func (*ProviderError) Error ¶
func (pe *ProviderError) Error() string
func (*ProviderError) Message ¶
func (pe *ProviderError) Message() string
func (*ProviderError) Unwrap ¶
func (pe *ProviderError) Unwrap() error
type ProviderErrorKind ¶
type ProviderErrorKind string
const ( ProviderErrorKindInvalidRequest ProviderErrorKind = "invalid_request" ProviderErrorKindRateLimitExceeded ProviderErrorKind = "rate_limit_exceeded" ProviderErrorKindOverloaded ProviderErrorKind = "overloaded" ProviderErrorKindInternal ProviderErrorKind = "internal" ProviderErrorKindTimeout ProviderErrorKind = "timeout" ProviderErrorKindCanceled ProviderErrorKind = "canceled" ProviderErrorKindUnknown ProviderErrorKind = "unknown" )
type ProviderKind ¶
type ProviderKind string
const ( ProviderKindAnthropic ProviderKind = "anthropic" ProviderKindOpenAI ProviderKind = "openai" ProviderKindDeepSeek ProviderKind = "deepseek" ProviderKindGemini ProviderKind = "gemini" ProviderKindXAI ProviderKind = "xai" ProviderKindBedrock ProviderKind = "bedrock" )
type ProviderOption ¶
type ProviderOption func(*ProviderOptions)
func WithCircuitBreaker ¶
func WithCircuitBreaker(circuitBreaker *resilience.CircuitBreaker) ProviderOption
func WithMetrics ¶
func WithMetrics(metrics *prometheus.Registry) ProviderOption
func WithRetryConfig ¶
func WithRetryConfig(retryConfig *resilience.RetryConfig) ProviderOption
func WithURL ¶
func WithURL(url string) ProviderOption
type ProviderOptions ¶
type ProviderOptions struct {
URL string
RetryConfig *resilience.RetryConfig
CircuitBreaker *resilience.CircuitBreaker
Metrics *prometheus.Registry
}
func DefaultProviderOptions ¶
func DefaultProviderOptions(name string) *ProviderOptions
type SummarizationCondenser ¶
type SummarizationCondenser struct {
// contains filtered or unexported fields
}
func NewSummarizationCondenser ¶
func NewSummarizationCondenser(modelProvider ModelProvider) *SummarizationCondenser
type TextBlock ¶
type TextBlock struct {
Text string
}
func (*TextBlock) Type ¶
func (t *TextBlock) Type() ContentBlockType
type ToolCallBlock ¶
type ToolCallBlock struct {
ID string `json:"id"`
Tool string `json:"tool"`
Args json.RawMessage `json:"args"`
}
func (*ToolCallBlock) Type ¶
func (t *ToolCallBlock) Type() ContentBlockType
type ToolResultBlock ¶
type ToolResultBlock struct {
ID string `json:"id"`
Name string `json:"name"`
Result string `json:"result"`
Succeeded bool `json:"succeeded"`
}
func (*ToolResultBlock) Type ¶
func (t *ToolResultBlock) Type() ContentBlockType
type TruncationCondenser ¶
type TruncationCondenser struct {
// Maximum context window size
ContextWindow int64
// Percentage of context window to trigger truncation (e.g., 0.8 for 80%)
TruncationRatio float64
// Number of messages to preserve at the beginning and end
PreserveCount int
// Maximum percentage of messages to remove in one truncation
MaxRemovalPercent float64
}
TruncationCondenser removes messages from the middle of the conversation when the context window is approaching its limit
func NewTruncationCondenser ¶
func NewTruncationCondenser(contextWindow int64) *TruncationCondenser
NewTruncationCondenser creates a new TruncationCondenser with sensible defaults
func (*TruncationCondenser) Condense ¶
func (c *TruncationCondenser) Condense(ctx context.Context, messages []*Message) (*CondenserResult, error)
Click to show internal directories.
Click to hide internal directories.