Documentation
¶
Index ¶
- Constants
- func CosineSimilarity(vec1, vec2 []float32) float64
- func GenerateStringIdentifier(prefix string, length int) (string, error)
- func MonotonicIdGenerator(prefix string) func() string
- type AnnotatedMessage
- type AnnotatedMessages
- func (a AnnotatedMessages) AddTraceInformation(name string)
- func (a AnnotatedMessages) ChatCompletionMessages() (m []llm.ChatCompletionMessage)
- func (a AnnotatedMessages) FlattenedAnnotations() map[string]Annotation
- func (a AnnotatedMessages) GetAnnotation(name string) *Annotation
- func (a AnnotatedMessages) LastMessage() *AnnotatedMessage
- type Annotation
- type AnnotationTemplate
- type Behavior
- type BehaviorRef
- type BehaviorState
- type BehaviorTree
- func (b *BehaviorTree) AddState(s Behavior)
- func (b *BehaviorTree) AddTransition(from, to Behavior)
- func (b *BehaviorTree) Call(ctx context.Context, history AnnotatedMessages) (AnnotatedMessages, Signal)
- func (b *BehaviorTree) Copy() Behavior
- func (b *BehaviorTree) Description() string
- func (b *BehaviorTree) Hash() string
- func (b *BehaviorTree) Name() string
- type Channel
- type ChannelMessage
- type Chunk
- type ChunkingStrategy
- type CollectUserInputSignal
- type ErrorSignal
- type ExecGeneratedStep
- type ExecGeneratedStepSkeleton
- type Graph
- type Hashable
- type LLMCompletionOptions
- type MCPClientMux
- func (m *MCPClientMux) AddInMemoryServer(ctx context.Context, transport mcp.Transport) error
- func (m *MCPClientMux) AddProfilesOfType(t string, profiles []MCPProfile) error
- func (m *MCPClientMux) AddSSEServer(ctx context.Context, baseURL string) error
- func (m *MCPClientMux) CallTool(ctx context.Context, params *mcp.CallToolParams) (*mcp.CallToolResult, error)
- func (m *MCPClientMux) Close() error
- func (m *MCPClientMux) Tools() []llm.ChatTool
- type MCPProfile
- type MCPServer
- type MemoryChunk
- type MemoryStore
- func (m *MemoryStore) CreateMemoryBankIfNotExists(name string) error
- func (m *MemoryStore) Recall(ctx context.Context, bank, query, prefix string) ([]MemoryChunk, error)
- func (m *MemoryStore) Store(ctx context.Context, bank string, chunk string, metadata string) error
- func (m *MemoryStore) StoreBatch(ctx context.Context, bank string, chunks []string, metadatas []string) error
- type PlanResult
- type SemanticChunker
- type Signal
- type SkipSignal
- type Snapshot
- type Stack
- type TerminalChannel
- type TerminalSignal
- type TodoListExecutive
- func (e *TodoListExecutive) Call(ctx context.Context, messages AnnotatedMessages) (AnnotatedMessages, Signal)
- func (e *TodoListExecutive) Copy() Behavior
- func (e *TodoListExecutive) Description() string
- func (e *TodoListExecutive) Execute(ctx context.Context, messages AnnotatedMessages)
- func (e *TodoListExecutive) Hash() string
- func (e *TodoListExecutive) Name() string
- func (e *TodoListExecutive) Plan(messages AnnotatedMessages)
- func (e *TodoListExecutive) RunLoop(c Channel) error
- type Trace
- type TraceHistoryOperation
- type TraceMessage
- type TraceSignal
- type TraceTelemetry
- type TwilioSMSChannel
Constants ¶
const ( ProfileTypeEmulator = "emulator" ProfileTypeChat = "chat" ProfileTypeEmbedded = "embedded" )
const ( MCPServerTypeSSE = "sse" MCPServerTypeMemory = "mem" MCPServerTypeCommand = "cmd" )
const ( StateErrorTypeUnknown = "unknown" StateErrorTypeRetryable = "retryable" StateErrorTypeUnrecoverable = "unrecoverable" StateErrorTypeLuaSyntax = "lua_syntax" )
const ( TraceMessageTypeLuaSource = "lua_source" TraceMessageTypeCallBegin = "begin_call" TraceMessageTypeCallEnd = "end_call" )
const (
DefaultMaxPlanDepth = 3
)
Variables ¶
This section is empty.
Functions ¶
func CosineSimilarity ¶
func GenerateStringIdentifier ¶
GenerateStringIdentifier generates a random string of a given length and prefix.
func MonotonicIdGenerator ¶
Types ¶
type AnnotatedMessage ¶
type AnnotatedMessage struct {
llm.ChatCompletionMessage
Annotations map[string]Annotation
}
type AnnotatedMessages ¶
type AnnotatedMessages []AnnotatedMessage
func AppendToMessages ¶
func AppendToMessages(messages AnnotatedMessages, message llm.ChatCompletionMessage) AnnotatedMessages
func (AnnotatedMessages) AddTraceInformation ¶
func (a AnnotatedMessages) AddTraceInformation(name string)
func (AnnotatedMessages) ChatCompletionMessages ¶
func (a AnnotatedMessages) ChatCompletionMessages() (m []llm.ChatCompletionMessage)
func (AnnotatedMessages) FlattenedAnnotations ¶
func (a AnnotatedMessages) FlattenedAnnotations() map[string]Annotation
func (AnnotatedMessages) GetAnnotation ¶
func (a AnnotatedMessages) GetAnnotation(name string) *Annotation
func (AnnotatedMessages) LastMessage ¶
func (a AnnotatedMessages) LastMessage() *AnnotatedMessage
type Annotation ¶
type AnnotationTemplate ¶
type AnnotationTemplate struct {
// contains filtered or unexported fields
}
func (*AnnotationTemplate) Execute ¶
func (a *AnnotationTemplate) Execute(wr io.Writer, messages AnnotatedMessages) error
func (*AnnotationTemplate) Parse ¶
func (a *AnnotationTemplate) Parse(text string) (*AnnotationTemplate, error)
type Behavior ¶
type Behavior interface {
Hashable
Name() string
Description() string
Call(ctx context.Context, messages AnnotatedMessages) (AnnotatedMessages, Signal)
Copy() Behavior
}
type BehaviorRef ¶
type BehaviorRef string
type BehaviorState ¶
type BehaviorState struct {
StateName string
StateDescription string
HashId string
ClientID string
Lambda func(ctx context.Context, history AnnotatedMessages) (AnnotatedMessages, Signal)
}
func CannedResponseState ¶
func CannedResponseState(message string) *BehaviorState
func LLMCompletionState ¶
func LLMCompletionState(options LLMCompletionOptions) BehaviorState
func PauseState ¶
func PauseState(reason string) BehaviorState
func (*BehaviorState) Call ¶
func (b *BehaviorState) Call(ctx context.Context, history AnnotatedMessages) (AnnotatedMessages, Signal)
func (*BehaviorState) Copy ¶
func (b *BehaviorState) Copy() Behavior
func (*BehaviorState) Description ¶
func (b *BehaviorState) Description() string
func (*BehaviorState) Hash ¶
func (b *BehaviorState) Hash() string
func (*BehaviorState) Name ¶
func (b *BehaviorState) Name() string
type BehaviorTree ¶
type BehaviorTree struct {
BehaviorName string `json:"name"`
BehaviorDescription string `json:"description"`
Example string `json:"example"`
Graph Graph[Behavior] `json:"graph"`
State Stack[Behavior] `json:"state"`
Traversed map[string]bool `json:"traversed"`
ClientID string `json:"client_id"`
// contains filtered or unexported fields
}
func CreateBehaviorTree ¶
func CreateBehaviorTree(name, description, example string) BehaviorTree
func CreateBehaviorTreeWithId ¶
func CreateBehaviorTreeWithId(name, description, example, id string) BehaviorTree
func (*BehaviorTree) AddState ¶
func (b *BehaviorTree) AddState(s Behavior)
func (*BehaviorTree) AddTransition ¶
func (b *BehaviorTree) AddTransition(from, to Behavior)
func (*BehaviorTree) Call ¶
func (b *BehaviorTree) Call(ctx context.Context, history AnnotatedMessages) (AnnotatedMessages, Signal)
func (*BehaviorTree) Copy ¶
func (b *BehaviorTree) Copy() Behavior
func (*BehaviorTree) Description ¶
func (b *BehaviorTree) Description() string
func (*BehaviorTree) Hash ¶
func (b *BehaviorTree) Hash() string
func (*BehaviorTree) Name ¶
func (b *BehaviorTree) Name() string
type Channel ¶
type Channel interface {
AllocateID() string
Send(*ChannelMessage) error
Receive() (*ChannelMessage, error)
}
type ChannelMessage ¶
type ChunkingStrategy ¶
type CollectUserInputSignal ¶
type CollectUserInputSignal struct {
Reason string
}
CollectUserInputSignal signals that we must pause the current execution context, gather user input, and then resume.
func (CollectUserInputSignal) Description ¶
func (c CollectUserInputSignal) Description() string
type ErrorSignal ¶
An ErrorSignal signals that an error occurred. This will bubble out all the way up the call stack, and aborts any further behavior execution
func (ErrorSignal) Description ¶
func (e ErrorSignal) Description() string
func (ErrorSignal) Error ¶
func (e ErrorSignal) Error() string
func (ErrorSignal) Type ¶
func (e ErrorSignal) Type() string
type ExecGeneratedStep ¶
type ExecGeneratedStep struct {
Behavior Behavior
Messages AnnotatedMessages
ReplanTombstone bool
}
type ExecGeneratedStepSkeleton ¶
type ExecGeneratedStepSkeleton struct {
Ref string `json:"ref"`
Snapshot Snapshot `json:"snapshot"`
Messages AnnotatedMessages `json:"messages"`
ReplanTombstone bool `json:"replan_tombstone"`
}
type Graph ¶
type Graph[T Hashable] struct { Transitions [][]int `json:"transitions"` Nodes []T `json:"nodes"` // contains filtered or unexported fields }
func (*Graph[T]) AddTransition ¶
func (g *Graph[T]) AddTransition(from, to T)
type LLMCompletionOptions ¶
type MCPClientMux ¶
type MCPClientMux struct {
// contains filtered or unexported fields
}
func NewMCPClientMux ¶
func NewMCPClientMux() *MCPClientMux
func (*MCPClientMux) AddInMemoryServer ¶
func (*MCPClientMux) AddProfilesOfType ¶
func (m *MCPClientMux) AddProfilesOfType(t string, profiles []MCPProfile) error
func (*MCPClientMux) AddSSEServer ¶
func (m *MCPClientMux) AddSSEServer(ctx context.Context, baseURL string) error
func (*MCPClientMux) CallTool ¶
func (m *MCPClientMux) CallTool(ctx context.Context, params *mcp.CallToolParams) (*mcp.CallToolResult, error)
func (*MCPClientMux) Close ¶
func (m *MCPClientMux) Close() error
func (*MCPClientMux) Tools ¶
func (m *MCPClientMux) Tools() []llm.ChatTool
type MCPProfile ¶
func ProfilesForArtifact ¶
func ProfilesForArtifact(artifact []byte) ([]MCPProfile, error)
type MemoryChunk ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func CreateMemoryStore ¶
func CreateMemoryStore(db *sqlite3.Conn, provider llm.ModelProvider) *MemoryStore
func (*MemoryStore) CreateMemoryBankIfNotExists ¶
func (m *MemoryStore) CreateMemoryBankIfNotExists(name string) error
func (*MemoryStore) Recall ¶
func (m *MemoryStore) Recall(ctx context.Context, bank, query, prefix string) ([]MemoryChunk, error)
func (*MemoryStore) StoreBatch ¶
type PlanResult ¶
type PlanResult struct {
Messages AnnotatedMessages `json:"messages"`
Step *ExecGeneratedStep `json:"step"`
Signal Signal `json:"signal"`
}
type SemanticChunker ¶
type SemanticChunker struct {
Threshold float64
// contains filtered or unexported fields
}
func NewSemanticChunker ¶
func NewSemanticChunker(m llm.ModelProvider) *SemanticChunker
type Signal ¶
type Signal interface {
Description() string
}
The Signal interface is Arboreal's method of controlling execution flow.
type SkipSignal ¶
type SkipSignal struct {
Reason string
}
SkipSignal is only relevant to executing a BehaviorTree, and signals that the current branch should be skipped and execution should proceed to the next branch.
func (SkipSignal) Description ¶
func (c SkipSignal) Description() string
type TerminalChannel ¶
type TerminalChannel struct{}
func (TerminalChannel) AllocateID ¶
func (TerminalChannel) AllocateID() string
func (TerminalChannel) Receive ¶
func (TerminalChannel) Receive() (*ChannelMessage, error)
func (TerminalChannel) Send ¶
func (TerminalChannel) Send(m *ChannelMessage) error
type TerminalSignal ¶
type TerminalSignal struct {
Reason string
}
TerminalSignal signals that the current execution context should be terminated. Execution will flow back out to the parent.
func (*TerminalSignal) Description ¶
func (c *TerminalSignal) Description() string
type TodoListExecutive ¶
type TodoListExecutive struct {
ExecName string
ExecDescription string
Preamble string
Behaviors []Behavior
OutOfBoundsHandler Behavior
MaxPlanDepth int
History AnnotatedMessages
ClientID string
// FIXME: This shouldn't work this way
Output string
// contains filtered or unexported fields
}
func CreateTodoListExecutive ¶
func CreateTodoListExecutive(name, description string, behaviors ...Behavior) *TodoListExecutive
func CreateTodoListExecutiveWithId ¶
func CreateTodoListExecutiveWithId(name, description, id string, behaviors ...Behavior) *TodoListExecutive
func (*TodoListExecutive) Call ¶
func (e *TodoListExecutive) Call(ctx context.Context, messages AnnotatedMessages) (AnnotatedMessages, Signal)
func (*TodoListExecutive) Copy ¶
func (e *TodoListExecutive) Copy() Behavior
func (*TodoListExecutive) Description ¶
func (e *TodoListExecutive) Description() string
func (*TodoListExecutive) Execute ¶
func (e *TodoListExecutive) Execute(ctx context.Context, messages AnnotatedMessages)
func (*TodoListExecutive) Hash ¶
func (e *TodoListExecutive) Hash() string
func (*TodoListExecutive) Name ¶
func (e *TodoListExecutive) Name() string
func (*TodoListExecutive) Plan ¶
func (e *TodoListExecutive) Plan(messages AnnotatedMessages)
func (*TodoListExecutive) RunLoop ¶
func (e *TodoListExecutive) RunLoop(c Channel) error
type Trace ¶
type Trace chan *TraceMessage
func (Trace) Send ¶
func (t Trace) Send(msg *TraceMessage)
type TraceHistoryOperation ¶
type TraceHistoryOperation struct {
Type string `json:"type"`
Action string `json:"action"`
Annotation *Annotation `json:"annotation,omitempty"`
Message *llm.ChatCompletionMessage `json:"message,omitempty"`
}
type TraceMessage ¶
type TraceMessage struct {
Type string `json:"type"`
ID string `json:"id"`
ClientID string `json:"client_id,omitempty"`
Name string `json:"name"`
Message string `json:"message"`
Error error `json:"error,omitempty"`
Telemetry *TraceTelemetry `json:"telemetry,omitempty"`
Operations []*TraceHistoryOperation `json:"operations,omitempty"`
Signal *TraceSignal `json:"signal,omitempty"`
}
type TraceSignal ¶
func TraceForSignal ¶
func TraceForSignal(sig Signal) *TraceSignal
type TraceTelemetry ¶
type TwilioSMSChannel ¶
type TwilioSMSChannel struct {
AllowList []string
// contains filtered or unexported fields
}
func CreateTwilioSMSChannel ¶
func CreateTwilioSMSChannel() *TwilioSMSChannel
func (*TwilioSMSChannel) AllocateID ¶
func (c *TwilioSMSChannel) AllocateID() string
func (*TwilioSMSChannel) Receive ¶
func (c *TwilioSMSChannel) Receive() (*ChannelMessage, error)
func (*TwilioSMSChannel) Send ¶
func (c *TwilioSMSChannel) Send(m *ChannelMessage) error