feat(rag): pgvector knowledge base with API and LLM tools
- services/rag: knowledge_docs store — vector search via the shared embedder (HNSW index, graceful ILIKE fallback), list/delete scoped to the user, search intentionally global for the single-user deployment - gateway: GET/POST /knowledge/docs, DELETE /knowledge/docs/:id, POST /knowledge/search - plugins/knowledge: knowledge_search and knowledge_ingest tools so the persona can save and recall information mid-conversation - main: migrations, store wiring, plugin registration
This commit is contained in:
1 parent
ac0c2b2c73
commit
9c8d5a9e8d
6 files changed
+432
-2
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/services/ai-core/model"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/services/gateway/store"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/services/rag"
|
||||
)
|
||||
|
||||
// --- Interfaces for injected services ---
|
||||
@@ -96,6 +97,14 @@ type VisionAnalyzer interface {
|
||||
AnalyzeImage(ctx context.Context, prompt, imageRef string) (string, error)
|
||||
}
|
||||
|
||||
// KnowledgeStorer manages the knowledge base.
|
||||
type KnowledgeStorer interface {
|
||||
Ingest(ctx context.Context, userID, title, content string) (*rag.Document, error)
|
||||
Search(ctx context.Context, userID, query string, topK int) ([]rag.Document, error)
|
||||
List(ctx context.Context, userID string, limit int) ([]rag.Document, error)
|
||||
Delete(ctx context.Context, userID string, id int64) error
|
||||
}
|
||||
|
||||
// ChatStorer persists chat sessions and messages.
|
||||
type ChatStorer interface {
|
||||
CreateSession(ctx context.Context, id, userID, title string) (*store.Session, error)
|
||||
@@ -123,6 +132,7 @@ type Dependencies struct {
|
||||
AutomationEng AutomationEngine
|
||||
Reminders *ReminderStore
|
||||
Vision VisionAnalyzer
|
||||
Knowledge KnowledgeStorer
|
||||
PluginList []map[string]string
|
||||
}
|
||||
|
||||
@@ -184,6 +194,11 @@ func (r *Router) setupRoutes() {
|
||||
// Message search & session export
|
||||
r.mux.HandleFunc("/api/v1/messages/search", r.authMW(r.messageSearchHandler))
|
||||
|
||||
// Knowledge base
|
||||
r.mux.HandleFunc("/api/v1/knowledge/docs", r.authMW(r.knowledgeDocsHandler))
|
||||
r.mux.HandleFunc("/api/v1/knowledge/docs/", r.authMW(r.knowledgeDocItemHandler))
|
||||
r.mux.HandleFunc("/api/v1/knowledge/search", r.authMW(r.knowledgeSearchHandler))
|
||||
|
||||
// Image analysis
|
||||
r.mux.HandleFunc("/api/v1/images/analyze", r.authMW(r.imageAnalyzeHandler))
|
||||
|
||||
|
||||
Reference in new issue
Block a user