Help us shape the future of Go! Take the 2026 Go Developer Survey

compose

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BudgetConfig

type BudgetConfig struct {
	Enabled             bool
	MaxTokensPerRequest int
	MaxTokensPerMinute  int
	MaxTokensPerHour    int
	MaxTokensPerDay     int
	MaxCostPerRequest   float64
	MaxCostPerDay       float64
	AlertThreshold      float64
	AutoThrottle        bool
	ThrottleDelay       time.Duration
}

BudgetConfig controls token and cost policy assembly.

type CacheConfig

type CacheConfig struct {
	Enabled      bool
	LocalMaxSize int
	LocalTTL     time.Duration
	EnableRedis  bool
	RedisTTL     time.Duration
	KeyStrategy  string
}

CacheConfig controls prompt-cache assembly.

type Config

type Config struct {
	Timeout    time.Duration
	MaxRetries int
	Budget     BudgetConfig
	Cache      CacheConfig
	Tool       ToolProviderConfig
}

Config controls runtime composition around an already-constructed main provider. It is storage-agnostic and can be reused by external projects.

type Runtime

type Runtime struct {
	Gateway       llmcore.Gateway
	ToolGateway   llmcore.Gateway
	Provider      llm.Provider
	ToolProvider  llm.Provider
	BudgetManager *llmpolicy.TokenBudgetManager
	CostTracker   *observability.CostTracker
	Ledger        observability.Ledger
	Cache         *cache.MultiLevelCache
	Metrics       *observability.Metrics
	PolicyManager *llmpolicy.Manager
}

Runtime groups the LLM-facing runtime dependencies assembled around a main provider chain.

func Build

func Build(cfg Config, mainProvider llm.Provider, logger *zap.Logger) (*Runtime, error)

Build assembles the shared runtime chain around the supplied main provider.

type ToolProviderConfig

type ToolProviderConfig struct {
	Provider        string
	DefaultProvider string
	APIKey          string
	DefaultAPIKey   string
	BaseURL         string
	DefaultBaseURL  string
	Timeout         time.Duration
	MaxRetries      int
}

ToolProviderConfig describes an optional dedicated tool-calling provider. If the provider/api key/baseURL/timeout/max-retry fields are all left empty or zero, the runtime reuses the main provider for tools.

Jump to

Keyboard shortcuts

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