feat(add configurable network timeout):

This commit is contained in:
Alexander Myasoedov
2025-02-21 19:30:03 +02:00
parent 0ce4aac682
commit 4b0b6987cb
2 changed files with 12 additions and 3 deletions
+2
View File
@@ -140,6 +140,8 @@ use_disk_cache = false
[network]
retry = 3
timeout_connect = 30
timeout_response = 90
""".replace(
"$HOST", host
)
+10 -3
View File
@@ -49,14 +49,21 @@ class LLMSpec(BaseModel):
except Exception as e:
raise InvalidHTTPSpecError(f"Failed to parse HTTP spec: {e}") from e
def timeout(self):
return (
settings_var("network.timeout_connect", 30),
settings_var("network.timeout_response", 90),
)
async def _probe_with_files(self, files):
async with httpx.AsyncClient() as client:
transport = httpx.AsyncHTTPTransport(retries=settings_var("network.retry", 3))
async with httpx.AsyncClient(transport=transport) as client:
response = await client.request(
method=self.method,
url=self.url,
headers=self.headers,
files=files,
timeout=(30, 90),
timeout=self.timeout(),
)
return response
@@ -100,7 +107,7 @@ class LLMSpec(BaseModel):
url=self.url,
headers=self.headers,
content=content,
timeout=(30, 90),
timeout=self.timeout(),
)
return response