Encode texts into embedding vectors. Returns: np.ndarray of shape (len(texts), dim).
(self, texts: Union[str, List[str]], **kwargs)
| 197 | provider=provider, |
| 198 | model=model, |
| 199 | temperature=temperature, |
| 200 | max_tokens=max_tokens, |
| 201 | api_key=api_key, |
| 202 | base_url=base_url, |
| 203 | ) |
| 204 | |
| 205 | # Per-context instance pool: {context_id: HippoRAG} |
| 206 | self._hipporag_instances: Dict[int, Any] = {} |
| 207 | # Accumulated session texts awaiting graph build: {context_id: [text, ...]} |
| 208 | self._pending_sessions: Dict[int, List[str]] = {} |
| 209 | self._session_counts: Dict[int, int] = {} |
| 210 | # Tracks whether index() has run (used to detect new evaluation units) |
| 211 | self._indexed_flags: Dict[int, bool] = {} |
| 212 | |
| 213 | self._setup_hipporag_path() |
| 214 | self._hipporag_modules_loaded = False |
| 215 | self._shared_embedding_model = None |
| 216 | |
| 217 | def _setup_hipporag_path(self): |
| 218 | """Add HippoRAG src to sys.path and mock missing optional modules (vllm).""" |
| 219 | hipporag_src = Path(__file__).resolve().parent / "HippoRAG" / "src" |
| 220 | if not hipporag_src.exists(): |
| 221 | raise ImportError(f"HippoRAG source folder not found at {hipporag_src}") |
| 222 | |
| 223 | hipporag_src_str = str(hipporag_src) |
| 224 | if hipporag_src_str not in sys.path: |
| 225 | sys.path.insert(0, hipporag_src_str) |
| 226 | |
| 227 | # Mock vllm module if not installed (only needed for offline mode) |
| 228 | if 'vllm' not in sys.modules: |
| 229 | try: |
| 230 | import vllm |
no test coverage detected