Documentation
¶
Overview ¶
Package memory provides error definitions for memory service.
Package memory provides in-memory repository implementation for development/testing.
Package memory provides memory service implementation.
Index ¶
- Variables
- type Config
- type MemoryRepository
- func (r *MemoryRepository) AddMessage(ctx context.Context, message *core.Message) error
- func (r *MemoryRepository) CreateSession(ctx context.Context, session *core.Session) error
- func (r *MemoryRepository) DeleteSession(ctx context.Context, sessionID string) error
- func (r *MemoryRepository) GetDistilledTask(ctx context.Context, taskID string) (*core.DistilledTask, error)
- func (r *MemoryRepository) GetMessages(ctx context.Context, sessionID string, pagination *core.PaginationRequest) ([]*core.Message, error)
- func (r *MemoryRepository) GetSession(ctx context.Context, sessionID string) (*core.Session, error)
- func (r *MemoryRepository) SearchSimilarTasks(ctx context.Context, query *core.SearchQuery) ([]*core.SearchResult, error)
- func (r *MemoryRepository) StoreDistilledTask(ctx context.Context, task *core.DistilledTask) error
- func (r *MemoryRepository) UpdateSession(ctx context.Context, session *core.Session) error
- type Service
- func (s *Service) AddMessage(ctx context.Context, sessionID string, role core.MessageRole, content string) error
- func (s *Service) CreateSession(ctx context.Context, sessionConfig *core.SessionConfig) (string, error)
- func (s *Service) DeleteSession(ctx context.Context, sessionID string) error
- func (s *Service) DistillTask(ctx context.Context, taskID string) (*core.DistilledTask, error)
- func (s *Service) GetMessages(ctx context.Context, sessionID string, pagination *core.PaginationRequest) ([]*core.Message, error)
- func (s *Service) GetSession(ctx context.Context, sessionID string) (*core.Session, error)
- func (s *Service) SearchSimilarTasks(ctx context.Context, query *core.SearchQuery) ([]*core.SearchResult, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidUserID is returned when user ID is empty. ErrInvalidUserID = errors.New("invalid user ID") // ErrInvalidSessionID is returned when session ID is empty. ErrInvalidSessionID = errors.New("invalid session ID") // ErrInvalidRole is returned when role is empty. ErrInvalidRole = errors.New("invalid role") // ErrInvalidContent is returned when content is empty. ErrInvalidContent = errors.New("invalid content") // ErrInvalidTaskID is returned when task ID is empty. ErrInvalidTaskID = errors.New("invalid task ID") // ErrInvalidQuery is returned when query is empty. ErrInvalidQuery = errors.New("invalid query") // ErrInvalidConfig is returned when configuration is invalid. ErrInvalidConfig = errors.New("invalid configuration") // ErrSessionNotFound is returned when session does not exist. ErrSessionNotFound = errors.New("session not found") // ErrTaskNotFound is returned when task does not exist. ErrTaskNotFound = errors.New("task not found") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// BaseConfig is the base configuration.
BaseConfig *core.BaseConfig
// MemoryMgr is the internal memory manager instance.
MemoryMgr memory.MemoryManager
// Repo is the memory repository.
Repo core.MemoryRepository
}
Config represents service configuration.
type MemoryRepository ¶
type MemoryRepository struct {
// contains filtered or unexported fields
}
MemoryRepository provides an in-memory implementation of MemoryRepository. This is useful for development and testing without a database.
func NewMemoryRepository ¶
func NewMemoryRepository() *MemoryRepository
NewMemoryRepository creates a new in-memory memory repository. Returns new memory repository instance.
func (*MemoryRepository) AddMessage ¶
AddMessage adds a message to a session. Args: ctx - operation context. message - the message to add. Returns error if addition fails.
func (*MemoryRepository) CreateSession ¶
CreateSession creates a new session. Args: ctx - operation context. session - the session to create. Returns error if creation fails.
func (*MemoryRepository) DeleteSession ¶
func (r *MemoryRepository) DeleteSession(ctx context.Context, sessionID string) error
DeleteSession deletes a session and all its messages. Args: ctx - operation context. sessionID - the session identifier. Returns error if deletion fails.
func (*MemoryRepository) GetDistilledTask ¶
func (r *MemoryRepository) GetDistilledTask(ctx context.Context, taskID string) (*core.DistilledTask, error)
GetDistilledTask retrieves a distilled task by ID. Args: ctx - operation context. taskID - the task identifier. Returns the distilled task or error if not found.
func (*MemoryRepository) GetMessages ¶
func (r *MemoryRepository) GetMessages(ctx context.Context, sessionID string, pagination *core.PaginationRequest) ([]*core.Message, error)
GetMessages retrieves messages from a session. Args: ctx - operation context. sessionID - the session identifier. pagination - pagination parameters. Returns list of messages or error.
func (*MemoryRepository) GetSession ¶
GetSession retrieves a session by ID. Args: ctx - operation context. sessionID - the session identifier. Returns the session or error if not found.
func (*MemoryRepository) SearchSimilarTasks ¶
func (r *MemoryRepository) SearchSimilarTasks(ctx context.Context, query *core.SearchQuery) ([]*core.SearchResult, error)
SearchSimilarTasks searches for similar tasks. Args: ctx - operation context. query - the search query. Returns list of search results or error. Note: This is a simplified implementation that doesn't do actual vector similarity search.
func (*MemoryRepository) StoreDistilledTask ¶
func (r *MemoryRepository) StoreDistilledTask(ctx context.Context, task *core.DistilledTask) error
StoreDistilledTask stores a distilled task. Args: ctx - operation context. task - the distilled task to store. Returns error if storage fails.
func (*MemoryRepository) UpdateSession ¶
UpdateSession updates an existing session. Args: ctx - operation context. session - the session to update. Returns error if update fails.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides memory management operations.
func NewService ¶
NewService creates a new memory service instance. Args: config - service configuration. Returns new memory service instance or error.
func (*Service) AddMessage ¶
func (s *Service) AddMessage(ctx context.Context, sessionID string, role core.MessageRole, content string) error
AddMessage adds a message to a session. Args: ctx - operation context. sessionID - the session identifier. role - the message role. content - the message content. Returns error if addition fails.
func (*Service) CreateSession ¶
func (s *Service) CreateSession(ctx context.Context, sessionConfig *core.SessionConfig) (string, error)
CreateSession creates a new session with the given configuration. Args: ctx - operation context. sessionConfig - the session configuration. Returns the session ID or error.
func (*Service) DeleteSession ¶
DeleteSession deletes a session and all its messages. Args: ctx - operation context. sessionID - the session identifier. Returns error if deletion fails.
func (*Service) DistillTask ¶
DistillTask distills a task for future reference. Args: ctx - operation context. taskID - the task identifier. Returns the distilled task or error.
func (*Service) GetMessages ¶
func (s *Service) GetMessages(ctx context.Context, sessionID string, pagination *core.PaginationRequest) ([]*core.Message, error)
GetMessages retrieves messages from a session. Args: ctx - operation context. sessionID - the session identifier. pagination - pagination parameters. Returns list of messages or error.
func (*Service) GetSession ¶
GetSession retrieves a session by ID. Args: ctx - operation context. sessionID - the session identifier. Returns the session or error if not found.
func (*Service) SearchSimilarTasks ¶
func (s *Service) SearchSimilarTasks(ctx context.Context, query *core.SearchQuery) ([]*core.SearchResult, error)
SearchSimilarTasks searches for similar tasks. Args: ctx - operation context. query - the search query. Returns list of search results or error.