agents

package
v0.2.14 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentOption

type AgentOption func(*ChatAgent) error

AgentOption configures the ChatAgent

func WithMemoryContext

func WithMemoryContext() AgentOption

WithMemoryContext enables automatic memory inclusion in system prompts

func WithMemoryPersistence

func WithMemoryPersistence(filepath string) AgentOption

WithMemoryPersistence enables automatic memory saving/loading

func WithMemoryTools

func WithMemoryTools() AgentOption

WithMemoryTools enables memory tools (remember_fact, recall_fact)

type ChatAgent

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

ChatAgent maintains conversation state and handles tool execution

func New

func New(apiKey string, opts ...AgentOption) (*ChatAgent, error)

New creates a new ChatAgent with optional configuration

func (*ChatAgent) Chat

func (ca *ChatAgent) Chat(message string, opts ...*ChatOptions) (*ChatResponse, error)

Chat sends a message and handles tool execution automatically

func (*ChatAgent) ClearMemory

func (ca *ChatAgent) ClearMemory() error

ClearMemory removes all keys from persistent memory

func (*ChatAgent) Forget

func (ca *ChatAgent) Forget(key string) error

Forget removes a key from persistent memory

func (*ChatAgent) GetMemory

func (ca *ChatAgent) GetMemory() map[string]string

GetMemory returns a copy of all memory key-value pairs

func (*ChatAgent) Recall

func (ca *ChatAgent) Recall(key string) (string, bool)

Recall retrieves a value from persistent memory

func (*ChatAgent) RegisterTool

func (ca *ChatAgent) RegisterTool(tool types.Tool) error

RegisterTool adds a tool that GPT can use

func (*ChatAgent) Remember

func (ca *ChatAgent) Remember(key, value string) error

Remember stores a key-value pair in persistent memory

func (*ChatAgent) Reset

func (ca *ChatAgent) Reset(clearMemory bool) error

Reset clears conversation history and optionally persistent memory

type ChatOptions

type ChatOptions struct {
	Schema       string                     // JSON schema for structured output
	SystemPrompt string                     // System prompt for this specific message
	Temperature  float64                    // Temperature for response randomness (0.0-1.0, -1 = use default)
	MaxTokens    int                        // Maximum tokens in response (0 = omit from request)
	Files        []types.FileUploadResponse // File attachments to include in the message
}

ChatOptions provides optional parameters for chat requests

type ChatResponse

type ChatResponse struct {
	Text string          // Extracted text response
	Raw  *types.Response // Full API response
}

ChatResponse contains both extracted text and full raw response

type MemoryMode

type MemoryMode int

MemoryMode controls memory behavior using bitwise flags

const (
	MemoryDisabled    MemoryMode = 0
	MemoryContext     MemoryMode = 1 << 0 // Auto-include in system prompts
	MemoryTools       MemoryMode = 1 << 1 // Expose remember/recall as tools
	MemoryPersistence MemoryMode = 1 << 2 // Auto-save to disk
)

Jump to

Keyboard shortcuts

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