Documentation
¶
Index ¶
- type Agent
- type Factory
- type ReactAgent
- func (r *ReactAgent) Chat(ctx context.Context, prompt string) (string, error)
- func (r *ReactAgent) ChatStream(ctx context.Context, prompt string, chunkCallback func(*StreamChunk), ...) error
- func (r *ReactAgent) ChatWithCallback(ctx context.Context, prompt string, callback func(interface{})) (string, error)
- func (r *ReactAgent) Init() error
- func (r *ReactAgent) Run(prompt string) error
- type StreamChunk
- type ToolCallCallback
- func (t *ToolCallCallback) OnEnd(ctx context.Context, info *callbacks.RunInfo, output callbacks.CallbackOutput) context.Context
- func (t *ToolCallCallback) OnEndWithStreamOutput(ctx context.Context, info *callbacks.RunInfo, ...) context.Context
- func (t *ToolCallCallback) OnError(ctx context.Context, info *callbacks.RunInfo, err error) context.Context
- func (t *ToolCallCallback) OnStart(ctx context.Context, info *callbacks.RunInfo, input callbacks.CallbackInput) context.Context
- func (t *ToolCallCallback) OnStartWithStreamInput(ctx context.Context, info *callbacks.RunInfo, ...) context.Context
- type ToolCallInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
// Run runs the agent
Run(prompt string) error
// Chat performs conversation, returns response content
Chat(ctx context.Context, prompt string) (string, error)
// ChatWithCallback performs conversation, supporting tool call callbacks
ChatWithCallback(ctx context.Context, prompt string, callback func(interface{})) (string, error)
// ChatStream performs streaming conversation, handles streaming output through chunk callback
ChatStream(ctx context.Context, prompt string, chunkCallback func(*StreamChunk), toolCallback func(interface{})) error
}
Agent defines the agent interface used in the CLI
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is used to create Agent instances
type ReactAgent ¶
type ReactAgent struct {
// contains filtered or unexported fields
}
ReactAgent implements Agent using React pattern from cloudwego/eino library
func NewReactAgent ¶
func NewReactAgent(agentName string, cfg *config.Agent) *ReactAgent
NewReactAgent creates a new ReactAgent
func (*ReactAgent) ChatStream ¶
func (r *ReactAgent) ChatStream(ctx context.Context, prompt string, chunkCallback func(*StreamChunk), toolCallback func(interface{})) error
ChatStream performs streaming conversation, handles streaming output via chunk callback
func (*ReactAgent) ChatWithCallback ¶
func (r *ReactAgent) ChatWithCallback(ctx context.Context, prompt string, callback func(interface{})) (string, error)
ChatWithCallback performs conversation with streaming output and callback support
func (*ReactAgent) Run ¶
func (r *ReactAgent) Run(prompt string) error
Run runs Agent with optimized output formatting
type StreamChunk ¶
type StreamChunk struct {
Content string
Type string // "content", "tool_start", "tool_end", "error"
Tool string // Tool name (only used for tool-related messages)
}
StreamChunk represents a data chunk for streaming output
type ToolCallCallback ¶
type ToolCallCallback struct {
// contains filtered or unexported fields
}
ToolCallCallback custom callback handler for capturing tool call information
func (*ToolCallCallback) OnEnd ¶
func (t *ToolCallCallback) OnEnd(ctx context.Context, info *callbacks.RunInfo, output callbacks.CallbackOutput) context.Context
OnEnd callback when node ends
func (*ToolCallCallback) OnEndWithStreamOutput ¶
func (t *ToolCallCallback) OnEndWithStreamOutput(ctx context.Context, info *callbacks.RunInfo, output *schema.StreamReader[callbacks.CallbackOutput]) context.Context
OnEndWithStreamOutput callback when stream output ends
func (*ToolCallCallback) OnError ¶
func (t *ToolCallCallback) OnError(ctx context.Context, info *callbacks.RunInfo, err error) context.Context
OnError callback when node encounters error
func (*ToolCallCallback) OnStart ¶
func (t *ToolCallCallback) OnStart(ctx context.Context, info *callbacks.RunInfo, input callbacks.CallbackInput) context.Context
OnStart callback when node starts
func (*ToolCallCallback) OnStartWithStreamInput ¶
func (t *ToolCallCallback) OnStartWithStreamInput(ctx context.Context, info *callbacks.RunInfo, input *schema.StreamReader[callbacks.CallbackInput]) context.Context
OnStartWithStreamInput callback when stream input starts