provider

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package provider defines the Provider interface, the contract between the core loop and concrete LLM provider adapters.

The provider contract is intentionally minimal: a single Invoke() method that streams artifacts on the supplied channel in the exact order they are received from the underlying LLM API. Adapters must emit canonical ore artifact types (including delta types such as TextDelta, ToolCallDelta, and ReasoningDelta) immediately; the core loop accumulates them into complete artifacts. Adapters should not perform their own accumulation except when the native format genuinely cannot be expressed as an ore artifact type.

See the Provider interface in provider.go for the full contract and the artifact package for the list of canonical types.

Package provider defines the Provider interface, the contract between the core loop and concrete LLM provider adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InvokeOption

type InvokeOption interface {
	IsInvokeOption()
}

InvokeOption is a marker interface for per-invocation configuration options. Concrete provider sub-packages define their own option types and exported constructors (e.g. openai.WithTools). Providers silently ignore options they do not recognize.

func WithTools

func WithTools(tools []tool.Tool) InvokeOption

WithTools returns an InvokeOption that configures the set of available tools for a single provider invocation. It is a convenience wrapper for the common case where the tool set is static; it creates a ToolsOption whose Tools function simply returns the provided slice, ignoring the request context and state.

type Provider

type Provider interface {
	// Invoke serializes the given state, calls the LLM API, and emits
	// deserialized response artifacts to the provided channel.
	//
	// The adapter must emit each artifact as soon as the native API delivers a
	// chunk, preserving that arrival order.
	//
	// Adapters must emit canonical ore artifact types as soon as the native
	// API delivers a chunk, preserving that arrival order. Fragmented data
	// (e.g. streaming text or tool-call chunks) is emitted as delta types
	// (TextDelta, ToolCallDelta, etc.) and accumulated by the core loop.
	// Adapters should not perform their own accumulation except when the
	// native format genuinely cannot be expressed as an ore artifact type.
	//
	// The channel must not be closed by the adapter.
	Invoke(ctx context.Context, s state.State, ch chan<- artifact.Artifact, opts ...InvokeOption) error
}

Provider is the interface implemented by LLM provider adapters.

type ToolsOption

type ToolsOption struct {
	// Tools returns the slice of tools available for the current invocation.
	// The function receives the request context and the current state, enabling
	// per-turn dynamic selection of tools. Returning nil is equivalent to an
	// empty tool list (no tools are offered to the provider).
	Tools func(ctx context.Context, st state.State) []tool.Tool
}

ToolsOption is a per-invocation option that configures available tools. The Tools field is a function so the tool list can be resolved dynamically based on the current context and conversation state (e.g. filtering by permissions, user role, or runtime discovery).

func (ToolsOption) IsInvokeOption

func (ToolsOption) IsInvokeOption()

IsInvokeOption marks ToolsOption as a provider.InvokeOption.

Jump to

Keyboard shortcuts

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