llm

package
v0.1.62 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyCompletion = errors.New("provider returned no assistant content or tool calls")

ErrEmptyCompletion marks a terminal completion that carried no assistant content and no tool calls (e.g. a reasoning-only response). Providers wrap their terminal-empty errors with this so callers can recognize the case without depending on provider-internal error types.

Functions

This section is empty.

Types

type EventType

type EventType string
const (
	EventContentDelta   EventType = "content_delta"
	EventReasoningDelta EventType = "reasoning_delta"
	EventToolArgsDelta  EventType = "tool_args_delta"
	EventToolUseStart   EventType = "tool_use_start"
	EventToolUseStop    EventType = "tool_use_stop"
	EventRetryScheduled EventType = "retry_scheduled"
	EventComplete       EventType = "complete"
	EventError          EventType = "error"
)

type PrefixCompletionProvider added in v0.1.35

type PrefixCompletionProvider interface {
	StreamResponseWithPrefix(ctx context.Context, history []core.Message, prefix string, stop []string) <-chan ProviderEvent
}

type Provider

type Provider interface {
	StreamResponse(ctx context.Context, history []core.Message, tools []core.Tool) <-chan ProviderEvent
}

type ProviderEvent

type ProviderEvent struct {
	Type           EventType
	Content        string
	ReasoningDelta string
	ToolArgsDelta  *ToolArgsDelta
	ToolCall       *core.ToolCall
	Retry          *llmretry.Info
	Response       *ProviderResponse
	Err            error
}

type ProviderResponse

type ProviderResponse struct {
	Content      string
	Reasoning    string
	ToolCalls    []core.ToolCall
	Usage        Usage
	Model        string
	FinishReason core.FinishReason
}

type ToolArgsDelta

type ToolArgsDelta struct {
	ToolCallIndex int
	ToolName      string
	ArgsDelta     string
	ArgsChars     int
	ReadyCount    int
}

type Usage

type Usage struct {
	PromptTokens             int
	CompletionTokens         int
	TotalTokens              int
	PromptCacheHitTokens     int
	PromptCacheMissTokens    int
	PrefixCompletionRequests int
	ReasoningReplayTokens    int
	ToolResultRawChars       int
	ToolResultReplayChars    int
	ToolResultRawTokens      int
	ToolResultReplayTokens   int
	ToolResultTokensSaved    int
	ToolResultsCompacted     int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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