Documentation
¶
Overview ¶
Package agent contains yai's core (non-UI) logic.
It resolves the model/provider configuration, prepares the request (including MCP tools), and starts a streaming completion.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyProxyConfig ¶
func ApplyProxyConfig(httpProxy string, providerCfg *fantasybridge.Config) error
ApplyProxyConfig configures the provider HTTP client to use an HTTP proxy.
func NewFantasyClient ¶
func NewFantasyClient(cfg fantasybridge.Config) (stream.Client, error)
NewFantasyClient creates the fantasy bridge client.
Types ¶
type ClientFactory ¶ added in v0.2.3
type ClientFactory func(fantasybridge.Config) (stream.Client, error)
ClientFactory creates a stream.Client from a provider configuration. It allows tests to replace the real Fantasy bridge with a stub.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the core orchestration layer for starting LLM streams.
It is intentionally UI-agnostic and can be used by both the TUI and headless commands.
func New ¶
func New(cfg *config.Config, cache *cache.Conversations, mcpSvc *mcp.Service, opts ...ClientFactory) *Service
New creates an agent service. An optional ClientFactory can be provided for testing; when nil, the default Fantasy bridge client is used.
func (*Service) ActionForStreamError ¶
func (s *Service) ActionForStreamError(err error, mod config.Model, prompt string) StreamErrorAction
ActionForStreamError decides whether a provider error should be retried, and if so which prompt/model override should be used.
func (*Service) StreamContinue ¶ added in v0.2.4
func (s *Service) StreamContinue(ctx context.Context, history []proto.Message, prompt string) (StreamStart, error)
StreamContinue starts a streaming completion using pre-built conversation history. It prepends system messages (format + role) to the provided history and appends the new user message. This avoids per-turn disk I/O and prevents system message duplication across turns.
type StreamErrorAction ¶
StreamErrorAction describes how yai should respond to a streaming error.