llm

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: GPL-3.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package llm provides a unified interface for LLM inference across multiple providers (OpenAI, Anthropic, Google Vertex AI, Google Gemini, OpenRouter, AWS Bedrock).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Infer

func Infer(ctx context.Context, opts InferenceOptions) (string, error)

Infer performs a single LLM inference and returns the text result. If opts.Retries > 0, failed attempts are retried with exponential backoff.

Types

type InferenceOptions

type InferenceOptions struct {
	Provider     string // "openai", "anthropic", "vertex", "gemini", "openrouter", "bedrock"
	Model        string
	Prompt       string
	SystemPrompt string
	MaxTokens    int

	// Retry
	Retries    int           // Max retry attempts (0 = no retry)
	RetryDelay time.Duration // Initial delay between retries (doubles each attempt)
	Logger     *slog.Logger  // Logger for retry logging (optional)

	// Provider-specific
	TokenEnv string // Env var name holding the API key (openai, anthropic, gemini, openrouter)
	Project  string // GCP project ID (vertex only)
	Location string // GCP region (vertex only)
}

InferenceOptions holds the configuration for a single LLM inference call.

Jump to

Keyboard shortcuts

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