Documentation
¶
Index ¶
- Constants
- Variables
- func LogArgs(args am.A) map[string]string
- func MachTelemetry(mach *am.Machine, logArgs am.LogArgsMapperFn)
- func Map[A, B any](vals []A, f func(A) B) []B
- func NumRef(text string) int
- func P(txt string, args ...any)
- func PascalCase(in string) string
- func Pass(args *A) am.A
- func PassRpc(args *A) am.A
- func RemoveStyling(str string) string
- func RevertPascalCase(in string) string
- func Sj(parts ...string) string
- func Sl(txt string, args ...any) string
- func SlicesWithout[S ~[]E, E comparable](coll S, el E) S
- func Sp(txt string, args ...any) string
- type A
- type ARpc
- type Config
- type ConfigAI
- type ConfigAIGemini
- type ConfigAIOpenAI
- type ConfigAgent
- type ConfigAgentHistory
- type ConfigAgentLog
- type ConfigDebug
- type ConfigSearXNG
- type ConfigTUI
- type ConfigTools
- type From
- type Msg
- type OfferRef
- type Story
- type StoryAction
- type StoryActionsByIdx
- type StoryActor
- type StoryImpl
- type StoryInfo
Constants ¶
View Source
const ( // EnvConfig config location EnvConfig = "SECAI_CONFIG" // EnvAgentDir secai monorepo dir EnvAgentDir = "SECAI_AGENT_DIR" EnvNoDotEnv = "SECAI_NO_DOTENV" )
View Source
const APrefix = "secai"
Variables ¶
View Source
var ( FromAssistant = From{"assistant"} FromSystem = From{"system"} FromUser = From{"user"} FromNarrator = From{"narrator"} FromEnum = enum.New(FromAssistant, FromSystem, FromUser) )
Functions ¶
func MachTelemetry ¶
func MachTelemetry(mach *am.Machine, logArgs am.LogArgsMapperFn)
func Map ¶
func Map[A, B any](vals []A, f func(A) B) []B
Map maps vals through f and returns a list of returned values from f.
func NumRef ¶ added in v0.2.0
NumRef returns a number reference from the passed text, or -1 if none found.
func P ¶
P formats and prints the given string after de-denting and trimming it, and returns the number of bytes written and any error.
func PascalCase ¶ added in v0.2.0
PascalCase converts the input string to pascal case, matching the naming convention of state names.
func RemoveStyling ¶ added in v0.2.0
func RevertPascalCase ¶ added in v0.2.0
func SlicesWithout ¶ added in v0.2.0
func SlicesWithout[S ~[]E, E comparable](coll S, el E) S
Types ¶
type A ¶ added in v0.2.0
type A struct {
// ID is a general string ID param.
ID string `log:"id"`
// Addr is a network address.
Addr string `log:"addr"`
// Timeout is a generic timeout.
Timeout time.Duration `log:"timeout"`
// Prompt is a prompt to be sent to LLM.
Prompt string `log:"prompt"`
// IntByTimeout means the interruption was caused by timeout.
IntByTimeout bool `log:"int_by_timeout"`
// Msg is a single message with an author and text.
Msg *Msg `log:"msg"`
// Perform additional checks via LLM
CheckLLM bool `log:"check_llm"`
// List of choices
Choices []string
// Actions are a list of buttons to be displayed in the UI.
Actions []StoryAction `log:"actions"`
Stories []StoryInfo `log:"stories"`
StatesList []string `log:"states_list"`
// ActivateList is a list of booleans for StatesList, indicating an active state at the given index.
ActivateList []bool `log:"activate_list"`
// Result is a buffered channel to be closed by the receiver
Result chan<- am.Result
// DBQuery is a function that executes a query on the database.
DBQuery func(ctx context.Context) error
// RetStr returns dereferenced user prompts based on the list of offer.
RetOfferRef chan<- *OfferRef
SSHServer *ssh.Server
SSHSess ssh.Session
// Done is a buffered channel to be closed by the receiver
Done chan<- struct{}
}
A is a struct for node arguments. It's a typesafe alternative to am.A.
type ARpc ¶ added in v0.2.0
type ARpc struct {
// ID is a general string ID param.
ID string `log:"id"`
// Addr is a network address.
Addr string `log:"addr"`
// Timeout is a generic timeout.
Timeout time.Duration `log:"timeout"`
// Prompt is a prompt to be sent to LLM.
Prompt string `log:"prompt"`
// IntByTimeout means the interruption was caused by timeout.
IntByTimeout bool `log:"int_by_timeout"`
// Msg is a single message with an author and text.
Msg *Msg `log:"msg"`
// Perform additional checks via LLM
CheckLLM bool `log:"check_llm"`
// List of choices
Choices []string
// Buttons are a list of buttons to be displayed in the UI.
Buttons []StoryAction `log:"buttons"`
Stories []StoryInfo `log:"stories"`
StatesList []string `log:"states_list"`
ActivateList []bool `log:"activate_list"`
Result am.Result
}
ARpc is a subset of am.A that can be passed over RPC.
type Config ¶ added in v0.4.0
type Config struct {
AI ConfigAI
Agent ConfigAgent
TUI ConfigTUI
Tools ConfigTools
Debug ConfigDebug
}
func ConfigDefault ¶ added in v0.4.0
func ConfigDefault() Config
type ConfigAI ¶ added in v0.4.0
type ConfigAI struct {
OpenAI []ConfigAIOpenAI `kdl:"OpenAI,multiple"`
Gemini []ConfigAIGemini `kdl:"Gemini,multiple"`
// Max LLM requests per session.
ReqLimit int
}
type ConfigAIGemini ¶ added in v0.4.0
func ConfigDefaultGemini ¶ added in v0.4.0
func ConfigDefaultGemini() ConfigAIGemini
type ConfigAIOpenAI ¶ added in v0.4.0
type ConfigAIOpenAI struct {
Key string
Disabled bool
URL string
Model string
Tags []string
Retries int
}
func ConfigDefaultOpenAI ¶ added in v0.4.0
func ConfigDefaultOpenAI() ConfigAIOpenAI
type ConfigAgent ¶ added in v0.4.0
type ConfigAgent struct {
// bot ID
ID string
Label string
// // dir for tmp files, defaults to CWD
Dir string
Intro string
Log ConfigAgentLog
History ConfigAgentHistory
}
type ConfigAgentHistory ¶ added in v0.4.0
type ConfigAgentLog ¶ added in v0.4.0
type ConfigDebug ¶ added in v0.4.0
type ConfigDebug struct {
// display extra info about these stories in the machine log
Story []string `kdl:",multiple"`
// Run the mock scenarios (if any)
Mock bool
// Enable misc debugging modes (eg SQL history)
Misc bool
// Enable REPL for each machine
REPL bool
// Enable debugging in am-dbg ("1" expands to default). am-dbg has to be started BEFORE the bot.
DBGAddr string
}
type ConfigSearXNG ¶ added in v0.4.0
type ConfigTools ¶ added in v0.4.0
type ConfigTools struct {
SearXNG ConfigSearXNG
}
type Story ¶ added in v0.2.0
type Story[G any] struct { StoryInfo // If is an optional function used to confirm that this story can activate. It has access to the whole story struct, // so all the involved state machines and their historical snapshots (relative to activation and deactivation of // this story). CanActivate func(s *G) bool }
type StoryAction ¶ added in v0.4.0
type StoryAction struct {
// Current value.
Value func() int
// Maximum value.
ValueEnd func() int
Label string
Desc string
StateAdd string
StateRemove string
VisibleCook amhelp.Cond
VisibleMem amhelp.Cond
Action func()
IsDisabled func() bool
LabelEnd string
Pos int
PosInferred bool
}
func (StoryAction) String ¶ added in v0.4.0
func (s StoryAction) String() string
type StoryActionsByIdx ¶ added in v0.4.0
type StoryActionsByIdx []StoryAction
func (StoryActionsByIdx) Len ¶ added in v0.4.0
func (s StoryActionsByIdx) Len() int
func (StoryActionsByIdx) Less ¶ added in v0.4.0
func (s StoryActionsByIdx) Less(i, j int) bool
func (StoryActionsByIdx) Swap ¶ added in v0.4.0
func (s StoryActionsByIdx) Swap(i, j int)
type StoryActor ¶ added in v0.2.0
type StoryActor struct {
Mach *am.Machine
// actor's time when the story activated
TimeActivated am.Time
TimeDeactivated am.Time
// When these conditions are met, the story will activate itself.
Trigger amhelp.Cond
}
StoryActor is a binding between a Story and an actor (state machine).
type StoryInfo ¶ added in v0.2.0
type StoryInfo struct {
// Name of the bound state (eg StoryFoo).
State string
// Tick is the current tick of the bound state.
Tick uint64
// Epoch is the sum of all previous memories, before a replacement.
Epoch uint64
// Title of this story.
Title string
// Description of this story.
Desc string
// The story was last deactivated at this human time.
DeactivatedAt time.Time
// The story was last active for this many ticks of the AgentLLM machine.
LastActiveTicks uint64
}
Click to show internal directories.
Click to hide internal directories.