llm

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package llm provides LLM provider integration using the iris SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogProviderError added in v1.0.0

func LogProviderError(ctx context.Context, operation string, err error)

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 NewClient

func NewClient(provider core.Provider, opts ...core.ClientOption) *core.Client

NewClient creates an iris client from a provider.

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

func NewProvider(providerType string) (core.Provider, error)

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)

Types

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL