forked from AI21Labs/ai21-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync_run.py
More file actions
31 lines (24 loc) · 792 Bytes
/
async_run.py
File metadata and controls
31 lines (24 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import asyncio
from ai21 import AsyncAI21Client
client = AsyncAI21Client()
async def main():
try:
run_result = await client.beta.maestro.runs.create_and_poll(
input="Write a poem about the ocean",
requirements=[
{
"name": "length requirement",
"description": "The length of the poem should be less than 1000 characters",
},
{
"name": "rhyme requirement",
"description": "The poem should rhyme",
},
],
include=["requirements_result"],
)
print(run_result)
except TimeoutError:
print("The run timed out")
if __name__ == "__main__":
asyncio.run(main())