Documentation
¶
Index ¶
- Constants
- func ApplySkill(ac *config.Agent, sk config.Skill)
- func IsToolError(result string) bool
- type Agent
- type Factory
- type ReactAgent
- func (r *ReactAgent) Chat(ctx context.Context, history []*schema.Message, prompt string) (output string, retErr error)
- func (r *ReactAgent) ChatStream(ctx context.Context, history []*schema.Message, prompt string, ...) (retErr error)
- func (r *ReactAgent) ChatWithCallback(ctx context.Context, history []*schema.Message, prompt string, ...) (output string, retErr error)
- func (r *ReactAgent) Init() error
- func (r *ReactAgent) Run(prompt string) error
- type StreamChunk
- type ThinkFilter
- 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 ¶
const ToolErrorPrefix = "tool execution failed: "
ToolErrorPrefix marks a tool result that carries a failure. The UI shows such a result as a failed call instead of a successful one.
Variables ¶
This section is empty.
Functions ¶
func ApplySkill ¶ added in v0.7.0
ApplySkill folds a skill into an agent configuration: the skill's instructions go in front of the agent's system prompt and its extension tools are added without duplicating tools the agent already has.
This is the eager half of the Agent Skills model: an explicitly activated skill (`/skill`, session config options) is inlined for the whole session. Skills that are only discovered stay out of the prompt body; see skillsCatalog.
func IsToolError ¶
IsToolError reports whether a tool result carries a failure.
Types ¶
type Agent ¶
type Agent interface {
// Run runs the agent
Run(prompt string) error
// Chat performs conversation, returns response content
Chat(ctx context.Context, history []*schema.Message, prompt string) (string, error)
// ChatWithCallback performs conversation, supporting tool call callbacks
ChatWithCallback(ctx context.Context, history []*schema.Message, prompt string, callback func(interface{})) (string, error)
// ChatStream performs streaming conversation, handles streaming output through chunk callback
ChatStream(ctx context.Context, history []*schema.Message, prompt string, chunkCallback func(*StreamChunk), toolCallback func(interface{})) error
}
Agent defines the agent interface used in the CLI.
The conversation methods take the prior turns (history) explicitly: the underlying ReAct flow is stateless, so multi-turn context is passed in by the caller on every turn.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is used to create Agent instances
func (*Factory) CreateAgent ¶
CreateAgent creates Agent based on name
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) Chat ¶
func (r *ReactAgent) Chat(ctx context.Context, history []*schema.Message, prompt string) (output string, retErr error)
Chat performs conversation, returns response content
func (*ReactAgent) ChatStream ¶
func (r *ReactAgent) ChatStream(ctx context.Context, history []*schema.Message, prompt string, chunkCallback func(*StreamChunk), toolCallback func(interface{})) (retErr error)
ChatStream performs streaming conversation, handles streaming output via chunk callback
func (*ReactAgent) ChatWithCallback ¶
func (r *ReactAgent) ChatWithCallback(ctx context.Context, history []*schema.Message, prompt string, callback func(interface{})) (output string, retErr 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", "reasoning", "tool_start", "tool_end", "error"
Tool string // Tool name (only used for tool-related messages)
}
StreamChunk represents a data chunk for streaming output
type ThinkFilter ¶
type ThinkFilter struct {
// contains filtered or unexported fields
}
ThinkFilter splits streamed content into visible answer text and reasoning text. Markers may span chunk boundaries; partial markers are buffered until they can be classified.
func NewThinkFilter ¶
func NewThinkFilter() *ThinkFilter
NewThinkFilter creates a filter state for one streaming turn.
func (*ThinkFilter) Feed ¶
func (f *ThinkFilter) Feed(s string) (visible, thought string)
Feed processes one chunk and returns the visible answer content and the reasoning content extracted from it (either may be empty).
func (*ThinkFilter) Flush ¶
func (f *ThinkFilter) Flush() (visible, thought string)
Flush drains any buffered content when the stream ends. An unterminated thinking section is returned as reasoning rather than dropped.
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