provider

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownProvider   = errors.New("provider: unknown provider")
	ErrUnauthorized      = errors.New("provider: unauthorized (check API key)")
	ErrRateLimit         = errors.New("provider: rate limit exceeded")
	ErrContextTooLong    = errors.New("provider: input exceeds model context window")
	ErrModelNotSupported = errors.New("provider: model not supported by this provider")
	ErrTimeout           = errors.New("provider: request timed out")
)

Functions

func Names

func Names() []string

func Register

func Register(name string, factory Factory)

Register installs a provider factory under the given name. Intended to be called from package init() functions of provider subpackages. Panics on duplicate registration to surface programmer errors at startup rather than silently overriding.

Types

type Factory

type Factory func(cfg config.ProviderConfig) (Provider, error)

type PlainTextEmitter added in v0.9.0

type PlainTextEmitter interface {
	Provider
	EmitsPlainText()
}

PlainTextEmitter is the marker interface for providers whose Review() returns formatted plain text instead of the structured findings JSON the API providers contract. The review pipeline uses this to short-circuit JSON parsing, retry-once, and the cards/markdown renderer — the response is emitted to stdout verbatim because the CLI tool has already formatted it.

CLI-based providers (claude-cli, gemini-cli, codex-cli) implement this so they can pass through their host CLI's output without the JSON-contract enforcement that API providers do via native structured-output mechanisms (tool_use / response_format / response_schema).

type Pricing

type Pricing struct {
	InputPer1M  float64
	OutputPer1M float64

	// CachedInputPer1M is the per-1M-token price for cached input tokens.
	// Zero means "same as InputPer1M" (no cache discount or not supported).
	CachedInputPer1M float64
}

func (Pricing) Cost

func (p Pricing) Cost(u Usage) float64

type Provider

type Provider interface {
	Name() string

	DefaultModel() string

	ContextWindow(model string) int

	EstimateTokens(text string) int

	Pricing(model string) Pricing

	Review(ctx context.Context, req Request) (Response, error)

	TestConnection(ctx context.Context) error
}

func New

func New(name string, cfg config.ProviderConfig) (Provider, error)

type Request

type Request struct {
	Model        string
	SystemPrompt string
	UserPrompt   string
	Lang         string
	MaxTokens    int

	// ProviderOpts is an escape hatch (ADR-0001 risk #1) for features that
	// don't fit the common interface, e.g. Anthropic prompt caching or
	// OpenAI logprobs. Providers cast to their expected type; unknown values
	// are ignored.
	ProviderOpts any
}

type Response

type Response struct {
	Content string
	Model   string
	Usage   Usage
}

type Usage

type Usage struct {
	InputTokens  int
	OutputTokens int

	// CachedInputTokens is the subset of InputTokens served from a provider-
	// side prompt cache (Anthropic ephemeral cache, OpenAI cached completions).
	// Zero if unknown or unsupported.
	CachedInputTokens int
}

Directories

Path Synopsis
Package claudecli registers a CLI-tool-backed provider that drives Anthropic's Claude Code (`claude`) binary as the review engine.
Package claudecli registers a CLI-tool-backed provider that drives Anthropic's Claude Code (`claude`) binary as the review engine.
Package clireview is the shared implementation of CLI-tool-backed review providers.
Package clireview is the shared implementation of CLI-tool-backed review providers.
Package geminicli registers a CLI-tool-backed provider that drives Google's Gemini CLI (`gemini`) binary as the review engine.
Package geminicli registers a CLI-tool-backed provider that drives Google's Gemini CLI (`gemini`) binary as the review engine.

Jump to

Keyboard shortcuts

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