Spaces:
Sleeping
Sleeping
| """ | |
| embeddings.py — single source of the embedding function used by BOTH ingest.py | |
| and search.py (they must match, or query vectors won't align with the index). | |
| Uses Chroma's built-in ONNX all-MiniLM-L6-v2 (onnxruntime). This deliberately | |
| avoids torch / sentence-transformers, whose unsigned DLLs get blocked by Windows | |
| App Control on managed devices. onnxruntime's DLLs are signed and pass. | |
| """ | |
| from chromadb.utils import embedding_functions | |
| _ef = None | |
| def get_embedding_function(): | |
| """Return a shared ONNX MiniLM embedding function (cached).""" | |
| global _ef | |
| if _ef is None: | |
| # DefaultEmbeddingFunction == ONNXMiniLM_L6_V2 in current chromadb. | |
| _ef = embedding_functions.DefaultEmbeddingFunction() | |
| return _ef | |