Documentation
¶
Index ¶
- func ReactLoop(ctx context.Context, task *Task) error
- type Agent
- type AgentOption
- func WithHistoryCompressor(compressor HistoryCompressor) AgentOption
- func WithInstruction(instruction string) AgentOption
- func WithLLMInterceptor(interceptor LLMInterceptor) AgentOption
- func WithMaxTurn(maxTurn int) AgentOption
- func WithModel(models *llmapi.Models, model string) AgentOption
- func WithNewTools(tools ...*Tool) AgentOption
- func WithOnEventUpdate(handler EventUpdateHandler) AgentOption
- func WithReasonLevel(level int) AgentOption
- func WithStream(stream bool) AgentOption
- func WithTaskInterceptor(interceptor TaskInterceptor) AgentOption
- func WithToolCallInterceptor(interceptor ToolCallInterceptor) AgentOption
- func WithTools(tools ...*Tool) AgentOption
- type AgentOptions
- type EventUpdateHandler
- type HTTPOption
- type HTTPServer
- type HistoryCompressor
- type LLMHandler
- type LLMInterceptor
- type Loop
- type RunResult
- type Task
- func (t *Task) AddEvent(event *types.Event) error
- func (t *Task) AddMessage(msg *llmtypes.Message) (*types.Event, error)
- func (t *Task) AddToolResults(toolRuns []*ToolRun) ([]*types.Event, error)
- func (t *Task) Done(err error) error
- func (t *Task) RunTurn(ctx context.Context, turnIndex int) ([]*types.Event, error)
- func (t *Task) Start() error
- type TaskHandler
- type TaskInterceptor
- type TaskPrompt
- type TaskPromptHumanResult
- type TaskPromptTool
- type TaskPromptToolResult
- type TaskTurn
- type Tool
- type ToolCallHandler
- type ToolCallInterceptor
- type ToolContext
- type ToolInvoker
- type ToolResultHuman
- type ToolResultNotify
- type ToolRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Agent ¶
func NewAgent ¶
func NewAgent(name, desc string, storage types.SessionStorage, loop Loop, opts ...AgentOption) (*Agent, error)
func (*Agent) ListSessions ¶
func (*Agent) RunTask ¶
func (a *Agent) RunTask(ctx context.Context, sessionId string, prompt *TaskPrompt, opts ...AgentOption) (*Task, error)
type AgentOption ¶
type AgentOption func(*AgentOptions) *AgentOptions
func WithHistoryCompressor ¶
func WithHistoryCompressor(compressor HistoryCompressor) AgentOption
func WithInstruction ¶
func WithInstruction(instruction string) AgentOption
func WithLLMInterceptor ¶
func WithLLMInterceptor(interceptor LLMInterceptor) AgentOption
func WithMaxTurn ¶
func WithMaxTurn(maxTurn int) AgentOption
func WithNewTools ¶
func WithNewTools(tools ...*Tool) AgentOption
func WithOnEventUpdate ¶
func WithOnEventUpdate(handler EventUpdateHandler) AgentOption
func WithReasonLevel ¶
func WithReasonLevel(level int) AgentOption
func WithStream ¶
func WithStream(stream bool) AgentOption
func WithTaskInterceptor ¶
func WithTaskInterceptor(interceptor TaskInterceptor) AgentOption
func WithToolCallInterceptor ¶
func WithToolCallInterceptor(interceptor ToolCallInterceptor) AgentOption
func WithTools ¶
func WithTools(tools ...*Tool) AgentOption
type AgentOptions ¶
type AgentOptions struct {
Models *llmapi.Models
Model string
Instruction string
ReasonLevel int
Tools []*Tool
MaxTurn int
Stream bool
OnEventUpdate EventUpdateHandler
HistoryCompressor HistoryCompressor
TaskInterceptors []TaskInterceptor
LLMInterceptors []LLMInterceptor
ToolCallInterceptors []ToolCallInterceptor
}
type EventUpdateHandler ¶
type HTTPOption ¶
type HTTPOption func(*HTTPServer)
func HTTPWithEnableConsole ¶
func HTTPWithEnableConsole(enable bool) HTTPOption
func HTTPWithPrefix ¶
func HTTPWithPrefix(prefix string) HTTPOption
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func NewHTTPServer ¶
func NewHTTPServer(agents []*Agent, opts ...HTTPOption) *HTTPServer
func (*HTTPServer) Handler ¶
func (s *HTTPServer) Handler() http.Handler
func (*HTTPServer) ServeHTTP ¶
func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start(addr string) error
type HistoryCompressor ¶
type LLMHandler ¶
type LLMInterceptor ¶
type LLMInterceptor func(LLMHandler) LLMHandler
type RunResult ¶
type RunResult struct {
AgentName string `json:"agentName,omitempty" yaml:"agentName,omitempty"`
SessionID string `json:"sessionId,omitempty" yaml:"sessionId,omitempty"`
TaskID string `json:"taskId,omitempty" yaml:"taskId,omitempty"`
Events []*types.Event `json:"events,omitempty" yaml:"events,omitempty"`
Error string `json:"error,omitempty" yaml:"error,omitempty"`
}
type Task ¶
type Task struct {
ID string
Session *session.Session
Events []*types.Event
Models *llmapi.Models
Model string
Instruction string
Tools map[string]*Tool
ReasonLevel int
History []*llmtypes.Message
Prompt *TaskPrompt
Stream bool
MaxTurn int
HistoryCompressor HistoryCompressor
OnEventUpdate EventUpdateHandler
LLMInterceptors []LLMInterceptor
ToolCallInterceptors []ToolCallInterceptor
// contains filtered or unexported fields
}
func NewTask ¶
func NewTask(agent *Agent, session *session.Session, options *AgentOptions, prompt *TaskPrompt) (*Task, error)
func (*Task) AddToolResults ¶
type TaskInterceptor ¶
type TaskInterceptor func(TaskHandler) TaskHandler
type TaskPrompt ¶
type TaskPrompt struct {
Text string `json:"text,omitempty"`
Tools []*TaskPromptTool `json:"tools,omitempty"`
ToolResults []*TaskPromptToolResult `json:"toolResults,omitempty"`
HumanResults []*TaskPromptHumanResult `json:"humanResults,omitempty"`
State map[string]any `json:"state,omitempty"`
StateDelta map[string]any `json:"stateDelta,omitempty"`
}
type TaskPromptHumanResult ¶
type TaskPromptTool ¶
type TaskPromptToolResult ¶
type Tool ¶
type Tool struct {
Name string
Description string
Parameters map[string]any
Invoker ToolInvoker
}
type ToolCallHandler ¶
type ToolCallHandler func(context.Context, *llmtypes.MessageToolCall) *llmtypes.MessageToolResult
type ToolCallInterceptor ¶
type ToolCallInterceptor func(ToolCallHandler) ToolCallHandler
type ToolContext ¶
type ToolInvoker ¶
type ToolInvoker func(ToolContext, string) (any, error)
type ToolResultHuman ¶
type ToolResultNotify ¶
type ToolResultNotify struct{}
type ToolRun ¶
type ToolRun struct {
Call *llmtypes.MessageToolCall
Result *llmtypes.MessageToolResult
}
Click to show internal directories.
Click to hide internal directories.