This commit is contained in:
Andras Schmelczer 2022-07-01 21:10:38 +02:00
commit 076f676f4f

View file

@ -8,10 +8,14 @@ from .remote_call_error import RemoteCallError
http: Optional[HttpClient] = None
T = TypeVar("T", BaseModel)
T = TypeVar("T", bound=BaseModel)
async def call_remote_great_ai_async(
base_uri: str, data: Mapping[str, Any], retry_count: int = 4, model_class:Optional[Type[T]]=None
base_uri: str,
data: Mapping[str, Any],
retry_count: int = 4,
model_class: Optional[Type[T]] = None,
) -> Trace[T]:
global http
if http is None:
@ -27,7 +31,7 @@ async def call_remote_great_ai_async(
try:
if model_class is not None:
response['output'] = model_class.parse_obj(response['output'])
response["output"] = model_class.parse_obj(response["output"])
return Trace.parse_obj(response)
except Exception:
raise RemoteCallError("Could not parse response")