Documentation
¶
Overview ¶
Package llm provides LLM provider integration using the iris SDK.
Index ¶
- func ChatProviders() []string
- func EmbeddingProviders() []string
- func LogProviderError(ctx context.Context, operation string, err error)
- func NewClient(provider core.Provider, opts ...core.ClientOption) *core.Client
- func NewEmbeddingProvider(providerType string) (core.EmbeddingProvider, error)
- func NewProvider(providerType string) (core.Provider, error)
- func SupportedProviders() []string
- type Capabilities
- type EmbeddingProvider
- type ErrorKind
- type ProviderType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChatProviders ¶ added in v1.1.1
func ChatProviders() []string
ChatProviders returns the providers usable for summarization and entity extraction, sorted.
func EmbeddingProviders ¶ added in v1.1.1
func EmbeddingProviders() []string
EmbeddingProviders returns the providers usable for embeddings, sorted.
func LogProviderError ¶ added in v1.0.0
LogProviderError emits a structured log line for a failed provider call, including the classification, HTTP status, provider error code, and the provider RequestID so operators can escalate with support. No-op for non-provider errors (the raw error is still returned to the caller).
func NewEmbeddingProvider ¶
func NewEmbeddingProvider(providerType string) (core.EmbeddingProvider, error)
NewEmbeddingProvider creates an iris embedding provider based on the provider type. Returns the provider cast to core.EmbeddingProvider, or an error if the provider doesn't support embeddings.
func NewProvider ¶
NewProvider creates an iris provider based on the provider type. API keys are read from standard environment variables: - openai: OPENAI_API_KEY - anthropic: ANTHROPIC_API_KEY - gemini: GEMINI_API_KEY or GOOGLE_API_KEY - voyageai: VOYAGEAI_API_KEY - ollama: no API key required (local)
func SupportedProviders ¶ added in v1.1.1
func SupportedProviders() []string
SupportedProviders returns every known provider name, sorted.
Types ¶
type Capabilities ¶ added in v1.1.1
Capabilities describes what a provider can do. Not every provider offers every feature: Anthropic and Gemini expose no embedding API through iris, and VoyageAI is embeddings-only — its Chat returns core.ErrNotSupported.
func ProviderCapabilities ¶ added in v1.1.1
func ProviderCapabilities(name string) (Capabilities, bool)
ProviderCapabilities returns what the named provider supports. The second return is false for a name that is not a known provider at all.
type EmbeddingProvider ¶
type EmbeddingProvider = core.EmbeddingProvider
EmbeddingProvider is an alias for core.EmbeddingProvider.
type ErrorKind ¶ added in v1.0.0
type ErrorKind string
ErrorKind classifies a provider failure by the operational response it demands, derived from the iris typed error taxonomy (core.ProviderError + sentinels) rather than message text.
const ( // ErrorKindUnknown means the error is not a recognized provider error; // no classification is possible. ErrorKindUnknown ErrorKind = "unknown" // ErrorKindPermanent means retrying cannot succeed — a bad API key // (401/403), a malformed request (400), or an unparsable response. // Stop, alert on configuration, and dead-letter queued work. ErrorKindPermanent ErrorKind = "permanent" // ErrorKindRateLimited means the provider returned 429: back off before // retrying, and alert if sustained. ErrorKindRateLimited ErrorKind = "rate_limited" // ErrorKindTransient means a server-side (5xx) or network failure: // safe to retry with backoff. ErrorKindTransient ErrorKind = "transient" )
func ClassifyError ¶ added in v1.0.0
func ClassifyError(err error) (ErrorKind, *core.ProviderError)
ClassifyError inspects err against the iris taxonomy and returns the operational kind plus the typed *core.ProviderError when present (nil for non-provider errors). The kind is derived from the sentinel errors (which survive %w wrapping), so bare sentinel chains classify too; the typed struct carries Status/Code/RequestID for alerting when available.
type ProviderType ¶
type ProviderType string
ProviderType identifies the LLM provider.
const ( ProviderOpenAI ProviderType = "openai" ProviderAnthropic ProviderType = "anthropic" ProviderGemini ProviderType = "gemini" ProviderOllama ProviderType = "ollama" ProviderVoyageAI ProviderType = "voyageai" )