llm

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxTokens = 1024

DefaultMaxTokens is used when MaxTokens is 0 and the provider requires it (e.g. Anthropic).

Variables

This section is empty.

Functions

This section is empty.

Types

type LLMConfig

type LLMConfig struct {
	APIKey   string
	Model    string
	BaseURL  string
	Logger   logger.Logger
	LogLevel string
	// PromptCaching is Anthropic-only; nil means disabled. Set via WithPromptCaching.
	PromptCaching *bool
}

func BuildConfig

func BuildConfig(opts ...Option) (*LLMConfig, error)

BuildConfig builds LLMConfig from options, requiring a non-empty APIKey. For keyless/local providers use BuildConfigKeyless. Defaults when not set:

  • LogLevel: "error"
  • Logger: stderr slog logger at LogLevel

Sampling (Temperature, MaxTokens, TopP, TopK) is per-agent—use agent.WithTemperature etc.

func BuildConfigKeyless added in v0.2.6

func BuildConfigKeyless(opts ...Option) (*LLMConfig, error)

BuildConfigKeyless builds LLMConfig from options without requiring an APIKey. It is for keyless/local providers (e.g. Ollama) whose transport ignores auth. Defaults when not set:

  • LogLevel: "error"
  • Logger: stderr slog logger at LogLevel

Sampling (Temperature, MaxTokens, TopP, TopK) is per-agent—use agent.WithTemperature etc.

type Option

type Option func(*LLMConfig)

func WithAPIKey

func WithAPIKey(apiKey string) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithLogLevel

func WithLogLevel(level string) Option

func WithLogger

func WithLogger(l logger.Logger) Option

func WithModel

func WithModel(model string) Option

func WithPromptCaching added in v0.2.6

func WithPromptCaching(enabled bool) Option

WithPromptCaching enables or disables Anthropic prompt-cache breakpoints. Default when unset is disabled (write cost / short TTL are a poor fit at low volume). OpenAI/Gemini/DeepSeek ignore this option.

Directories

Path Synopsis
Package deepseek provides an interfaces.LLMClient for DeepSeek.
Package deepseek provides an interfaces.LLMClient for DeepSeek.
Package ollama provides an interfaces.LLMClient for Ollama, covering both a local daemon and Ollama Cloud (ollama.com).
Package ollama provides an interfaces.LLMClient for Ollama, covering both a local daemon and Ollama Cloud (ollama.com).

Jump to

Keyboard shortcuts

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