Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / class
HttpEmbedder
codeintel.embeddings.HttpEmbedder
PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.
PHAROS at 975a38dMIT license
Around this symbol
Search all symbolsLoading
| Symbol | File | Resolved by |
|---|---|---|
| get_embedder | embeddings.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| __init__ | embeddings.py | same file |
| _embed | embeddings.py | same file |
| _post | embeddings.py | same file |
| embed_documents | embeddings.py | same file |
| embed_query | embeddings.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| embeddings | embeddings.py | same file |
codeintel.embeddings.HttpEmbedderbackend/app/codeintel/embeddings.py, lines 235–280Open source
class HttpEmbedder(_PrefixMixin, Embedder): """Client for the edge worker's embed server. Uses ``POST /embed/batch`` (``{"texts": [...]}`` -> ``{"embeddings": [...]}``) and falls back to the single-text ``POST /embed`` of older servers. """ def __init__(self, base_url: str, model_name: str, token: str | None = None, timeout: float = 30.0): self.base_url = base_url.rstrip("/") self.model_name = model_name self.prefixes = _use_prefixes(model_name) self.model_id = model_name + ("+prefix" if self.prefixes else "") self.timeout = timeout self._headers = {"Authorization": f"Bearer {token}"} if token else {} self._batch_supported: bool | None = None def _post(self, path: str, payload: dict) -> dict: import httpx try: resp = httpx.post( f"{self.base_url}{path}", json=payload, headers=self._headers, timeout=self.timeout ) except httpx.HTTPError as exc: raise EmbeddingUnavailable(f"embedding server unreachable: {type(exc).__name__}") from exc if resp.status_code == 404 and path == "/embed/batch": raise FileNotFoundError if resp.status_code >= 400: raise EmbeddingUnavailable(f"embedding server returned HTTP {resp.status_code}") return resp.json() def _embed(self, texts: list[str]) -> list[list[float]]: if self._batch_supported is not False: try: data = self._post("/embed/batch", {"texts": texts}) self._batch_supported = True return [_pad(v, self.dim) for v in data["embeddings"]] except FileNotFoundError: self._batch_supported = False return [_pad(self._post("/embed", {"text": t})["embedding"], self.dim) for t in texts] def embed_documents(self, texts: list[str]) -> list[list[float]]: return self._embed([self._doc(t) for t in texts]) def embed_query(self, text: str) -> list[float]: return self._embed([self._query(text)])[0]What the index recorded
- Signature
class HttpEmbedder(_PrefixMixin, Embedder):- File
backend/app/codeintel/embeddings.py- Lines
- 235–280
- Parser
- python-ast
- Git blob
df7f8202f23ca6ad2c57aca5f09b435eb6486d79- Outside this subset
- 1 more edges reach code outside the graph shown here
