Documentation
¶
Index ¶
- type AIAgent
- type Config
- type NPCAgent
- func (agent *NPCAgent) Completion(ctx context.Context, config Config, userMessage string) (string, error)
- func (agent *NPCAgent) CompletionWithSimilaritySearch(ctx context.Context, config Config, userMessage string) (string, error)
- func (agent *NPCAgent) DetectAndExecuteToolCalls(ctx context.Context, config Config, userMessage string) (*ToolCallsResult, error)
- func (agent *NPCAgent) DetectAndExecuteToolCallsWithConfirmation(ctx context.Context, config Config, userMessage string) (*ToolCallsResult, error)
- func (agent *NPCAgent) DirectExecuteTool(ctx context.Context, config Config, req *ai.ToolRequest) (string, error)
- func (agent *NPCAgent) DisplayHistory()
- func (agent *NPCAgent) GetHistory() []*ai.Message
- func (agent *NPCAgent) Initialize(ctx context.Context, config Config, name string)
- func (agent *NPCAgent) InitializeVectorStoreFromFile(ctx context.Context, config Config, backgroundContextPath string) error
- func (agent *NPCAgent) JsonCompletion(ctx context.Context, config Config, outputType any, userMessage string) (string, error)
- func (agent *NPCAgent) JsonStreamCompletion(ctx context.Context, config Config, outputType any, userMessage string, ...) (string, error)
- func (agent *NPCAgent) LoopCompletion(ctx context.Context, config Config)
- func (agent *NPCAgent) QuickInitialization()
- func (agent *NPCAgent) ResetMessages()
- func (agent *NPCAgent) SetSystemInstructions(systemInstructions string)
- func (agent *NPCAgent) SetSystemInstructionsFromFile(systemInstructionsPath string) error
- func (agent *NPCAgent) SimilaritySearch(ctx context.Context, config Config, userMessage string) (string, error)
- func (agent *NPCAgent) StreamCompletion(ctx context.Context, config Config, userMessage string, ...) (string, error)
- func (agent *NPCAgent) StreamCompletionWithSimilaritySearch(ctx context.Context, config Config, userMessage string, ...) (string, error)
- type ToolCallsResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIAgent ¶
type AIAgent interface {
//GetName() string
Initialize(ctx context.Context, config Config, name string)
QuickInitialization()
SetSystemInstructionsFromFile(systemInstructionsPath string) error
SetSystemInstructions(systemInstructions string)
InitializeVectorStoreFromFile(ctx context.Context, config Config, backgroundContextPath string) error
Completion(ctx context.Context, config Config, userMessage string) (string, error)
JsonCompletion(ctx context.Context, config Config, outputType any, userMessage string) (string, error)
SimilaritySearch(ctx context.Context, config Config, userMessage string) (string, error)
CompletionWithSimilaritySearch(ctx context.Context, config Config, userMessage string) (string, error)
StreamCompletion(ctx context.Context, config Config, userMessage string, callback ai.ModelStreamCallback) (string, error)
StreamCompletionWithSimilaritySearch(ctx context.Context, config Config, userMessage string, callback ai.ModelStreamCallback) (string, error)
DetectAndExecuteToolCalls(ctx context.Context, config Config, userMessage string) (*ToolCallsResult, error)
DetectAndExecuteToolCallsWithConfirmation(ctx context.Context, config Config, userMessage string) (*ToolCallsResult, error)
ResetMessages()
GetHistory() []*ai.Message
DisplayHistory()
LoopCompletion(ctx context.Context, config Config)
DirectExecuteTool(ctx context.Context, config Config, req *ai.ToolRequest) (string, error)
}
type NPCAgent ¶
type NPCAgent struct {
Name string
// contains filtered or unexported fields
}
IMPORTANT: the conversation history is automatically managed TODO: add methods to clear history, export history, import history, etc.
func (*NPCAgent) Completion ¶
func (*NPCAgent) CompletionWithSimilaritySearch ¶
func (*NPCAgent) DetectAndExecuteToolCalls ¶
func (agent *NPCAgent) DetectAndExecuteToolCalls(ctx context.Context, config Config, userMessage string) (*ToolCallsResult, error)
DetectAndExecuteToolCalls detects and executes tool calls automatically (no confirmation)
Flow:
┌──────────────────────────────┐
│ DetectAndExecuteToolCalls │
└──────────────┬───────────────┘
│
│ Creates executor lambda
│ that calls executeTool
│
▼
┌──────────────────────────────┐
│detectAndExecuteToolCallsLoop │
└──────────────┬───────────────┘
│
│ For each tool request,
│ calls executor
│
▼
┌──────────────────────────────┐
│ executeTool │
│ (automatic execution) │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ tool.RunRaw() │
│ Append result to history │
└──────────────────────────────┘
func (*NPCAgent) DetectAndExecuteToolCallsWithConfirmation ¶
func (agent *NPCAgent) DetectAndExecuteToolCallsWithConfirmation(ctx context.Context, config Config, userMessage string) (*ToolCallsResult, error)
DetectAndExecuteToolCallsWithConfirmation detects and executes tool calls with user confirmation
Flow:
┌──────────────────────────────┐
│DetectAndExecuteToolCalls │
│WithConfirmation │
└──────────────┬───────────────┘
│
│ Passes executeToolWithConfirmation
│ as executor
│
▼
┌──────────────────────────────┐
│detectAndExecuteToolCallsLoop │
└──────────────┬───────────────┘
│
│ For each tool request,
│ calls executor
│
▼
���──────────────────────────────┐
│executeToolWithConfirmation │
└──────────────┬───────────────┘
│
│ Ask user: y/n/q?
│
┌──────────┼──────────┐
│ │ │
▼ ▼ ▼
┌───┐ ┌───┐ ┌───┐
│ y │ │ n │ │ q │
└─┬─┘ └─┬─┘ └─┬─┘
│ │ │
│ │ └──► Set stopped=true
│ │
│ └──► Append "cancelled" to history
│
└──► Call executeTool()
func (*NPCAgent) DirectExecuteTool ¶
func (agent *NPCAgent) DirectExecuteTool(ctx context.Context, config Config, req *ai.ToolRequest) (string, error)
IMPORTANT: [TODO]
func (*NPCAgent) DisplayHistory ¶
func (agent *NPCAgent) DisplayHistory()
func (*NPCAgent) GetHistory ¶
func (*NPCAgent) Initialize ¶
func (*NPCAgent) InitializeVectorStoreFromFile ¶
func (*NPCAgent) JsonCompletion ¶
func (*NPCAgent) JsonStreamCompletion ¶
func (*NPCAgent) LoopCompletion ¶
func (*NPCAgent) QuickInitialization ¶
func (agent *NPCAgent) QuickInitialization()
func (*NPCAgent) ResetMessages ¶
func (agent *NPCAgent) ResetMessages()
func (*NPCAgent) SetSystemInstructions ¶
func (*NPCAgent) SetSystemInstructionsFromFile ¶
func (*NPCAgent) SimilaritySearch ¶
func (*NPCAgent) StreamCompletion ¶
Click to show internal directories.
Click to hide internal directories.