Add remote calls
This commit is contained in:
parent
a63b0ad5e7
commit
e16db17db0
1 changed files with 217 additions and 2 deletions
26
src/great_ai/great_ai/remote/call_remote_great_ai.py
Normal file
26
src/great_ai/great_ai/remote/call_remote_great_ai.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import asyncio
|
||||
from typing import Any, Mapping
|
||||
|
||||
from ...utilities import get_logger
|
||||
from ..views import Trace
|
||||
from .call_remote_great_ai_async import call_remote_great_ai_async
|
||||
|
||||
logger = get_logger("call_remote_great_ai")
|
||||
|
||||
|
||||
def call_remote_great_ai(
|
||||
base_uri: str, data: Mapping[str, Any], retry_count: int = 4
|
||||
) -> Trace:
|
||||
try:
|
||||
asyncio.get_running_loop()
|
||||
raise Exception(
|
||||
f"Already running in an event loop, you have to call `{call_remote_great_ai_async.__name__}`"
|
||||
)
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
future = call_remote_great_ai_async(
|
||||
base_uri=base_uri, data=data, retry_count=retry_count
|
||||
)
|
||||
|
||||
return asyncio.run(future)
|
||||
Loading…
Reference in a new issue