Documentation
¶
Overview ¶
Package ai coordinates provider resolution, route tools, memory, and streaming turns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotConfigured means neither a user provider nor the shared config is usable. ErrNotConfigured = errors.New("ai: no provider configured") // ErrProviderUnsupported means the resolved provider kind has no adapter yet. ErrProviderUnsupported = errors.New("ai: provider kind not supported") )
Functions ¶
Types ¶
type ProviderFactory ¶
type ProviderFactory func(ctx context.Context, kind models.AIProviderKind, key, baseURL, model string) (engine.Provider, error)
ProviderFactory builds an engine.Provider for a resolved config.
type RunInput ¶
type RunInput struct {
User models.User
ConnID string
Protocol string
ConnectionTitle string
AIMode string // disabled | read_only | read_write
AllowDestructive bool
Scope Scope
ConversationID string // when set (with memory wired), history is persisted
History []engine.Message
UserMessage string
RecentOps []string
Confirm tools.Confirmer
}
RunInput is one chat turn's request.
type Scope ¶
type Scope struct {
ProviderID string
}
Scope selects the provider for a turn. Empty ProviderID means shared AI.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the public AI surface used by transport.
func New ¶
func New(providers *aiconfig.Service, global config.AIConfig, routes tools.RouteSource, invoker tools.Invoker, mem *memory.Store, models *modelreg.Registry) *Service
New wires the config service, global config, route source, secure invoker, conversation memory, and the model-limit registry.
func (*Service) Configured ¶
Configured reports whether any provider (user or global) could serve a turn for the user. Used by transport to gate the chat endpoint.
func (*Service) Conversations ¶
Conversations exposes the conversation/message store for transport CRUD.
func (*Service) Run ¶
Run executes one turn and relays every event to sink. The caller cancels ctx to stop the turn cleanly.
func (*Service) WithProviderFactory ¶
func (s *Service) WithProviderFactory(f ProviderFactory) *Service
WithProviderFactory overrides the engine adapter (used in tests).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent builds the system prompt and relays a provider turn to the transport, buffering text deltas so the UI receives smooth, batched updates instead of a flood of tiny frames.
|
Package agent builds the system prompt and relays a provider turn to the transport, buffering text deltas so the UI receives smooth, batched updates instead of a flood of tiny frames. |
|
Package budget computes a turn's token budgeting.
|
Package budget computes a turn's token budgeting. |
|
Package aiconfig manages shared and user-scoped AI provider configuration.
|
Package aiconfig manages shared and user-scoped AI provider configuration. |
|
Package engine defines the framework-agnostic AI provider interfaces.
|
Package engine defines the framework-agnostic AI provider interfaces. |
|
eino
Package eino is the only package that imports cloudwego/eino; it adapts the framework to the engine.Provider seam with an explicit tool-calling loop so each tool call flows through the risk-gated executor.
|
Package eino is the only package that imports cloudwego/eino; it adapts the framework to the engine.Provider seam with an explicit tool-calling loop so each tool call flows through the risk-gated executor. |
|
Package memory persists AI conversations and assembles context windows.
|
Package memory persists AI conversations and assembles context windows. |
|
Package modelreg resolves model token limits from live registries, provider catalogues, static metadata, and finally a safe default.
|
Package modelreg resolves model token limits from live registries, provider catalogues, static metadata, and finally a safe default. |
|
Package tools exposes risk-gated connection routes as agent tools.
|
Package tools exposes risk-gated connection routes as agent tools. |