sdk

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentOptions

type AgentOptions struct {
	// BuildOptions controls agent runtime optional subsystems (reflection, MCP, LSP, etc.).
	// Zero value means "use runtime.DefaultBuildOptions()".
	BuildOptions runtime.BuildOptions

	// ToolScope optionally restricts the tools available to built agents.
	// Empty means no restriction.
	ToolScope []string
}

type Builder

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

Builder is the SDK unified builder.

func New

func New(opts Options) *Builder

New creates a unified SDK builder.

func (*Builder) Build

func (b *Builder) Build(ctx context.Context) (*Runtime, error)

Build assembles the library runtime according to Options.

type LLMOptions

type LLMOptions struct {
	// Provider is a ready-to-use main provider. When set, Router is ignored.
	Provider llm.Provider

	// ToolProvider is optional. When set, agents may use it for tool calls
	// while using Provider for final answer generation (dual-model mode).
	ToolProvider llm.Provider

	// Compose optionally wraps the assembled main provider with retry/cache/budget
	// middleware via llm/runtime/compose.Build.
	Compose *llmcompose.Config

	// Router optionally builds a channel-routed provider from a store. This is
	// the SDK-friendly assembly surface for load balancing and model mapping.
	Router *LLMRouterOptions
}

LLMOptions unifies the SDK entrypoint for LLM provider composition.

Consumers can either inject a ready llm.Provider directly (Provider), or ask the SDK to build a channel-routed provider (Router).

type LLMRouterOptions

type LLMRouterOptions struct {
	// Name is an optional provider chain name for diagnostics.
	Name string

	// Store is required. It supplies channels, keys, secrets, and model mappings.
	Store channelstore.Store

	// ProviderTimeout controls upstream provider timeout (optional).
	ProviderTimeout time.Duration

	// RetryPolicy is optional and overrides the router's default retry behavior.
	RetryPolicy llmrouter.ChannelRouteRetryPolicy

	// Logger overrides the build logger (optional).
	Logger *zap.Logger
}

type Options

type Options struct {
	Logger *zap.Logger

	// LLM configures how the SDK assembles the main provider/tool provider.
	// This is the single supported top-level entry for SDK LLM wiring.
	LLM *LLMOptions

	Agent    *AgentOptions
	Workflow *WorkflowOptions
	RAG      *RAGOptions
}

Options defines the unified SDK assembly surface for library consumers.

Boundary (A): - Outputs: Agent / Workflow / RAG / LLM Provider (optional routing) - Excludes: HTTP server, routes/handlers, DB migrations, service lifecycle bootstrap

type RAGOptions

type RAGOptions struct {
	// Enable builds RAG runtime components.
	Enable bool

	// Config optionally provides global config (used by runtime builder for store selection).
	// May be nil; in that case the runtime defaults to in-memory store unless overridden.
	Config *config.Config

	// VectorStoreType selects a backend when Config is present.
	// Default: core.VectorStoreMemory.
	VectorStoreType core.VectorStoreType

	// EmbeddingType selects embedding provider type when Config is present.
	// Default: core.EmbeddingProviderType(cfg.LLM.DefaultProvider) when cfg != nil.
	EmbeddingType core.EmbeddingProviderType

	// RerankType selects rerank provider type when Config is present.
	// Default: core.RerankProviderType(cfg.LLM.DefaultProvider) when cfg != nil.
	RerankType core.RerankProviderType

	// Direct injections (override types/config).
	VectorStore       core.VectorStore
	EmbeddingProvider core.EmbeddingProvider
	RerankProvider    core.RerankProvider

	// HybridConfig overrides the default hybrid retrieval config.
	HybridConfig *rag.HybridRetrievalConfig

	// APIKey overrides cfg.LLM.APIKey when building providers/stores from config.
	APIKey string
}

type RAGRuntime

type RAGRuntime struct {
	Store             core.VectorStore
	EmbeddingProvider core.EmbeddingProvider
	RerankProvider    core.RerankProvider

	EnhancedRetriever *rag.EnhancedRetriever
	HybridRetriever   *rag.HybridRetriever
}

type Runtime

type Runtime struct {

	// Provider is the primary chat provider (may be nil if not configured).
	Provider llm.Provider
	// ToolProvider is an optional dedicated provider for tool calls.
	ToolProvider llm.Provider
	Gateway      llmcore.Gateway
	ToolGateway  llmcore.Gateway

	Workflow *WorkflowRuntime
	RAG      *RAGRuntime
	// contains filtered or unexported fields
}

Runtime is the assembled library runtime for external consumers. It exposes small, stable entrypoints to construct and execute capabilities.

func (*Runtime) Logger

func (r *Runtime) Logger() *zap.Logger

Logger returns the runtime logger.

func (*Runtime) NewAgent

func (r *Runtime) NewAgent(ctx context.Context, cfg types.AgentConfig) (*agent.BaseAgent, error)

NewAgent constructs an agent using the unified runtime builder. It requires Provider to be configured (either through SDK Options or a later override).

type WorkflowOptions

type WorkflowOptions struct {
	// Enable builds workflow facade/executor. Default true when provided.
	Enable bool

	// EnableDSL builds a DSL parser (workflow/dsl) in addition to the facade.
	EnableDSL bool
}

type WorkflowRuntime

type WorkflowRuntime struct {
	Facade *workflow.Facade
	Parser *dsl.Parser // optional
}

Jump to

Keyboard shortcuts

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