feat: add FK-aware schema indexing with metadata across vector stores#9
feat: add FK-aware schema indexing with metadata across vector stores#9
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR refactors the vector indexing pipeline to support document-based indexing with metadata and relationship tracking. It introduces structured document payloads containing id, content, and metadata fields; updates vector store interfaces to enable kind-based filtering; refactors schema extraction to return both tables and relationships; and converts prompt generation from string output to role-based message lists. Changes
Sequence DiagramsequenceDiagram
participant API as NaturalSQL.build_vector_db()
participant Extractor as SQLSchemaExtractor
participant VectorMgr as VectorManager
participant Store as VectorStore (Chroma/SQLite)
API->>Extractor: extract_schema()
Extractor-->>API: {"tables": {...}, "relationships": [...]}
API->>Extractor: formated_for_ia(schema_bundle)
Extractor-->>API: [{id, content, metadata}, ...]<br/>(documents_payload)
API->>VectorMgr: index_documents(documents_payload)
VectorMgr->>VectorMgr: Build embeddings for each document
VectorMgr->>Store: upsert(documents, ids, embeddings, metadatas)
Store->>Store: Persist with kind filtering (table/relationship)
Store-->>VectorMgr: Success
Note over API,Store: Later: search_relevant_tables()
VectorMgr->>Store: query(embedding, limit, kind="table")
Store-->>VectorMgr: Table results
VectorMgr->>Store: query(embedding, limit, kind="relationship")
Store-->>VectorMgr: Relationship results
VectorMgr->>VectorMgr: Merge & sort by distance
VectorMgr-->>API: Ranked results
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
Release Notes
New Features
Improvements