Documentation
¶
Index ¶
- Constants
- func RunStreamText(ctx context.Context, a StreamAgent, input string) (*schema.RunStream, error)
- func RunText(ctx context.Context, a Agent, input string) (*schema.RunResponse, error)
- func RunToStream(ctx context.Context, a Agent, req *schema.RunRequest) *schema.RunStream
- type Agent
- type Base
- type Config
- type CustomAgent
- type RunFunc
- type StreamAgent
- type StreamMiddleware
Constants ¶
const DefaultStreamBufferSize = 32
DefaultStreamBufferSize is the default channel buffer size for streaming events.
Variables ¶
This section is empty.
Functions ¶
func RunStreamText ¶
RunStreamText is a convenience function that sends a single text message and returns a streaming response. The agent must implement StreamAgent.
func RunToStream ¶
RunToStream wraps a non-streaming Agent.Run call as a RunStream, emitting AgentStart and AgentEnd lifecycle events.
Types ¶
type Agent ¶
type Agent interface {
Run(ctx context.Context, req *schema.RunRequest) (*schema.RunResponse, error)
ID() string
Name() string
Description() string
}
Agent is the core interface for all agent types.
type Base ¶
Base implements ID/Name/Description for embedding into concrete agent types.
func (*Base) Description ¶
type CustomAgent ¶
type CustomAgent struct {
Base
// contains filtered or unexported fields
}
CustomAgent delegates its Run to a user-provided RunFunc.
func NewCustomAgent ¶
func NewCustomAgent(cfg Config, fn RunFunc) *CustomAgent
NewCustomAgent creates a CustomAgent with the given RunFunc.
func (*CustomAgent) Run ¶
func (a *CustomAgent) Run(ctx context.Context, req *schema.RunRequest) (*schema.RunResponse, error)
Run delegates to the configured RunFunc. Returns an error if RunFunc is nil.
type RunFunc ¶
type RunFunc func(ctx context.Context, req *schema.RunRequest) (*schema.RunResponse, error)
RunFunc is the function signature used by CustomAgent.
type StreamAgent ¶
type StreamAgent interface {
Agent
RunStream(ctx context.Context, req *schema.RunRequest) (*schema.RunStream, error)
}
StreamAgent extends Agent with streaming support.