MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / encode

Method encode

methods/hipporag_agent.py:199–227  ·  view source on GitHub ↗

Encode texts into embedding vectors. Returns: np.ndarray of shape (len(texts), dim).

(self, texts: Union[str, List[str]], **kwargs)

Source from the content-addressed store, hash-verified

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

Callers 2

batch_encodeMethod · 0.95
_encode_localMethod · 0.45

Calls 4

_lazy_initMethod · 0.95
_encode_localMethod · 0.95
_encode_apiMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected