creative

package module
v0.0.0-...-e6e9530 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 15 Imported by: 0

README

creative

ollama agent ai on russian

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MailBoxFile   = "mailbox.out" // Filename for default mailbox storage
	ReloadMailbox bool            // Whether to reload mailbox from file on startup
)

Global configuration variables

View Source
var (
	DebugAgentOutput = true
)

TODO

View Source
var MaxAgentIterations = 10

Functions

func ParseMails

func ParseMails[T any](body string) (ms []T, err error)

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 Agent

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

func NewAgent

func NewAgent(prv AIrunner, name string, role Prompt) *Agent

func (*Agent) AddSystem

func (a *Agent) AddSystem(system ...string)

func (*Agent) Init

func (a *Agent) Init()

func (*Agent) Reset

func (a *Agent) Reset()

func (*Agent) Send

func (a *Agent) Send(input string) (responce string, err error)

func (Agent) String

func (a Agent) String() string

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 Chat

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

func NewChat

func NewChat(prv AIrunner) *Chat

func (*Chat) AddSystem

func (ch *Chat) AddSystem(system ...string)

func (*Chat) Send

func (ch *Chat) Send(agentName, input string, isChat bool) (responce string, err error)

func (Chat) String

func (ch Chat) 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

func (Mail) String

func (m Mail) String() string

String returns JSON representation of Mail

type MailBox

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

MailBox manages a collection of mail messages with thread support

func (*MailBox) Add

func (mb *MailBox) Add(mails []Mail, addAll bool, defaultAgentName string)

Add adds new mails to the mailbox, assigning IDs and managing threads mails: slice of Mail objects to add

func (*MailBox) Get

func (mb *MailBox) Get(filename string) (mails []Mail)

Get loads mails from a JSON file filename: path to JSON file containing mail data

func (MailBox) GetSolved

func (mb MailBox) GetSolved() (res string)

GetSolved returns formatted solved mails Returns: concatenated JSON representations of solved mails

func (MailBox) GetThreads

func (mb MailBox) GetThreads(agent string) (mails string)

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

func (MailBox) Save

func (mb MailBox) Save(filename string)

Save writes all mails to a JSON file filename: path to save JSON file

func (MailBox) String

func (mb MailBox) String() string

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 MailDirection struct {
	Self  bool
	Other bool
}

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 (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 (pr Ollama) GetContextSize() int

func (Ollama) GetModels

func (o Ollama) GetModels() (out string, err error)

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

func (pr RouterAI) GetContextSize() int

func (RouterAI) GetModels

func (o RouterAI) GetModels() (out string, err error)

func (RouterAI) Send

func (o RouterAI) Send(messages []ChatMessage, isChat bool) (repsonce string, err error)

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 Convert

func Convert(m Mail) ShortMessage

Convert transforms a Mail to ShortMessage format

func (ShortMessage) String

func (s ShortMessage) String() string

String returns JSON representation of ShortMessage

Jump to

Keyboard shortcuts

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