feat(memory): hybrid vector search via embedder

- repository: optional pgvector embedding column (migration with
  CREATE EXTENSION guarded by main), SearchByVector cosine search,
  vector-enabled insert path
- service: SetEmbedder — memories are embedded on Add; Search merges
  vector hits with n-gram keyword matches (vector first, deduped)
- embedder was already implemented (OpenAI-compatible API + n-gram FNV
  fallback) but never instantiated; main now wires it from
  EMBEDDING_API_URL/EMBEDDING_MODEL config
This commit is contained in:
Aska committed 2026-08-20 20:57:13 +08:00
1 parent 8190007865
commit 8495a4b055
4 files changed
+119 -8

No files matched your search

+4
View File
@@ -19,6 +19,10 @@ type Memory struct {
LastAcc time.Time `json:"last_accessed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Embedding is the vector representation used for semantic search.
// Not serialized or scanned by default queries; pgvector-only.
Embedding []float64 `json:"-"`
}
// SearchQuery represents a memory search request.