Documentation
¶
Index ¶
- type Agent
- func (a *Agent) AddMessage(ctx context.Context, thread *Thread, message Message) error
- func (a *Agent) AddMessageWithUser(ctx context.Context, thread *Thread, message Message, userID string) error
- func (a *Agent) AddMessageWithoutSaving(ctx context.Context, thread *Thread, message Message, userID string) error
- func (a *Agent) CancelRun(ctx context.Context, run *Run) error
- func (a *Agent) CreateRun(ctx context.Context, thread *Thread) (*Run, error)
- func (a *Agent) CreateThread(ctx context.Context, messages []Message, metadata map[string]interface{}) (*Thread, error)
- func (a *Agent) CreateThreadWithUser(ctx context.Context, userID string, messages []Message, ...) (*Thread, error)
- func (a *Agent) DelegateToChild(ctx context.Context, target string, input *Message, ...) (map[string]interface{}, error)
- func (a *Agent) ExecuteRun(ctx context.Context, run *Run, thread *Thread) error
- func (a *Agent) ExecuteRunWithRepository(ctx context.Context, run *Run, thread *Thread, userID string, repo interface{}) error
- func (a *Agent) GetChild(name string) (*Agent, bool)
- func (a *Agent) RegisterChild(name string, child *Agent)
- func (a *Agent) SetClient(client *LLMClient)
- func (a *Agent) SetDescription(s string)
- func (a *Agent) SetSystemPrompt(s string)
- func (a *Agent) StreamRun(ctx context.Context, run *Run, thread *Thread, callback func(Message) error) error
- type AgentConfig
- type Config
- type Handoff
- type LLMClient
- type Message
- type OpenAIConfig
- type Run
- type RunStatus
- type Thread
- type Tool
- type ToolCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
Config AgentConfig
Handoff Handoff
// contains filtered or unexported fields
}
Agent represents an OpenAI agent that can perform tasks
func NewAgent ¶
func NewAgent(config AgentConfig) *Agent
NewAgent creates a new agent with the given configuration
func (*Agent) AddMessage ¶
AddMessage adds a message to a thread
func (*Agent) AddMessageWithUser ¶
func (a *Agent) AddMessageWithUser(ctx context.Context, thread *Thread, message Message, userID string) error
AddMessageWithUser adds a message to a thread with user identification
func (*Agent) AddMessageWithoutSaving ¶
func (a *Agent) AddMessageWithoutSaving(ctx context.Context, thread *Thread, message Message, userID string) error
AddMessageWithoutSaving adds a message to a thread without saving to repository
func (*Agent) CreateThread ¶
func (a *Agent) CreateThread(ctx context.Context, messages []Message, metadata map[string]interface{}) (*Thread, error)
CreateThread creates a new conversation thread
func (*Agent) CreateThreadWithUser ¶
func (a *Agent) CreateThreadWithUser(ctx context.Context, userID string, messages []Message, metadata map[string]interface{}) (*Thread, error)
CreateThreadWithUser creates a new conversation thread with user identification
func (*Agent) DelegateToChild ¶
func (a *Agent) DelegateToChild(ctx context.Context, target string, input *Message, metadata map[string]interface{}) (map[string]interface{}, error)
DelegateToChild performs a programmatic handoff to a registered child agent and returns the child's final response.
func (*Agent) ExecuteRun ¶
ExecuteRun executes a run synchronously
func (*Agent) ExecuteRunWithRepository ¶
func (a *Agent) ExecuteRunWithRepository(ctx context.Context, run *Run, thread *Thread, userID string, repo interface{}) error
ExecuteRunWithRepository executes a run synchronously and saves messages to repository
func (*Agent) RegisterChild ¶
RegisterChild registers a child agent by name for handoffs
func (*Agent) SetDescription ¶
SetDescription sets the Description for the agent
func (*Agent) SetSystemPrompt ¶
SetSystemPrompt sets the SystemPrompt for the agent
type AgentConfig ¶
type AgentConfig struct {
Model string `json:"model"`
Tools []Tool `json:"tools"`
MaxSteps int `json:"max_steps"`
Temperature float64 `json:"temperature"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
AgentConfig holds configuration for an agent
type Config ¶
type Config struct {
OpenAI OpenAIConfig
}
type LLMClient ¶
type LLMClient struct {
// contains filtered or unexported fields
}
Client represents an LLM client that can generate responses
func (*LLMClient) ExecuteToolCalls ¶
ExecuteToolCalls executes the tool calls in a message
type Message ¶
type Message struct {
Role string `json:"role"` // "user", "assistant", "system", "tool"
Content string `json:"content"`
MultiContent openai.ChatMessagePart `json:"multiContent"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"` // Used for tool messages
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Message represents a message in a conversation
type OpenAIConfig ¶
type Run ¶
type Run struct {
ID string `json:"id"`
ThreadID string `json:"thread_id"`
Status RunStatus `json:"status"`
Tools []Tool `json:"tools"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
}
Run represents an execution of an agent on a thread
type Thread ¶
type Thread struct {
ID string `json:"id"`
Messages []Message `json:"messages"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Thread represents a conversation thread
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]interface{} `json:"parameters"`
Function func(ctx context.Context, params map[string]interface{}) (interface{}, error)
}
Tool represents a function that an agent can use to interact with external systems