agent

package
v0.0.0-...-d758db0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

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

func NewFactory

func NewFactory(cfg *config.Config) *Factory

NewFactory creates a new Factory

func (*Factory) CreateAgent

func (f *Factory) CreateAgent(name string) (Agent, error)

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, prompt string) (string, error)

Chat performs conversation, returns response content

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) Init

func (r *ReactAgent) Init() error

Init initializes Agent

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

OnEnd callback when node ends

func (*ToolCallCallback) OnEndWithStreamOutput

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

OnStart callback when node starts

func (*ToolCallCallback) OnStartWithStreamInput

OnStartWithStreamInput callback when stream input starts

type ToolCallInfo

type ToolCallInfo struct {
	Type      string // "start", "end", "error"
	Name      string
	Arguments string
	Result    string
	Error     string
}

ToolCallInfo represents structured tool call information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL