Documentation
¶
Overview ¶
Package llm defines the provider-agnostic types and the Client interface every LLM provider satisfies.
The shapes here are deliberately the lowest common denominator across providers. Provider-specific knobs live on each provider's Options struct.
See docs/v1/API.md for the rationale behind every type.
Index ¶
- Variables
- func Collect(ctx context.Context, c Client, req Request) (text string, calls []ToolCall, images []ImagePart, usage *Usage, err error)
- func Float32(v float32) *float32
- type CacheBreakpoint
- type CacheTTL
- type Client
- type Event
- type EventKind
- type ImagePart
- type Message
- type Request
- type Role
- type ThinkingConfig
- type ThinkingEffort
- type ToolCall
- type ToolDef
- type Usage
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuth = errors.New("aikido/llm: authentication failed") ErrRateLimited = errors.New("aikido/llm: rate limited") ErrServerError = errors.New("aikido/llm: provider server error") ErrInvalidRequest = errors.New("aikido/llm: invalid request") )
Errors providers wrap with %w when mapping HTTP status to a typed cause.
Functions ¶
func Collect ¶
func Collect(ctx context.Context, c Client, req Request) (text string, calls []ToolCall, images []ImagePart, usage *Usage, err error)
Collect drains a stream into a final result. Useful for non-streaming callers.
Returns text accumulated from EventTextDelta, all complete tool calls, all images surfaced by the provider, final Usage if the provider emitted one, and the first error encountered. Thinking text is not included in the returned text.
Collect respects ctx cancellation: if ctx is cancelled before the stream closes, Collect returns ctx.Err() without waiting for the producer.
Types ¶
type CacheBreakpoint ¶
type CacheBreakpoint struct {
TTL CacheTTL
}
CacheBreakpoint marks a message as a cache breakpoint on providers that support it. nil = no breakpoint. &CacheBreakpoint{} = default 5m TTL.
type Event ¶
type Event struct {
Kind EventKind
Text string
Tool *ToolCall
Image *ImagePart
Usage *Usage
Err error
}
Event is one streaming event emitted by a Client. Channel closes after EventEnd.
type ImagePart ¶
ImagePart is one image attached to a message or returned by an image-capable model. URL is set when the provider returned a remote URL or when the caller supplied a data URI / remote URL on input. Data is set when the provider returned inline bytes (decoded from a data: URI) or when the caller wants to inline an image on output. ContentType is the MIME type when known ("image/png", "image/jpeg", ...) — empty when not provided by the wire.
type ThinkingConfig ¶
type ThinkingConfig struct {
// contains filtered or unexported fields
}
ThinkingConfig configures provider-side thinking. Use ThinkingByEffort or ThinkingByBudget — the unexported fields prevent setting both.
func ThinkingByBudget ¶
func ThinkingByBudget(n int) *ThinkingConfig
func ThinkingByEffort ¶
func ThinkingByEffort(e ThinkingEffort) *ThinkingConfig
func (*ThinkingConfig) Budget ¶
func (t *ThinkingConfig) Budget() int
Budget returns the configured token budget, 0 if effort-based.
func (*ThinkingConfig) Effort ¶
func (t *ThinkingConfig) Effort() ThinkingEffort
Effort returns the configured coarse effort, empty string if budget-based.
type ThinkingEffort ¶
type ThinkingEffort string
const ( ThinkingEffortLow ThinkingEffort = "low" ThinkingEffortMedium ThinkingEffort = "medium" ThinkingEffortHigh ThinkingEffort = "high" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package llmtest provides public test helpers for the llm package.
|
Package llmtest provides public test helpers for the llm package. |
|
Package openrouter implements llm.Client against OpenRouter (https://openrouter.ai).
|
Package openrouter implements llm.Client against OpenRouter (https://openrouter.ai). |