Documentation
¶
Index ¶
- Constants
- Variables
- func NewKBWrapperActions(ragdb RAGDB, kbResults int) (*SearchKnowledgeBaseAction, *AddToKnowledgeBaseAction)
- type AddToKnowledgeBaseAction
- type Agent
- func (a *Agent) AddSubscriber(f func(*types.ConversationMessage))
- func (a *Agent) Ask(opts ...types.JobOption) *types.JobResult
- func (a *Agent) Context() context.Context
- func (a *Agent) Enqueue(j *types.Job)
- func (a *Agent) Execute(j *types.Job) *types.JobResult
- func (a *Agent) LoadCharacter(path string) error
- func (a *Agent) LoadState(path string) error
- func (a *Agent) Memory() RAGDB
- func (a *Agent) Observer() Observer
- func (a *Agent) Pause()
- func (a *Agent) Paused() bool
- func (a *Agent) Resume()
- func (a *Agent) Run() error
- func (a *Agent) SaveCharacter(path string) error
- func (a *Agent) SaveState(path string) error
- func (a *Agent) SharedState() *types.AgentSharedState
- func (a *Agent) State() types.AgentInternalState
- func (a *Agent) Stop()
- func (a *Agent) TTS(ctx context.Context, text string) ([]byte, error)
- func (a *Agent) Transcribe(ctx context.Context, file string) (string, error)
- type Character
- type ConversationStorageMode
- type DynamicPrompt
- type KBWrapperActions
- type MCPSTDIOServer
- type MCPServer
- type Messages
- func (m Messages) Exist(content string) bool
- func (m Messages) GetLatestUserMessage() *openai.ChatCompletionMessage
- func (m Messages) RemoveIf(f func(msg openai.ChatCompletionMessage) bool) Messages
- func (m Messages) RemoveLastUserMessage() Messages
- func (m Messages) Save(path string) error
- func (m Messages) String() string
- func (m Messages) ToOpenAI() []openai.ChatCompletionMessage
- type NoToolToCallArgs
- type NoToolToCallTool
- type Observer
- type Option
- func EnableEvaluation() Option
- func EnableKnowledgeBaseWithResults(results int) Option
- func FromFile(path string) Option
- func WithActions(actions ...types.Action) Option
- func WithAgentReasoningCallback(cb func(types.ActionCurrentState) bool) Option
- func WithAgentResultCallback(cb func(types.ActionState)) Option
- func WithCharacter(c Character) Option
- func WithCharacterFile(path string) Option
- func WithContext(ctx context.Context) Option
- func WithConversationStorageMode(mode ConversationStorageMode) Option
- func WithConversationsPath(path string) Option
- func WithJobFilters(filters ...types.JobFilter) Option
- func WithKBAutoSearch(enabled bool) Option
- func WithLLMAPIKey(key string) Option
- func WithLLMAPIURL(url string) Option
- func WithLastMessageDuration(duration string) Option
- func WithMCPPrepareScript(script string) Option
- func WithMCPSTDIOServers(servers ...MCPSTDIOServer) Option
- func WithMCPServers(servers ...MCPServer) Option
- func WithMaxEvaluationLoops(loops int) Option
- func WithModel(model string) Option
- func WithMultimodalModel(model string) Option
- func WithNewConversationSubscriber(sub func(*types.ConversationMessage)) Option
- func WithObserver(observer Observer) Option
- func WithParallelJobs(jobs int) Option
- func WithPeriodicRuns(duration string) Option
- func WithPermanentGoal(goal string) Option
- func WithPrompts(prompts ...DynamicPrompt) Option
- func WithRAGDB(db RAGDB) Option
- func WithRandomIdentity(guidance ...string) Option
- func WithSchedulerPollInterval(duration string) Option
- func WithSchedulerStorePath(path string) Option
- func WithStateFile(path string) Option
- func WithSystemPrompt(prompt string) Option
- func WithTTSModel(model string) Option
- func WithTimeout(timeout string) Option
- func WithTranscriptionLanguage(language string) Option
- func WithTranscriptionModel(model string) Option
- type PromptHUD
- type RAGDB
- type SSEObserver
- type SearchKnowledgeBaseAction
- type ToolInputSchema
Constants ¶
const ( UserRole = "user" AssistantRole = "assistant" SystemRole = "system" )
Variables ¶
var CanStopItself = func(o *options) error { o.canStopItself = true return nil }
var DisableSinkState = func(o *options) error { o.disableSinkState = true return nil }
var EnableForceReasoning = func(o *options) error { o.forceReasoning = true return nil }
var EnableForceReasoningTool = func(o *options) error { o.forceReasoningTool = true return nil }
var EnableGuidedTools = func(o *options) error { o.enableGuidedTools = true return nil }
var EnableHUD = func(o *options) error { o.enableHUD = true return nil }
var EnableInitiateConversations = func(o *options) error { o.initiateConversations = true return nil }
var EnableKnowledgeBase = func(o *options) error { o.enableKB = true o.kbResults = 5 return nil }
var EnableLongTermMemory = func(o *options) error { o.enableLongTermMemory = true return nil }
var EnablePersonality = func(o *options) error { o.showCharacter = true return nil }
var EnablePlanning = func(o *options) error { o.canPlan = true return nil }
var EnableStandaloneJob = func(o *options) error { o.standaloneJob = true return nil }
EnableStandaloneJob is an option to enable the agent to run jobs in the background automatically
var EnableStripThinkingTags = func(o *options) error { o.stripThinkingTags = true return nil }
var EnableSummaryMemory = func(o *options) error { o.enableSummaryMemory = true return nil }
var ErrContextCanceled = fmt.Errorf("context canceled")
var WithPlanReviewerLLM = func(model string) Option { return func(o *options) error { o.LLMAPI.ReviewerModel = model return nil } }
Functions ¶
func NewKBWrapperActions ¶
func NewKBWrapperActions(ragdb RAGDB, kbResults int) (*SearchKnowledgeBaseAction, *AddToKnowledgeBaseAction)
NewKBWrapperActions creates factory functions for KB wrapper actions
Types ¶
type AddToKnowledgeBaseAction ¶
type AddToKnowledgeBaseAction struct {
*KBWrapperActions
}
func (*AddToKnowledgeBaseAction) Definition ¶
func (a *AddToKnowledgeBaseAction) Definition() types.ActionDefinition
func (*AddToKnowledgeBaseAction) Run ¶
func (a *AddToKnowledgeBaseAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error)
type Agent ¶
func (*Agent) AddSubscriber ¶
func (a *Agent) AddSubscriber(f func(*types.ConversationMessage))
func (*Agent) Ask ¶
Ask is a blocking call that returns the response as soon as it's ready. It discards any other computation.
func (*Agent) Execute ¶
Ask is a pre-emptive, blocking call that returns the response as soon as it's ready. It discards any other computation.
func (*Agent) LoadCharacter ¶
func (*Agent) SaveCharacter ¶
func (*Agent) SharedState ¶
func (a *Agent) SharedState() *types.AgentSharedState
func (*Agent) State ¶
func (a *Agent) State() types.AgentInternalState
type Character ¶
type Character struct {
Name string `json:"name"`
Age string `json:"age"`
Occupation string `json:"job_occupation"`
Hobbies []string `json:"hobbies"`
MusicTaste []string `json:"favorites_music_genres"`
Sex string `json:"sex"`
}
func (*Character) ToJSONSchema ¶
func (c *Character) ToJSONSchema() jsonschema.Definition
type ConversationStorageMode ¶
type ConversationStorageMode string
ConversationStorageMode defines how conversations are stored in the knowledge base
const ( // StoreUserOnly stores only user messages (default) StoreUserOnly ConversationStorageMode = "user_only" // StoreUserAndAssistant stores both user and assistant messages separately StoreUserAndAssistant ConversationStorageMode = "user_and_assistant" // StoreWholeConversation stores the entire conversation as a single block StoreWholeConversation ConversationStorageMode = "whole_conversation" )
type DynamicPrompt ¶
type DynamicPrompt interface {
Render(a *Agent) (types.PromptResult, error)
Role() string
}
type KBWrapperActions ¶
type KBWrapperActions struct {
// contains filtered or unexported fields
}
KBWrapperActions wraps RAGDB functionality as actions
type MCPSTDIOServer ¶
type Messages ¶
type Messages []openai.ChatCompletionMessage
func (Messages) GetLatestUserMessage ¶
func (m Messages) GetLatestUserMessage() *openai.ChatCompletionMessage
func (Messages) RemoveIf ¶
func (m Messages) RemoveIf(f func(msg openai.ChatCompletionMessage) bool) Messages
func (Messages) RemoveLastUserMessage ¶
func (Messages) ToOpenAI ¶
func (m Messages) ToOpenAI() []openai.ChatCompletionMessage
type NoToolToCallArgs ¶
type NoToolToCallArgs struct {
Reasoning string `json:"reasoning" description:"The reasoning for why no tool is being called"`
}
NoToolToCallArgs defines the arguments for the no_tool_to_call sink state tool
type NoToolToCallTool ¶
type NoToolToCallTool struct{}
NoToolToCallTool is a custom sink state tool that logs when no other tool is needed
func (NoToolToCallTool) Run ¶
func (t NoToolToCallTool) Run(args NoToolToCallArgs) (string, any, error)
Run executes the no_tool_to_call tool and logs a message
type Observer ¶
type Observer interface {
NewObservable() *types.Observable
Update(types.Observable)
History() []types.Observable
ClearHistory()
}
type Option ¶
type Option func(*options) error
func EnableEvaluation ¶
func EnableEvaluation() Option
func WithActions ¶
func WithAgentReasoningCallback ¶
func WithAgentReasoningCallback(cb func(types.ActionCurrentState) bool) Option
func WithAgentResultCallback ¶
func WithAgentResultCallback(cb func(types.ActionState)) Option
func WithCharacter ¶
func WithCharacterFile ¶
func WithContext ¶
func WithConversationStorageMode ¶
func WithConversationStorageMode(mode ConversationStorageMode) Option
WithConversationStorageMode sets how conversations are stored in the knowledge base
func WithConversationsPath ¶
func WithJobFilters ¶
func WithKBAutoSearch ¶
func WithLLMAPIKey ¶
func WithLLMAPIURL ¶
func WithLastMessageDuration ¶
func WithMCPPrepareScript ¶
func WithMCPSTDIOServers ¶
func WithMCPSTDIOServers(servers ...MCPSTDIOServer) Option
func WithMCPServers ¶
func WithMaxEvaluationLoops ¶
func WithMultimodalModel ¶
func WithNewConversationSubscriber ¶
func WithNewConversationSubscriber(sub func(*types.ConversationMessage)) Option
func WithObserver ¶
func WithParallelJobs ¶
func WithPeriodicRuns ¶
func WithPermanentGoal ¶
func WithPrompts ¶
func WithPrompts(prompts ...DynamicPrompt) Option
WithPrompts adds additional block prompts to the agent to be rendered internally in the conversation when processing the conversation to the LLM
func WithRandomIdentity ¶
func WithSchedulerStorePath ¶
WithSchedulerStorePath sets the path for the scheduler's JSON storage file
func WithStateFile ¶
func WithSystemPrompt ¶
func WithTTSModel ¶
func WithTimeout ¶
func WithTranscriptionModel ¶
type PromptHUD ¶
type PromptHUD struct {
Character Character `json:"character"`
CurrentState types.AgentInternalState `json:"current_state"`
PermanentGoal string `json:"permanent_goal"`
ShowCharacter bool `json:"show_character"`
}
PromptHUD contains all information that should be displayed to the LLM in the prompts
type SSEObserver ¶
type SSEObserver struct {
// contains filtered or unexported fields
}
func NewSSEObserver ¶
func NewSSEObserver(agent string, manager sse.Manager) *SSEObserver
func (*SSEObserver) ClearHistory ¶
func (s *SSEObserver) ClearHistory()
func (*SSEObserver) History ¶
func (s *SSEObserver) History() []types.Observable
func (*SSEObserver) NewObservable ¶
func (s *SSEObserver) NewObservable() *types.Observable
func (*SSEObserver) Update ¶
func (s *SSEObserver) Update(obs types.Observable)
type SearchKnowledgeBaseAction ¶
type SearchKnowledgeBaseAction struct {
*KBWrapperActions
}
func (*SearchKnowledgeBaseAction) Definition ¶
func (a *SearchKnowledgeBaseAction) Definition() types.ActionDefinition
func (*SearchKnowledgeBaseAction) Run ¶
func (a *SearchKnowledgeBaseAction) Run(ctx context.Context, sharedState *types.AgentSharedState, params types.ActionParams) (types.ActionResult, error)