fix: force IPv4 voor Mistral embedding API (IPv6 timeout op Hetzner)
This commit is contained in:
parent
df8a520b87
commit
9e254cc953
1 changed files with 13 additions and 12 deletions
|
|
@ -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"]]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue