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:
|
def _get_embeddings(self, texts: list[str]) -> list[list[float]] | None:
|
||||||
"""Genereer embeddings via Mistral API."""
|
"""Genereer embeddings via Mistral API."""
|
||||||
try:
|
try:
|
||||||
resp = httpx.post(
|
transport = httpx.HTTPTransport(local_address="0.0.0.0")
|
||||||
MISTRAL_EMBED_URL,
|
with httpx.Client(transport=transport, timeout=30) as client:
|
||||||
headers={
|
resp = client.post(
|
||||||
"Authorization": f"Bearer {self.api_key}",
|
MISTRAL_EMBED_URL,
|
||||||
"Content-Type": "application/json",
|
headers={
|
||||||
},
|
"Authorization": f"Bearer {self.api_key}",
|
||||||
json={
|
"Content-Type": "application/json",
|
||||||
"model": MISTRAL_EMBED_MODEL,
|
},
|
||||||
"input": texts,
|
json={
|
||||||
},
|
"model": MISTRAL_EMBED_MODEL,
|
||||||
timeout=30,
|
"input": texts,
|
||||||
)
|
},
|
||||||
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
return [item["embedding"] for item in data["data"]]
|
return [item["embedding"] for item in data["data"]]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue