diff --git a/src/wetgit/ai/semantic.py b/src/wetgit/ai/semantic.py index fa05acf..3234c2c 100644 --- a/src/wetgit/ai/semantic.py +++ b/src/wetgit/ai/semantic.py @@ -165,18 +165,19 @@ class SemanticSearch: def _get_embeddings(self, texts: list[str]) -> list[list[float]] | None: """Genereer embeddings via Mistral API.""" try: - resp = httpx.post( - MISTRAL_EMBED_URL, - headers={ - "Authorization": f"Bearer {self.api_key}", - "Content-Type": "application/json", - }, - json={ - "model": MISTRAL_EMBED_MODEL, - "input": texts, - }, - timeout=30, - ) + transport = httpx.HTTPTransport(local_address="0.0.0.0") + with httpx.Client(transport=transport, timeout=30) as client: + resp = client.post( + MISTRAL_EMBED_URL, + headers={ + "Authorization": f"Bearer {self.api_key}", + "Content-Type": "application/json", + }, + json={ + "model": MISTRAL_EMBED_MODEL, + "input": texts, + }, + ) resp.raise_for_status() data = resp.json() return [item["embedding"] for item in data["data"]]