Improve remote call
This commit is contained in:
parent
5800557168
commit
6d57622ce3
2 changed files with 19 additions and 10 deletions
|
|
@ -13,7 +13,7 @@ async def call_remote_great_ai_async(
|
|||
base_uri: str,
|
||||
data: Mapping[str, Any],
|
||||
retry_count: int = 4,
|
||||
timeout_in_seconds: int = 300,
|
||||
timeout_in_seconds: Optional[int] = 300,
|
||||
model_class: Optional[Type[T]] = None,
|
||||
) -> Trace[T]:
|
||||
|
||||
|
|
@ -24,14 +24,18 @@ async def call_remote_great_ai_async(
|
|||
base_uri = f"{base_uri}/predict"
|
||||
|
||||
transport = httpx.AsyncHTTPTransport(retries=retry_count)
|
||||
async with httpx.AsyncClient(
|
||||
transport=transport, timeout=timeout_in_seconds
|
||||
) as client:
|
||||
response = await client.post(base_uri, json=data)
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except Exception:
|
||||
raise RemoteCallError("Unexpected status code")
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient(
|
||||
transport=transport, timeout=timeout_in_seconds
|
||||
) as client:
|
||||
response = await client.post(base_uri, json=data)
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except Exception:
|
||||
raise RemoteCallError("Unexpected status code")
|
||||
except Exception as e:
|
||||
raise RemoteCallError from e
|
||||
|
||||
try:
|
||||
trace = response.json()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue