From 9e254cc953b3bc24d564bab1e8772ed6c44cdc45 Mon Sep 17 00:00:00 2001 From: Coornhert Date: Mon, 30 Mar 2026 11:57:10 +0200 Subject: [PATCH] fix: force IPv4 voor Mistral embedding API (IPv6 timeout op Hetzner) --- src/wetgit/ai/semantic.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) 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"]]