Files
bubble/src/integrations/27-vector-search-integration.py
anthonyrawlins 013e0dc3f0 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>
2025-08-27 09:35:03 +10:00

23 lines
706 B
Python

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