mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-09-30 19:59:34 +02:00
feat(add configurable network timeout):
This commit is contained in:
1 parent
0ce4aac682
commit
4b0b6987cb
2 files changed
+12
-3
No files matched your search
@@ -140,6 +140,8 @@ use_disk_cache = false
|
|||||||
|
|
||||||
[network]
|
[network]
|
||||||
retry = 3
|
retry = 3
|
||||||
|
timeout_connect = 30
|
||||||
|
timeout_response = 90
|
||||||
""".replace(
|
""".replace(
|
||||||
"$HOST", host
|
"$HOST", host
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -49,14 +49,21 @@ class LLMSpec(BaseModel):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise InvalidHTTPSpecError(f"Failed to parse HTTP spec: {e}") from 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 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(
|
response = await client.request(
|
||||||
method=self.method,
|
method=self.method,
|
||||||
url=self.url,
|
url=self.url,
|
||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
files=files,
|
files=files,
|
||||||
timeout=(30, 90),
|
timeout=self.timeout(),
|
||||||
)
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -100,7 +107,7 @@ class LLMSpec(BaseModel):
|
|||||||
url=self.url,
|
url=self.url,
|
||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
content=content,
|
content=content,
|
||||||
timeout=(30, 90),
|
timeout=self.timeout(),
|
||||||
)
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in new issue
Block a user