Documentation
¶
Index ¶
- Variables
- func ParseMails[T any](body string) (ms []T, err error)
- type AIrunner
- type Agent
- type AgentMailBox
- type Chat
- type ChatMessage
- type Mail
- type MailBox
- func (mb *MailBox) Add(mails []Mail, addAll bool, defaultAgentName string)
- func (mb *MailBox) Get(filename string) (mails []Mail)
- func (mb MailBox) GetSolved() (res string)
- func (mb MailBox) GetThreads(agent string) (mails string)
- func (mb MailBox) Save(filename string)
- func (mb MailBox) String() string
- type MailBoxPermission
- type MailDirection
- type MailNetwork
- type Ollama
- type Prompt
- type Provider
- type RouterAI
- type ShortMessage
Constants ¶
This section is empty.
Variables ¶
var ( MailBoxFile = "mailbox.out" // Filename for default mailbox storage ReloadMailbox bool // Whether to reload mailbox from file on startup )
Global configuration variables
var (
DebugAgentOutput = true
)
TODO
var MaxAgentIterations = 10
Functions ¶
func ParseMails ¶
ParseMails extracts Mail objects from AI response text body: AI response string, may contain JSON arrays, single JSON objects, or code blocks Returns: slice of valid Mail objects and any parsing error
Types ¶
type AIrunner ¶
type AIrunner interface {
// GetContextSize return context size
GetContextSize() int
GetModels() (string, error)
Send(chs []ChatMessage, isChat bool) (repsonce string, err error)
}
AIrunner defines the interface for AI providers Implementations must handle AI model interactions
type AgentMailBox ¶
type AgentMailBox struct {
// contains filtered or unexported fields
}
func NewAgentMailBox ¶
func NewAgentMailBox(prv AIrunner, name string, role Prompt, mb *MailBox, mp MailBoxPermission) *AgentMailBox
func (*AgentMailBox) AddSystem ¶
func (a *AgentMailBox) AddSystem(system ...string)
func (*AgentMailBox) Init ¶
func (a *AgentMailBox) Init()
func (*AgentMailBox) Run ¶
func (a *AgentMailBox) Run() (err error)
func (AgentMailBox) String ¶
func (a AgentMailBox) String() string
type ChatMessage ¶
type ChatMessage struct {
Role string `json:"role"` // "user", "assistant", or "system"
Content string `json:"content"` // Message content
}
ChatMessage represents a single message in chat conversation
type Mail ¶
type Mail struct {
// ID is unique position in mailbox
ID int `json:"id"`
From string `json:"from"`
To string `json:"to"`
Body string `json:"body"`
Archived bool `json:"archived"`
Solved bool `json:"solved"` // TODO remove
Next []string `json:"next"` // TODO add implementation
ReplyID int // -1 for new threads, ID of parent mail for replies
}
Mail represents an email message between agents Valid ranges:
- ID: positive integer, unique identifier
- From: non-empty string (sender)
- To: non-empty string (recipient)
- Body: string content
- Archived: boolean flag
- Solved: boolean flag
- Next: list of agents sorted by priority
- ReplyID: -1 for new threads, positive for replies
type MailBox ¶
type MailBox struct {
// contains filtered or unexported fields
}
MailBox manages a collection of mail messages with thread support
func (*MailBox) Add ¶
Add adds new mails to the mailbox, assigning IDs and managing threads mails: slice of Mail objects to add
func (*MailBox) Get ¶
Get loads mails from a JSON file filename: path to JSON file containing mail data
func (MailBox) GetSolved ¶
GetSolved returns formatted solved mails Returns: concatenated JSON representations of solved mails
func (MailBox) GetThreads ¶
GetThreads returns formatted mail threads for a specific agent or all agents agent: agent name to filter threads for, empty string returns all threads Returns: formatted string with mail threads in JSON code blocks
type MailBoxPermission ¶
type MailBoxPermission struct {
Read MailDirection
Send MailDirection
Archived MailDirection
Solved MailDirection
}
func DefaultMailPermission ¶
func DefaultMailPermission() MailBoxPermission
func (MailBoxPermission) String ¶
func (mp MailBoxPermission) String() string
type MailDirection ¶
type MailNetwork ¶
type MailNetwork struct {
// contains filtered or unexported fields
}
MailNetwork manages connections between agents and coordinates their execution Valid ranges:
- Agents: non-empty slice of Agent structs
- Links: 2D slice where each inner slice represents a fully connected group
func NewMailNetwork ¶
func NewMailNetwork(ai AIrunner) *MailNetwork
func (*MailNetwork) AddAgent ¶
func (an *MailNetwork) AddAgent(filename string, mp MailBoxPermission)
AddAgent loads an agent definition from file and adds it to the network filename: path to agent definition file (e.g., "agent/dreamer.md") The agent name is derived from the filename without extension
func (*MailNetwork) AddLinks ¶
func (an *MailNetwork) AddLinks(links []string)
func (*MailNetwork) AddSystem ¶
func (an *MailNetwork) AddSystem(system ...string)
func (*MailNetwork) Run ¶
func (an *MailNetwork) Run(MaxIterations int) (err error)
Run executes the agent network with given input task input: global task description string, must be non-empty Returns: aggregated output from all agents or error
type Ollama ¶
type Ollama Provider
Ollama is an AI provider implementation for Ollama API It embeds Provider configuration and implements AIrunner interface
func (Ollama) GetContextSize ¶
func (Ollama) Send ¶
func (o Ollama) Send(messages []ChatMessage, isChat bool) (repsonce string, err error)
In documentation: To generate a response using the generate endpoint, send a POST request with a JSON body specifying the model and prompt: ```bash
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1",
"prompt": "Why is the sky blue?"
}'
```
For a chat-based interaction using the /api/chat endpoint: ```bash
curl http://localhost:11434/api/chat -d '{
"model": "llama3.1",
"messages": [
{ "role": "user", "content": "Why is the sky blue?" }
]
}'
```
type Prompt ¶
type Prompt string
Prompt represents a text prompt for AI agents
const ( ContinueDisscussion Prompt = "Продолжай. Дополни." FinishDisscussion Prompt = "Пока писать нечего и работа агента закончена" )
TODO
var ConflictPrompt Prompt
ConflictPrompt contains the prompt template for conflict solving
var MailBoxPrompt Prompt
MailBoxPrompt contains the prompt template for email generation
type Provider ¶
type Provider struct {
Model string // AI model name, e.g., "llama3.1", "gpt-4"
Endpoint string // API endpoint URL, e.g., "http://localhost:11434/api/"
Key string // API key for external providers (optional)
ContextSize int // Maximum context window size in tokens
RequestTimeout time.Duration // Timeout for HTTP requests
}
Provider represents configuration for AI model provider Valid ranges:
- Model: non-empty string
- Endpoint: valid URL format, non-empty
- Key: optional API key, can be empty for local providers
- ContextSize: positive integer, typically 1000-200000
- RequestTimeout: positive duration, typically 1m-24h
- KeepAlive: duration string like "5m", "1h", "24h", or "-1" for infinite
type RouterAI ¶
type RouterAI Provider
RouterAI is an AI provider implementation for RouterAI API It embeds Provider configuration and implements AIrunner interface RouterAI is a unified API gateway for accessing OpenAI, Anthropic, Google and other providers
func (RouterAI) GetContextSize ¶
type ShortMessage ¶
type ShortMessage struct {
ID int `json:"id"`
From string `json:"from"`
To string `json:"to"`
Body string `json:"body"`
}
ShortMessage represents a simplified mail structure for display Valid ranges:
- From: non-empty string (sender agent name)
- To: non-empty string (recipient agent name)
- Body: string content, can be empty but not recommended
func (ShortMessage) String ¶
func (s ShortMessage) String() string
String returns JSON representation of ShortMessage