Documentation
¶
Index ¶
- func Base64EncodeImage(filename string) (string, error)
- func MustJSONSchema(s any) *jsonschema.Definition
- type Agent
- func (agent *Agent) AsTool(description string) Tool
- func (agent *Agent) IsZero() bool
- func (agent *Agent) Name() string
- func (agent *Agent) Run(ctx context.Context, messages Messages, options ...RunOption) (*Response, error)
- func (agent *Agent) SetSchema(value any) error
- func (agent *Agent) String() string
- type AgentHooks
- type AgentOption
- type Caller
- type DefaultAgentHooks
- func (h *DefaultAgentHooks) OnAgentEnd(ctx context.Context, agent *Agent, response *Response) error
- func (h *DefaultAgentHooks) OnAgentStart(ctx context.Context, agent *Agent, messages Messages) error
- func (h *DefaultAgentHooks) OnHandoff(ctx context.Context, fromAgent *Agent, toAgent *Agent, agentContext string) error
- func (h *DefaultAgentHooks) OnToolEnd(ctx context.Context, agent *Agent, toolName string, result any) error
- func (h *DefaultAgentHooks) OnToolStart(ctx context.Context, agent *Agent, toolName string, params map[string]any) error
- type Message
- type Messages
- type Response
- type RunOption
- type Tool
- type Tools
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64EncodeImage ¶
func MustJSONSchema ¶
func MustJSONSchema(s any) *jsonschema.Definition
Types ¶
type Agent ¶
func New ¶
func New(name, instructions string, options ...AgentOption) *Agent
func (*Agent) AsTool ¶
AsTool creates a tool that returns the agent itself This is useful for agent handoff scenarios where one agent can call another agent
type AgentHooks ¶
type AgentHooks interface {
OnAgentStart(ctx context.Context, agent *Agent, messages Messages) error
OnAgentEnd(ctx context.Context, agent *Agent, response *Response) error
OnHandoff(ctx context.Context, fromAgent *Agent, toAgent *Agent, agentContext string) error
OnToolStart(ctx context.Context, agent *Agent, toolName string, params map[string]any) error
OnToolEnd(ctx context.Context, agent *Agent, toolName string, result any) error
}
AgentHooks defines callbacks for agent lifecycle events
type AgentOption ¶
type AgentOption func(*Agent)
func WithClient ¶
func WithClient(client *client.Client) AgentOption
func WithHooks ¶
func WithHooks(hooks AgentHooks) AgentOption
WithHooks adds lifecycle hooks to the agent
func WithLogger ¶
func WithLogger(logger *slog.Logger) AgentOption
type DefaultAgentHooks ¶
type DefaultAgentHooks struct{}
DefaultAgentHooks provides a no-op implementation of AgentHooks Users can embed this struct and override only the methods they need
func (*DefaultAgentHooks) OnAgentEnd ¶
func (*DefaultAgentHooks) OnAgentStart ¶
func (*DefaultAgentHooks) OnToolStart ¶
type RunOption ¶
type RunOption func(*runOptions)
RunOption defines options for the Run function
func WithMaxMessages ¶
WithMaxMessages sets the maximum number of message iterations in the agent's run loop
type Tool ¶
type Tool struct {
Name string
Description string
Parameters *jsonschema.Definition
Func func(ctx context.Context, params map[string]any) (any, error)
}
func MustWrapStruct ¶
Click to show internal directories.
Click to hide internal directories.