llm

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPStatusFromError

func HTTPStatusFromError(err error) int

func IsContextOverflowError

func IsContextOverflowError(err error) bool

IsContextOverflowError reports context-length failures that should use compaction instead of retry.

func IsRetryableError

func IsRetryableError(err error) bool

IsRetryableError reports whether an error looks transient and safe to retry. Context overflow and quota exhaustion are excluded.

func MustToolCall

func MustToolCall(name, args string) agentkit.ToolCall

func NewOpenAI

func NewOpenAI(cfg OpenAIConfig, deps OpenAIDeps) (agentkit.LLMProvider, error)

NewOpenAI registers llm/openai-compatible: OpenAI-compatible provider, chat or responses API.

Best practices:

  • Token budgets and compaction/token-limit need reported usage; the chat API supplies it, the responses API may not.

func NewScripted

func NewScripted(cfg ScriptedConfig) (agentkit.LLMProvider, error)

NewScripted registers llm/scripted: Deterministic canned responses. For tests and offline smoke runs.

func SleepContext

func SleepContext(ctx context.Context, delay time.Duration) error

Types

type LLMRetryConfig

type LLMRetryConfig struct {
	Provider *ProviderRetrySettings `json:"provider,omitempty"`
}

type OpenAI

type OpenAI struct {
	// contains filtered or unexported fields
}

func (*OpenAI) Name

func (p *OpenAI) Name() string

func (*OpenAI) Stream

type OpenAIConfig

type OpenAIConfig struct {
	// Model is model name.
	Model string `json:"model"`
	// BaseURL is API base URL, e.g. https://api.openai.com/v1.
	BaseURL string `json:"baseUrl"`
	// APIKey is inline key. Prefer APIKeyRef so the secret stays out of the config file.
	APIKey string `json:"apiKey"`
	// APIKeyRef is credentials reference, e.g. env:OPENAI_API_KEY.
	APIKeyRef string `json:"apiKeyRef"`
	// API is chat or responses.
	API string `json:"api"`
	// Reasoning is reasoning effort and summary settings, for models that support them.
	Reasoning *OpenAIReasoningConfig `json:"reasoning,omitempty"`
	// Retry is provider-level retry, separate from the agent's per-step retry.
	Retry *LLMRetryConfig `json:"retry,omitempty"`
}

type OpenAIDeps

type OpenAIDeps struct {
	Credentials credentials.Store `json:"credentials,omitempty"`
}

type OpenAIReasoningConfig

type OpenAIReasoningConfig struct {
	Effort          string `json:"effort,omitempty"`
	GenerateSummary string `json:"generateSummary,omitempty"`
}

type ProviderRetrySettings

type ProviderRetrySettings struct {
	MaxRetries      int `json:"maxRetries"`
	MaxRetryDelayMs int `json:"maxRetryDelayMs"`
}

type Scripted

type Scripted struct {
	// contains filtered or unexported fields
}

Scripted replays fixed assistant responses for tests. One instance can be shared by several sessions (a multiplex or concurrent-dispatch preset), so the step cursor is guarded.

func (*Scripted) Name

func (p *Scripted) Name() string

func (*Scripted) Stream

type ScriptedConfig

type ScriptedConfig struct {
	// Model is name reported back to callers.
	Model string `json:"model"`
	// Steps are replies in order: text, tool calls, or both.
	Steps []ScriptedStep `json:"steps"`
}

type ScriptedStep

type ScriptedStep struct {
	Text      string              `json:"text"`
	ToolCalls []agentkit.ToolCall `json:"toolCalls"`
}

Jump to

Keyboard shortcuts

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