agent

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatExecutionPlan added in v0.0.2

func FormatExecutionPlan(plan *ExecutionPlan) string

FormatExecutionPlan formats an execution plan for display to the user

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent represents an AI agent

func NewAgent

func NewAgent(options ...Option) (*Agent, error)

NewAgent creates a new agent with the given options

func (*Agent) ApproveExecutionPlan added in v0.0.2

func (a *Agent) ApproveExecutionPlan(ctx context.Context, plan *ExecutionPlan) (string, error)

ApproveExecutionPlan approves an execution plan for execution

func (*Agent) CancelPlan added in v0.0.2

func (a *Agent) CancelPlan(plan *ExecutionPlan)

CancelPlan cancels an execution plan

func (*Agent) ExecutePlan added in v0.0.2

func (a *Agent) ExecutePlan(ctx context.Context, plan *ExecutionPlan) (string, error)

ExecutePlan executes an approved execution plan

func (*Agent) GenerateExecutionPlan added in v0.0.2

func (a *Agent) GenerateExecutionPlan(ctx context.Context, input string) (*ExecutionPlan, error)

GenerateExecutionPlan generates an execution plan based on the user input

func (*Agent) GetPlanByTaskID added in v0.0.2

func (a *Agent) GetPlanByTaskID(taskID string) (*ExecutionPlan, bool)

GetPlanByTaskID returns an execution plan by its task ID

func (*Agent) GetPlanStatus added in v0.0.2

func (a *Agent) GetPlanStatus(plan *ExecutionPlan) ExecutionPlanStatus

GetPlanStatus returns the status of an execution plan

func (*Agent) GetTaskByID added in v0.0.2

func (a *Agent) GetTaskByID(taskID string) (*ExecutionPlan, bool)

GetTaskByID returns a task by its ID

func (*Agent) ListTasks added in v0.0.2

func (a *Agent) ListTasks() []*ExecutionPlan

ListTasks returns a list of all tasks

func (*Agent) ModifyExecutionPlan added in v0.0.2

func (a *Agent) ModifyExecutionPlan(ctx context.Context, plan *ExecutionPlan, modifications string) (*ExecutionPlan, error)

ModifyExecutionPlan modifies an execution plan based on user input

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, input string) (string, error)

Run runs the agent with the given input

type ExecutionPlan added in v0.0.2

type ExecutionPlan struct {
	// Steps is a list of planned tool executions
	Steps []ExecutionStep
	// Description is a high-level description of what the plan will accomplish
	Description string
	// UserApproved indicates whether the user has approved the plan
	UserApproved bool
	// TaskID is a unique identifier for the task associated with this plan
	TaskID string
	// Status represents the current status of the execution plan
	Status ExecutionPlanStatus
	// CreatedAt is the time when the plan was created
	CreatedAt time.Time
	// UpdatedAt is the time when the plan was last updated
	UpdatedAt time.Time
}

ExecutionPlan represents a plan of tool executions that the agent intends to perform

func NewExecutionPlan added in v0.0.2

func NewExecutionPlan(description string, steps []ExecutionStep) *ExecutionPlan

NewExecutionPlan creates a new execution plan

type ExecutionPlanStatus added in v0.0.2

type ExecutionPlanStatus string

ExecutionPlanStatus represents the status of an execution plan

const (
	// StatusDraft indicates the plan is in draft state
	StatusDraft ExecutionPlanStatus = "draft"
	// StatusPendingApproval indicates the plan is waiting for user approval
	StatusPendingApproval ExecutionPlanStatus = "pending_approval"
	// StatusApproved indicates the plan has been approved
	StatusApproved ExecutionPlanStatus = "approved"
	// StatusExecuting indicates the plan is currently executing
	StatusExecuting ExecutionPlanStatus = "executing"
	// StatusCompleted indicates the plan has completed execution
	StatusCompleted ExecutionPlanStatus = "completed"
	// StatusFailed indicates the plan execution failed
	StatusFailed ExecutionPlanStatus = "failed"
	// StatusCancelled indicates the plan was cancelled
	StatusCancelled ExecutionPlanStatus = "cancelled"
)

type ExecutionStep added in v0.0.2

type ExecutionStep struct {
	// ToolName is the name of the tool to execute
	ToolName string
	// Input is the input to provide to the tool
	Input string
	// Description is a description of what this step will accomplish
	Description string
	// Parameters contains the parameters for the tool execution
	Parameters map[string]interface{}
}

ExecutionStep represents a single step in an execution plan

type Option

type Option func(*Agent)

Option represents an option for configuring an agent

func WithGuardrails

func WithGuardrails(guardrails interfaces.Guardrails) Option

WithGuardrails sets the guardrails for the agent

func WithLLM

func WithLLM(llm interfaces.LLM) Option

WithLLM sets the LLM for the agent

func WithMemory

func WithMemory(memory interfaces.Memory) Option

WithMemory sets the memory for the agent

func WithName added in v0.0.2

func WithName(name string) Option

WithName sets the name for the agent

func WithOrgID

func WithOrgID(orgID string) Option

WithOrgID sets the organization ID for multi-tenancy

func WithRequirePlanApproval added in v0.0.2

func WithRequirePlanApproval(require bool) Option

WithRequirePlanApproval sets whether execution plans require user approval

func WithSystemPrompt

func WithSystemPrompt(prompt string) Option

WithSystemPrompt sets the system prompt for the agent

func WithTools

func WithTools(tools ...interfaces.Tool) Option

WithTools sets the tools for the agent

func WithTracer

func WithTracer(tracer interfaces.Tracer) Option

WithTracer sets the tracer for the agent

Jump to

Keyboard shortcuts

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