Documentation
¶
Index ¶
- func RecordCleanupDeleted(table string, count int64)
- func RecordCleanupDuration(table string, seconds float64)
- func SetStorageSize(bytes int64)
- func SetTableSize(table string, bytes int64)
- type DashboardStats
- type Fact
- type FactHistory
- type FactHistoryFilter
- type FactHistoryRepository
- type FactHistoryResult
- type FactRepository
- type FactStats
- type LogRepository
- type MaintenanceRepository
- type MemoryBankRepository
- type MergeCandidate
- type Message
- type MessageRepository
- type RAGLog
- type RerankerCandidate
- type RerankerLog
- type RerankerLogRepository
- type RerankerToolCall
- type RerankerToolCallTopic
- type SQLiteStore
- func (s *SQLiteStore) AddFact(fact Fact) (int64, error)
- func (s *SQLiteStore) AddFactHistory(h FactHistory) error
- func (s *SQLiteStore) AddMessageToHistory(userID int64, message Message) error
- func (s *SQLiteStore) AddRAGLog(log RAGLog) error
- func (s *SQLiteStore) AddRerankerLog(log RerankerLog) error
- func (s *SQLiteStore) AddStat(stat Stat) error
- func (s *SQLiteStore) AddTopic(topic Topic) (int64, error)
- func (s *SQLiteStore) CleanupFactHistory(keepPerUser int) (int64, error)
- func (s *SQLiteStore) CleanupRagLogs(keepPerUser int) (int64, error)
- func (s *SQLiteStore) CleanupRerankerLogs(keepPerUser int) (int64, error)
- func (s *SQLiteStore) ClearHistory(userID int64) error
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) CreateTopic(topic Topic) (int64, error)
- func (s *SQLiteStore) DeleteFact(userID, id int64) error
- func (s *SQLiteStore) DeleteTopic(id int64) error
- func (s *SQLiteStore) DeleteTopicCascade(id int64) error
- func (s *SQLiteStore) GetAllFacts() ([]Fact, error)
- func (s *SQLiteStore) GetAllTopics() ([]Topic, error)
- func (s *SQLiteStore) GetAllUsers() ([]User, error)
- func (s *SQLiteStore) GetDBSize() (int64, error)
- func (s *SQLiteStore) GetDashboardStats(userID int64) (*DashboardStats, error)
- func (s *SQLiteStore) GetFactHistory(userID int64, limit int) ([]FactHistory, error)
- func (s *SQLiteStore) GetFactHistoryExtended(filter FactHistoryFilter, limit, offset int, sortBy, sortDir string) (FactHistoryResult, error)
- func (s *SQLiteStore) GetFactStats() (FactStats, error)
- func (s *SQLiteStore) GetFactStatsByUser(userID int64) (FactStats, error)
- func (s *SQLiteStore) GetFacts(userID int64) ([]Fact, error)
- func (s *SQLiteStore) GetFactsAfterID(minID int64) ([]Fact, error)
- func (s *SQLiteStore) GetFactsByIDs(ids []int64) ([]Fact, error)
- func (s *SQLiteStore) GetLastTopicEndMessageID(userID int64) (int64, error)
- func (s *SQLiteStore) GetMemoryBank(userID int64) (string, error)
- func (s *SQLiteStore) GetMergeCandidates(userID int64) ([]MergeCandidate, error)
- func (s *SQLiteStore) GetMessagesByIDs(ids []int64) ([]Message, error)
- func (s *SQLiteStore) GetMessagesInRange(ctx context.Context, userID int64, startID, endID int64) ([]Message, error)
- func (s *SQLiteStore) GetRAGLogs(userID int64, limit int) ([]RAGLog, error)
- func (s *SQLiteStore) GetRecentHistory(userID int64, limit int) ([]Message, error)
- func (s *SQLiteStore) GetRerankerLogs(userID int64, limit int) ([]RerankerLog, error)
- func (s *SQLiteStore) GetStats() (map[int64]Stat, error)
- func (s *SQLiteStore) GetTableSizes() ([]TableSize, error)
- func (s *SQLiteStore) GetTopicExtractionLogs(limit, offset int) ([]RAGLog, int, error)
- func (s *SQLiteStore) GetTopics(userID int64) ([]Topic, error)
- func (s *SQLiteStore) GetTopicsAfterID(minID int64) ([]Topic, error)
- func (s *SQLiteStore) GetTopicsByIDs(ids []int64) ([]Topic, error)
- func (s *SQLiteStore) GetTopicsExtended(filter TopicFilter, limit, offset int, sortBy, sortDir string) (TopicResult, error)
- func (s *SQLiteStore) GetTopicsPendingFacts(userID int64) ([]Topic, error)
- func (s *SQLiteStore) GetUnprocessedMessages(userID int64) ([]Message, error)
- func (s *SQLiteStore) ImportMessage(userID int64, message Message) error
- func (s *SQLiteStore) Init() error
- func (s *SQLiteStore) ResetUserData(userID int64) error
- func (s *SQLiteStore) SetTopicConsolidationChecked(topicID int64, checked bool) error
- func (s *SQLiteStore) SetTopicFactsExtracted(topicID int64, extracted bool) error
- func (s *SQLiteStore) UpdateFact(fact Fact) error
- func (s *SQLiteStore) UpdateFactHistoryTopic(oldTopicID, newTopicID int64) error
- func (s *SQLiteStore) UpdateFactTopic(oldTopicID, newTopicID int64) error
- func (s *SQLiteStore) UpdateMemoryBank(userID int64, content string) error
- func (s *SQLiteStore) UpdateMessageTopic(messageID, topicID int64) error
- func (s *SQLiteStore) UpsertUser(user User) error
- type Stat
- type StatsRepository
- type Storage
- type TableSize
- type Topic
- type TopicExtended
- type TopicFilter
- type TopicRepository
- type TopicResult
- type User
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordCleanupDeleted ¶ added in v0.3.5
RecordCleanupDeleted records the number of deleted rows during cleanup.
func RecordCleanupDuration ¶ added in v0.3.5
RecordCleanupDuration records the duration of a cleanup operation.
func SetStorageSize ¶ added in v0.3.5
func SetStorageSize(bytes int64)
SetStorageSize updates the storage size metric.
func SetTableSize ¶ added in v0.3.5
SetTableSize updates the table size metric.
Types ¶
type DashboardStats ¶
type DashboardStats struct {
TotalTopics int
AvgTopicSize float64
ProcessedTopicsPct float64
ConsolidatedTopics int
TotalFacts int
FactsByCategory map[string]int
FactsByType map[string]int
TotalMessages int
UnprocessedMessages int
TotalRAGQueries int
AvgRAGCost float64
MessagesPerDay map[string]int
FactsGrowth map[string]int
}
type FactHistory ¶
type FactHistoryFilter ¶
type FactHistoryRepository ¶
type FactHistoryRepository interface {
AddFactHistory(history FactHistory) error
UpdateFactHistoryTopic(oldTopicID, newTopicID int64) error
GetFactHistory(userID int64, limit int) ([]FactHistory, error)
GetFactHistoryExtended(filter FactHistoryFilter, limit, offset int, sortBy, sortDir string) (FactHistoryResult, error)
}
FactHistoryRepository handles fact history operations.
type FactHistoryResult ¶
type FactHistoryResult struct {
Data []FactHistory
TotalCount int
}
type FactRepository ¶
type FactRepository interface {
AddFact(fact Fact) (int64, error)
GetFacts(userID int64) ([]Fact, error)
GetFactsByIDs(ids []int64) ([]Fact, error)
GetAllFacts() ([]Fact, error)
GetFactsAfterID(minID int64) ([]Fact, error)
GetFactStats() (FactStats, error)
GetFactStatsByUser(userID int64) (FactStats, error)
UpdateFact(fact Fact) error
UpdateFactTopic(oldTopicID, newTopicID int64) error
DeleteFact(userID, id int64) error
}
FactRepository handles fact operations.
type LogRepository ¶
type LogRepository interface {
AddRAGLog(log RAGLog) error
GetRAGLogs(userID int64, limit int) ([]RAGLog, error)
GetTopicExtractionLogs(limit, offset int) ([]RAGLog, int, error)
}
LogRepository handles RAG log operations.
type MaintenanceRepository ¶ added in v0.3.5
type MaintenanceRepository interface {
GetDBSize() (int64, error)
GetTableSizes() ([]TableSize, error)
CleanupFactHistory(keepPerUser int) (int64, error)
CleanupRagLogs(keepPerUser int) (int64, error)
CleanupRerankerLogs(keepPerUser int) (int64, error)
}
MaintenanceRepository handles database maintenance operations.
type MemoryBankRepository ¶
type MemoryBankRepository interface {
GetMemoryBank(userID int64) (string, error)
UpdateMemoryBank(userID int64, content string) error
}
MemoryBankRepository handles the legacy memory bank.
type MergeCandidate ¶
type MessageRepository ¶
type MessageRepository interface {
AddMessageToHistory(userID int64, message Message) error
ImportMessage(userID int64, message Message) error
GetRecentHistory(userID int64, limit int) ([]Message, error)
GetMessagesByIDs(ids []int64) ([]Message, error)
ClearHistory(userID int64) error
GetMessagesInRange(ctx context.Context, userID int64, startID, endID int64) ([]Message, error)
UpdateMessageTopic(messageID, topicID int64) error
GetUnprocessedMessages(userID int64) ([]Message, error)
}
MessageRepository handles message history operations.
type RAGLog ¶
type RAGLog struct {
ID int64
UserID int64
OriginalQuery string
EnrichedQuery string
EnrichmentPrompt string
ContextUsed string // The full context sent to the generation model
SystemPrompt string
RetrievalResults string // JSON array of retrieved messages
LLMResponse string
EnrichmentTokens int
GenerationTokens int
TotalCostUSD float64
CreatedAt time.Time
}
type RerankerCandidate ¶ added in v0.4.1
type RerankerCandidate struct {
TopicID int64 `json:"topic_id"`
Summary string `json:"summary"`
Score float32 `json:"score"`
Date string `json:"date"`
MessageCount int `json:"message_count"`
SizeChars int `json:"size_chars"`
}
RerankerCandidate is a single candidate for JSON serialization
type RerankerLog ¶ added in v0.4.1
type RerankerLog struct {
ID int64
UserID int64
OriginalQuery string
EnrichedQuery string
CandidatesJSON string // JSON array of candidates with scores
ToolCallsJSON string // JSON array of tool call iterations
SelectedIDsJSON string // JSON array of selected topic IDs
FallbackReason *string // nil if no fallback, otherwise reason
DurationEnrichmentMs int
DurationVectorMs int
DurationRerankerMs int
DurationTotalMs int
CreatedAt time.Time
}
RerankerLog stores debug traces from the reranker component
type RerankerLogRepository ¶ added in v0.4.1
type RerankerLogRepository interface {
AddRerankerLog(log RerankerLog) error
GetRerankerLogs(userID int64, limit int) ([]RerankerLog, error)
}
RerankerLogRepository handles reranker debug log operations.
type RerankerToolCall ¶ added in v0.4.1
type RerankerToolCall struct {
Iteration int `json:"iteration"`
TopicIDs []int64 `json:"topic_ids"`
Topics []RerankerToolCallTopic `json:"topics"`
}
RerankerToolCall represents one iteration of tool calls
type RerankerToolCallTopic ¶ added in v0.4.1
RerankerToolCallTopic contains topic info for tool call display
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
func NewSQLiteStore ¶
func NewSQLiteStore(logger *slog.Logger, path string) (*SQLiteStore, error)
func (*SQLiteStore) AddFactHistory ¶
func (s *SQLiteStore) AddFactHistory(h FactHistory) error
func (*SQLiteStore) AddMessageToHistory ¶
func (s *SQLiteStore) AddMessageToHistory(userID int64, message Message) error
func (*SQLiteStore) AddRAGLog ¶
func (s *SQLiteStore) AddRAGLog(log RAGLog) error
func (*SQLiteStore) AddRerankerLog ¶ added in v0.4.1
func (s *SQLiteStore) AddRerankerLog(log RerankerLog) error
AddRerankerLog saves a reranker debug trace.
func (*SQLiteStore) AddStat ¶
func (s *SQLiteStore) AddStat(stat Stat) error
func (*SQLiteStore) CleanupFactHistory ¶ added in v0.3.5
func (s *SQLiteStore) CleanupFactHistory(keepPerUser int) (int64, error)
CleanupFactHistory removes old fact_history records, keeping only the N most recent per user. Returns the number of deleted rows.
func (*SQLiteStore) CleanupRagLogs ¶ added in v0.3.5
func (s *SQLiteStore) CleanupRagLogs(keepPerUser int) (int64, error)
CleanupRagLogs removes old rag_logs records, keeping only the N most recent per user. Returns the number of deleted rows.
func (*SQLiteStore) CleanupRerankerLogs ¶ added in v0.4.1
func (s *SQLiteStore) CleanupRerankerLogs(keepPerUser int) (int64, error)
CleanupRerankerLogs removes old reranker_logs records, keeping only the N most recent per user. Returns the number of deleted rows.
func (*SQLiteStore) ClearHistory ¶
func (s *SQLiteStore) ClearHistory(userID int64) error
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
func (*SQLiteStore) CreateTopic ¶
func (s *SQLiteStore) CreateTopic(topic Topic) (int64, error)
func (*SQLiteStore) DeleteFact ¶
func (s *SQLiteStore) DeleteFact(userID, id int64) error
func (*SQLiteStore) DeleteTopic ¶
func (s *SQLiteStore) DeleteTopic(id int64) error
func (*SQLiteStore) DeleteTopicCascade ¶
func (s *SQLiteStore) DeleteTopicCascade(id int64) error
func (*SQLiteStore) GetAllFacts ¶
func (s *SQLiteStore) GetAllFacts() ([]Fact, error)
func (*SQLiteStore) GetAllTopics ¶
func (s *SQLiteStore) GetAllTopics() ([]Topic, error)
func (*SQLiteStore) GetAllUsers ¶
func (s *SQLiteStore) GetAllUsers() ([]User, error)
func (*SQLiteStore) GetDBSize ¶ added in v0.3.5
func (s *SQLiteStore) GetDBSize() (int64, error)
GetDBSize returns the size of the database file in bytes.
func (*SQLiteStore) GetDashboardStats ¶
func (s *SQLiteStore) GetDashboardStats(userID int64) (*DashboardStats, error)
func (*SQLiteStore) GetFactHistory ¶
func (s *SQLiteStore) GetFactHistory(userID int64, limit int) ([]FactHistory, error)
func (*SQLiteStore) GetFactHistoryExtended ¶
func (s *SQLiteStore) GetFactHistoryExtended(filter FactHistoryFilter, limit, offset int, sortBy, sortDir string) (FactHistoryResult, error)
func (*SQLiteStore) GetFactStats ¶
func (s *SQLiteStore) GetFactStats() (FactStats, error)
func (*SQLiteStore) GetFactStatsByUser ¶ added in v0.3.5
func (s *SQLiteStore) GetFactStatsByUser(userID int64) (FactStats, error)
func (*SQLiteStore) GetFactsAfterID ¶ added in v0.2.1
func (s *SQLiteStore) GetFactsAfterID(minID int64) ([]Fact, error)
func (*SQLiteStore) GetFactsByIDs ¶
func (s *SQLiteStore) GetFactsByIDs(ids []int64) ([]Fact, error)
func (*SQLiteStore) GetLastTopicEndMessageID ¶
func (s *SQLiteStore) GetLastTopicEndMessageID(userID int64) (int64, error)
func (*SQLiteStore) GetMemoryBank ¶
func (s *SQLiteStore) GetMemoryBank(userID int64) (string, error)
func (*SQLiteStore) GetMergeCandidates ¶
func (s *SQLiteStore) GetMergeCandidates(userID int64) ([]MergeCandidate, error)
func (*SQLiteStore) GetMessagesByIDs ¶
func (s *SQLiteStore) GetMessagesByIDs(ids []int64) ([]Message, error)
func (*SQLiteStore) GetMessagesInRange ¶
func (*SQLiteStore) GetRAGLogs ¶
func (s *SQLiteStore) GetRAGLogs(userID int64, limit int) ([]RAGLog, error)
func (*SQLiteStore) GetRecentHistory ¶
func (s *SQLiteStore) GetRecentHistory(userID int64, limit int) ([]Message, error)
func (*SQLiteStore) GetRerankerLogs ¶ added in v0.4.1
func (s *SQLiteStore) GetRerankerLogs(userID int64, limit int) ([]RerankerLog, error)
GetRerankerLogs retrieves recent reranker traces for a user.
func (*SQLiteStore) GetTableSizes ¶ added in v0.3.5
func (s *SQLiteStore) GetTableSizes() ([]TableSize, error)
GetTableSizes returns the size of each table in bytes using SQLite's dbstat virtual table.
func (*SQLiteStore) GetTopicExtractionLogs ¶
func (s *SQLiteStore) GetTopicExtractionLogs(limit, offset int) ([]RAGLog, int, error)
func (*SQLiteStore) GetTopicsAfterID ¶ added in v0.2.1
func (s *SQLiteStore) GetTopicsAfterID(minID int64) ([]Topic, error)
func (*SQLiteStore) GetTopicsByIDs ¶ added in v0.2.1
func (s *SQLiteStore) GetTopicsByIDs(ids []int64) ([]Topic, error)
func (*SQLiteStore) GetTopicsExtended ¶
func (s *SQLiteStore) GetTopicsExtended(filter TopicFilter, limit, offset int, sortBy, sortDir string) (TopicResult, error)
func (*SQLiteStore) GetTopicsPendingFacts ¶
func (s *SQLiteStore) GetTopicsPendingFacts(userID int64) ([]Topic, error)
func (*SQLiteStore) GetUnprocessedMessages ¶
func (s *SQLiteStore) GetUnprocessedMessages(userID int64) ([]Message, error)
func (*SQLiteStore) ImportMessage ¶
func (s *SQLiteStore) ImportMessage(userID int64, message Message) error
func (*SQLiteStore) Init ¶
func (s *SQLiteStore) Init() error
func (*SQLiteStore) ResetUserData ¶
func (s *SQLiteStore) ResetUserData(userID int64) error
func (*SQLiteStore) SetTopicConsolidationChecked ¶
func (s *SQLiteStore) SetTopicConsolidationChecked(topicID int64, checked bool) error
func (*SQLiteStore) SetTopicFactsExtracted ¶
func (s *SQLiteStore) SetTopicFactsExtracted(topicID int64, extracted bool) error
func (*SQLiteStore) UpdateFact ¶
func (s *SQLiteStore) UpdateFact(fact Fact) error
func (*SQLiteStore) UpdateFactHistoryTopic ¶
func (s *SQLiteStore) UpdateFactHistoryTopic(oldTopicID, newTopicID int64) error
func (*SQLiteStore) UpdateFactTopic ¶
func (s *SQLiteStore) UpdateFactTopic(oldTopicID, newTopicID int64) error
func (*SQLiteStore) UpdateMemoryBank ¶
func (s *SQLiteStore) UpdateMemoryBank(userID int64, content string) error
func (*SQLiteStore) UpdateMessageTopic ¶
func (s *SQLiteStore) UpdateMessageTopic(messageID, topicID int64) error
func (*SQLiteStore) UpsertUser ¶
func (s *SQLiteStore) UpsertUser(user User) error
type StatsRepository ¶
type StatsRepository interface {
AddStat(stat Stat) error
GetStats() (map[int64]Stat, error)
GetDashboardStats(userID int64) (*DashboardStats, error)
}
StatsRepository handles usage statistics.
type TopicExtended ¶
type TopicFilter ¶
type TopicRepository ¶
type TopicRepository interface {
AddTopic(topic Topic) (int64, error)
CreateTopic(topic Topic) (int64, error)
DeleteTopic(id int64) error
DeleteTopicCascade(id int64) error
GetLastTopicEndMessageID(userID int64) (int64, error)
GetAllTopics() ([]Topic, error)
GetTopicsAfterID(minID int64) ([]Topic, error)
GetTopicsByIDs(ids []int64) ([]Topic, error)
GetTopics(userID int64) ([]Topic, error)
SetTopicFactsExtracted(topicID int64, extracted bool) error
SetTopicConsolidationChecked(topicID int64, checked bool) error
GetTopicsPendingFacts(userID int64) ([]Topic, error)
GetTopicsExtended(filter TopicFilter, limit, offset int, sortBy, sortDir string) (TopicResult, error)
GetMergeCandidates(userID int64) ([]MergeCandidate, error)
}
TopicRepository handles topic operations.
type TopicResult ¶
type TopicResult struct {
Data []TopicExtended
TotalCount int
}