fix: force IPv4 voor Mistral embedding API (IPv6 timeout op Hetzner)

This commit is contained in:
Coornhert 2026-03-30 11:57:10 +02:00
parent df8a520b87
commit 9e254cc953

View file

@ -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"]]