Initial commit - BUBBLE decision tracking system
- Added core BUBBLE architecture with decision envelopes and policy store - Implemented bundle API with FastAPI skeleton and OpenAPI specification - Added Go-based storage implementation with SQLite and RocksDB support - Created integrations for peer sync, vector search, and N8N workflows - Added comprehensive testing framework and documentation - Implemented provenance walking and decision checking algorithms 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
22
src/integrations/27-vector-search-integration.py
Normal file
22
src/integrations/27-vector-search-integration.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from sentence_transformers import SentenceTransformer
|
||||
import faiss
|
||||
import numpy as np
|
||||
|
||||
# Load your embedding model once
|
||||
embedding_model = SentenceTransformer("all-MiniLM-L6-v2")
|
||||
|
||||
# Load FAISS index from disk (or create it on startup)
|
||||
faiss_index = faiss.read_index("dr_faiss.index")
|
||||
|
||||
# Map of vector index to DR IDs
|
||||
dr_id_map = {} # Load from persistent storage
|
||||
|
||||
def vector_search(query: str, top_k=3) -> list:
|
||||
vec = embedding_model.encode([query], convert_to_numpy=True)
|
||||
D, I = faiss_index.search(vec, top_k)
|
||||
results = []
|
||||
for dist, idx in zip(D[0], I[0]):
|
||||
dr_id = dr_id_map.get(idx)
|
||||
if dr_id:
|
||||
results.append({"id": dr_id, "distance": dist})
|
||||
return results
|
||||
Reference in New Issue
Block a user