provider

package
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package provider resolves an LLM backend: the server's providers for a worker (Session, Judge), and one Anthropic-format endpoint from the environment for the local `whetstone` CLI (Resolve).

Index

Constants

View Source
const (
	APIKeyEnv    = "ANTHROPIC_API_KEY"
	AuthTokenEnv = "ANTHROPIC_AUTH_TOKEN"
	BaseURLEnv   = "ANTHROPIC_BASE_URL"
	// ModelEnv is comma-separated, most capable first: the first entry serves
	// every judge call and the panel's primary member, the rest are the panel's
	// floor members. One list rather than a strong/fast pair, which could be
	// half-set — a panel with one working member and one that 404s is not an
	// error but a complete run that scores and can never release anything.
	ModelEnv = "LLM_MODEL"
)

Variables

This section is empty.

Functions

func Judge added in v0.19.0

Judge builds the judge's gateway from one of the server's providers. An Anthropic provider speaks Messages; every other type speaks Chat Completions.

func Session added in v0.20.0

Session maps one of the server's providers and a model onto what a panel session needs.

Types

type Config

type Config struct {
	Kind   Kind
	Detail string
	// BaseURL is the panel's gateway as much as the judge's. Empty is
	// Anthropic's own API.
	BaseURL string
	Key     string
	// AuthStyle is inferred from which credential was set rather than
	// configured: a bearer token is only ever presented as a bearer token.
	AuthStyle api.AuthStyle
	// Models is ModelEnv, split and trimmed. Empty means the shipped defaults.
	Models []string
}

Config is data only: nothing dials anything until Gateway is called.

func FromEnv

func FromEnv() Config

func Resolve

func Resolve(env Getenv) Config

func (Config) Gateway

func (c Config) Gateway(o Options) (llm.Gateway, error)

Gateway builds the resolved backend.

func (Config) Member added in v0.20.0

func (c Config) Member(model string) agent.Backend

Member is one panel model on the judge's endpoint and key.

func (Config) PanelModels

func (c Config) PanelModels() []string

PanelModels is what the panel asks for, empty for the shipped default. A model named only to cheapen the judge on Anthropic's API keeps the panel.

func (Config) Validate

func (c Config) Validate() error

Validate reports a configuration that cannot serve a call. `whetstone doctor` and the worker's startup both report what this returns.

func (Config) Warnings

func (c Config) Warnings() []string

Warnings reports configurations that work often enough not to refuse, and break confusingly when they do.

type Getenv

type Getenv func(string) string

Getenv is os.Getenv, injectable so resolution is testable.

type Kind

type Kind string

Kind names the backend serving model calls.

const (
	KindAPI  Kind = "api"
	KindNone Kind = "none"
)

type Options

type Options struct {
	Cache      llm.Cache
	Timeout    time.Duration
	MaxRetries int
}

Options are per-caller settings that are not provider choices: whetstone allows a long timeout and shares a completion cache, the worker does neither.

Jump to

Keyboard shortcuts

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