Documentation
¶
Overview ¶
Code generated by enum generator; DO NOT EDIT.
Index ¶
- Constants
- Variables
- func ProviderTypeIter() func(yield func(ProviderType) bool)
- type Anthropic
- type CustomOpenAI
- type CustomOptions
- type EndpointType
- type Google
- type HTTPClient
- type OpenAI
- type Options
- type Provider
- func CreateProvider(providerType ProviderType, opts Options) (Provider, error)
- func FindProviderByName(name string, providers []Provider) Provider
- func NewRetryableProvider(p Provider, opts RetryOptions) Provider
- func WrapProviderWithRetry(p Provider, opts RetryOptions) Provider
- func WrapProvidersWithRetry(providers []Provider, opts RetryOptions) []Provider
- type ProviderType
- type Reasoning
- type Result
- type RetryOptions
- type RetryableProvider
Constants ¶
const DefaultMaxTokens = 1024
DefaultMaxTokens defines the default value for max tokens if not specified or negative
const DefaultTemperature = 0.7
DefaultTemperature defines the default temperature if not specified or negative
Variables ¶
var ( ProviderTypeUnknown = ProviderType{/* contains filtered or unexported fields */} ProviderTypeOpenAI = ProviderType{/* contains filtered or unexported fields */} ProviderTypeAnthropic = ProviderType{/* contains filtered or unexported fields */} ProviderTypeGoogle = ProviderType{/* contains filtered or unexported fields */} ProviderTypeCustom = ProviderType{/* contains filtered or unexported fields */} )
Public constants for providerType values
var ProviderTypeNames = []string{
"unknown",
"openai",
"anthropic",
"google",
"custom",
}
ProviderTypeNames contains all possible enum names
var ProviderTypeValues = []ProviderType{ ProviderTypeUnknown, ProviderTypeOpenAI, ProviderTypeAnthropic, ProviderTypeGoogle, ProviderTypeCustom, }
ProviderTypeValues contains all possible enum values
Functions ¶
func ProviderTypeIter ¶ added in v0.12.0
func ProviderTypeIter() func(yield func(ProviderType) bool)
ProviderTypeIter returns a function compatible with Go 1.23's range-over-func syntax. It yields all ProviderType values in declaration order. Example:
for v := range ProviderTypeIter() {
// use v
}
Types ¶
type Anthropic ¶
type Anthropic struct {
// contains filtered or unexported fields
}
Anthropic implements Provider interface for Anthropic
func NewAnthropic ¶
NewAnthropic creates a new Anthropic provider
type CustomOpenAI ¶
type CustomOpenAI struct {
// contains filtered or unexported fields
}
CustomOpenAI implements Provider interface for OpenAI-compatible providers it wraps the OpenAI provider with custom base URL and name
func NewCustomOpenAI ¶
func NewCustomOpenAI(opts CustomOptions) *CustomOpenAI
NewCustomOpenAI creates a new custom OpenAI-compatible provider
func (*CustomOpenAI) Enabled ¶
func (c *CustomOpenAI) Enabled() bool
Enabled returns whether this provider is enabled
func (*CustomOpenAI) Generate ¶
Generate sends a prompt to the custom provider and returns the generated text
func (*CustomOpenAI) Name ¶
func (c *CustomOpenAI) Name() string
Name returns the custom provider name
type CustomOptions ¶
type CustomOptions struct {
Name string // custom provider name
BaseURL string // base URL for the API
APIKey string // API key for authentication
Model string // model name to use
Enabled bool // whether provider is enabled
MaxTokens int // maximum number of tokens to generate
Temperature float32 // controls randomness (0-1, default: 0.7)
EndpointType EndpointType // endpoint type (auto, responses, chat_completions)
HTTPClient HTTPClient // optional HTTP client for dependency injection
}
CustomOptions defines options for custom OpenAI-compatible providers
type EndpointType ¶ added in v0.14.0
type EndpointType string
EndpointType represents the API endpoint type for OpenAI-compatible providers
const ( // EndpointTypeAuto automatically selects endpoint based on model name EndpointTypeAuto EndpointType = "auto" // EndpointTypeResponses forces use of v1/responses endpoint EndpointTypeResponses EndpointType = "responses" // EndpointTypeChatCompletions forces use of v1/chat/completions endpoint EndpointTypeChatCompletions EndpointType = "chat_completions" )
type Google ¶
type Google struct {
// contains filtered or unexported fields
}
Google implements Provider interface for Google's Gemini models
type HTTPClient ¶ added in v0.14.0
HTTPClient is an interface for making HTTP requests, allows for dependency injection and testing
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
OpenAI implements Provider interface for OpenAI
type Options ¶
type Options struct {
APIKey string
Enabled bool
Model string
MaxTokens int // maximum number of tokens to generate
Temperature float32 // controls randomness (0-1, default: 0.7)
ReasoningEffort string // reasoning effort level: minimal, low, medium (default), high (OpenAI only)
HTTPClient HTTPClient // optional HTTP client for dependency injection, defaults to &http.Client{} if nil
BaseURL string // optional base URL for custom endpoints (OpenAI-compatible providers only)
ForceEndpointType EndpointType // optional manual endpoint selection (auto, responses, chat_completions)
}
Options defines common options for all providers
func (Options) Validate ¶ added in v0.4.0
func (o Options) Validate(providerType ProviderType) error
Validate checks if the provider options are valid
type Provider ¶
type Provider interface {
Name() string
Generate(ctx context.Context, prompt string) (string, error)
Enabled() bool
}
Provider defines the interface for LLM providers
func CreateProvider ¶ added in v0.3.3
func CreateProvider(providerType ProviderType, opts Options) (Provider, error)
CreateProvider creates a standard provider (OpenAI, Anthropic, Google) based on the provider type and options. It validates required fields and returns appropriate errors if validation fails.
func FindProviderByName ¶ added in v0.12.0
FindProviderByName searches for a provider by name (case-insensitive partial match) among the given providers. It returns the first enabled provider that matches. If no match is found, it returns the first enabled provider as a fallback. Returns nil if no enabled providers are available.
func NewRetryableProvider ¶ added in v0.11.0
func NewRetryableProvider(p Provider, opts RetryOptions) Provider
NewRetryableProvider creates a provider wrapper with retry logic
func WrapProviderWithRetry ¶ added in v0.11.0
func WrapProviderWithRetry(p Provider, opts RetryOptions) Provider
WrapProviderWithRetry wraps a provider with retry logic if configured
func WrapProvidersWithRetry ¶ added in v0.11.0
func WrapProvidersWithRetry(providers []Provider, opts RetryOptions) []Provider
WrapProvidersWithRetry wraps multiple providers with retry logic
type ProviderType ¶ added in v0.12.0
type ProviderType struct {
// contains filtered or unexported fields
}
ProviderType is the exported type for the enum
func MustProviderType ¶ added in v0.12.0
func MustProviderType(v string) ProviderType
MustProviderType is like ParseProviderType but panics if string is invalid
func ParseProviderType ¶ added in v0.12.0
func ParseProviderType(v string) (ProviderType, error)
ParseProviderType converts string to providerType enum value
func (ProviderType) Index ¶ added in v0.12.0
func (e ProviderType) Index() uint8
Index returns the underlying integer value
func (ProviderType) MarshalText ¶ added in v0.12.0
func (e ProviderType) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (*ProviderType) Scan ¶ added in v0.12.0
func (e *ProviderType) Scan(value any) error
Scan implements the sql.Scanner interface
func (ProviderType) String ¶ added in v0.12.0
func (e ProviderType) String() string
func (*ProviderType) UnmarshalText ¶ added in v0.12.0
func (e *ProviderType) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type Reasoning ¶ added in v0.14.3
type Reasoning struct {
Effort string `json:"effort"` // minimal, low, medium, high
}
Reasoning represents reasoning configuration for responses API
type RetryOptions ¶ added in v0.11.0
RetryOptions configures retry behavior
type RetryableProvider ¶ added in v0.11.0
type RetryableProvider struct {
// contains filtered or unexported fields
}
RetryableProvider wraps a provider with retry logic for transient failures. The wrapped provider must be safe for concurrent use if the RetryableProvider will be used concurrently. The retry logic itself is thread-safe.
func (*RetryableProvider) Enabled ¶ added in v0.11.0
func (r *RetryableProvider) Enabled() bool
Enabled returns whether this provider is enabled
func (*RetryableProvider) Generate ¶ added in v0.11.0
Generate sends a prompt to the provider with retry logic
func (*RetryableProvider) Name ¶ added in v0.11.0
func (r *RetryableProvider) Name() string
Name returns the provider name