Improve docs

This commit is contained in:
Andras Schmelczer 2022-07-12 21:50:03 +02:00
parent b1a66cb579
commit 4e07161a16
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
4 changed files with 40 additions and 4 deletions

View file

@ -20,6 +20,11 @@ def call_remote_great_ai(
timeout_in_seconds: Optional[int] = 300,
model_class: Optional[Type[T]] = None,
) -> Trace[T]:
"""Communicate with a GreatAI object through an HTTP request.
Wrapper over `call_remote_great_ai_async` making it synchronous. For more info, see
`call_remote_great_ai_async`.
"""
try:
asyncio.get_running_loop()
raise Exception(

View file

@ -16,6 +16,23 @@ async def call_remote_great_ai_async(
timeout_in_seconds: Optional[int] = 300,
model_class: Optional[Type[T]] = None,
) -> Trace[T]:
"""Communicate with a GreatAI object through an HTTP request.
Send a POST request using [httpx](https://www.python-httpx.org/) to implement a
remote call. Error-handling and retries are provided by httpx.
The return value is inflated into a Trace. If `model_class` is specified, the
original output is deserialised.
Args:
base_uri: Address of the remote instance, example: 'http://localhost:6060'
data: The input sent as a json to the remote instance.
retry_count: Retry on any HTTP communication failure.
timeout_in_seconds: Overall permissable max length of the request. `None` means
no timeout.
model_class: A subtype of BaseModel to be used for deserialising the `.output`
of the trace.
"""
if base_uri.endswith("/"):
base_uri = base_uri[:-1]