manager

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithActorStore

func WithActorStore(store *stores.ActorStore) options.Option[BaseManager]

WithActorStore sets the actor store for the manager Used for managing actor data and preferences

func WithAssistantDetails

func WithAssistantDetails(assistantName string, assistantID id.ID) options.Option[BaseManager]

WithCoreDetails sets the core name and ID for the manager These are used to identify the assistant in logs and data storage

func WithContext

func WithContext(ctx context.Context) options.Option[BaseManager]

WithContext sets the context for the manager The context is used for cancellation and timeout control

func WithFragmentStore

func WithFragmentStore(store *stores.FragmentStore) options.Option[BaseManager]

WithFragmentStore sets the fragment store for the manager Used for persisting message fragments

func WithInteractionFragmentStore

func WithInteractionFragmentStore(store *stores.FragmentStore) options.Option[BaseManager]

WithInteractionFragmentStore sets the interaction fragment store for the manager Used for storing and retrieving conversation messages

func WithLLM

func WithLLM(llm *llm.LLMClient) options.Option[BaseManager]

WithLLM sets the LLM client for the manager Used for generating responses and processing text

func WithLogger

func WithLogger(logger *logger.Logger) options.Option[BaseManager]

WithLogger sets the logger instance for the manager Used for debugging and monitoring manager operations

func WithSessionStore

func WithSessionStore(store *stores.SessionStore) options.Option[BaseManager]

WithSessionStore sets the session store for the manager Used for managing session state and history

Types

type BaseManager

type BaseManager struct {
	Manager // Embedded interface for type safety
	options.RequiredFields

	AssistantName string
	AssistantID   id.ID

	Ctx           context.Context
	FragmentStore *stores.FragmentStore

	ActorStore   *stores.ActorStore
	SessionStore *stores.SessionStore

	InteractionFragmentStore *stores.FragmentStore

	Cache *cache.Cache

	LLM *llm.LLMClient

	Logger *logger.Logger
	// contains filtered or unexported fields
}

BaseManager provides common functionality for all manager implementations

func NewBaseManager

func NewBaseManager(opts ...options.Option[BaseManager]) (*BaseManager, error)

NewBaseManager creates a new BaseManager instance with the provided options

func (*BaseManager) Context

func (bm *BaseManager) Context(state *state.State) ([]state.StateData, error)

Context provides a default implementation that panics Managers should override this method to provide their specific context data

func (*BaseManager) GetDependencies

func (bm *BaseManager) GetDependencies() []ManagerID

GetDependencies returns an empty dependency list for the base manager

func (*BaseManager) GetID

func (bm *BaseManager) GetID() ManagerID

GetID returns the base manager identifier

func (*BaseManager) PostProcess

func (bm *BaseManager) PostProcess(state *state.State) error

PostProcess provides a default implementation that panics Managers should override this method with their specific post-processing logic

func (*BaseManager) Process

func (bm *BaseManager) Process(state *state.State) error

Process provides a default implementation that panics Managers should override this method with their specific analysis logic

func (*BaseManager) RegisterEventHandler

func (bm *BaseManager) RegisterEventHandler(callback EventCallbackFunc)

RegisterEventHandler sets the event handler callback for this manager

func (*BaseManager) StartBackgroundProcesses

func (bm *BaseManager) StartBackgroundProcesses()

StartBackgroundProcesses provides a default implementation that panics Managers should override this method if they need background processing

func (*BaseManager) StopBackgroundProcesses

func (bm *BaseManager) StopBackgroundProcesses()

StopBackgroundProcesses provides a default implementation that panics Managers should override this method if they need to clean up background processes

func (*BaseManager) Store

func (bm *BaseManager) Store(fragment *db.Fragment) error

Store persists a fragment to the fragment store

func (*BaseManager) ValidateRequiredFields

func (m *BaseManager) ValidateRequiredFields() error

ValidateRequiredFields ensures all required fields are set on the BaseManager Returns an error if any required field is missing

type EventCallbackFunc

type EventCallbackFunc func(eventData EventData) error

EventCallbackFunc defines the signature for event handler functions

type EventData

type EventData struct {
	EventType EventType   // Type of the event being triggered
	Data      interface{} // Associated data payload for the event
}

EventData encapsulates event information passed between managers

type EventType

type EventType string

type Manager

type Manager interface {
	// GetID returns the unique identifier for this manager
	GetID() ManagerID

	// GetDependencies returns a list of other manager IDs that this manager depends on
	GetDependencies() []ManagerID

	// Process performs analysis on the current state
	// This is called explicitly by the agent during message processing
	Process(state *state.State) error

	// PostProcess performs actions based on the current state
	// This is called explicitly by the agent after response generation
	PostProcess(state *state.State) error

	// ProvideContext collects and returns manager-specific data for the current state
	Context(state *state.State) ([]state.StateData, error)

	// StoreFragment persists a message fragment to storage
	Store(fragment *db.Fragment) error

	// StartBackgroundProcesses initializes any background tasks
	StartBackgroundProcesses()

	// StopBackgroundProcesses cleanly shuts down any background tasks
	StopBackgroundProcesses()

	// RegisterEventHandler sets up a callback for handling manager events
	RegisterEventHandler(callback EventCallbackFunc)
	// contains filtered or unexported methods
}

Manager defines the core interface that all managers must implement It provides methods for state management, execution, and event handling

type ManagerID

type ManagerID string

ManagerID is a unique identifier for manager instances

const (
	// BaseManagerID represents the core manager implementation
	BaseManagerID ManagerID = "base"

	// PersonalityManagerID handles agent personality and behavior traits
	PersonalityManagerID ManagerID = "personality"

	// InsightManagerID manages conversation and user insights
	InsightManagerID ManagerID = "insight"

	// TwitterManagerID handles Twitter-specific interactions
	TwitterManagerID ManagerID = "twitter"
)

Standard manager identifiers used throughout the system

Jump to

Keyboard shortcuts

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