Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ai21/clients/studio/resources/maestro/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def poll_for_status(self, *, run_id: str, poll_interval_sec: float, poll_timeout
return run

if (time.time() - start_time) >= poll_timeout_sec:
return run
raise TimeoutError(f"Timeout of {poll_timeout_sec} while polling for status of run with id {run_id}")

time.sleep(poll_interval_sec)

Expand Down Expand Up @@ -139,7 +139,7 @@ async def poll_for_status(self, *, run_id: str, poll_interval_sec: float, poll_t
return run

if (time.time() - start_time) >= poll_timeout_sec:
return run
raise TimeoutError(f"Timeout of {poll_timeout_sec} while polling for status of run with id {run_id}")

await asyncio.sleep(poll_interval_sec)

Expand Down
33 changes: 18 additions & 15 deletions examples/studio/maestro/async_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@


async def main():
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"],
)
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)
print(run_result)
except TimeoutError:
print("The run timed out")


if __name__ == "__main__":
Expand Down
33 changes: 18 additions & 15 deletions examples/studio/maestro/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@


def main():
run_result = 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"],
)
try:
run_result = 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)
print(run_result)
except TimeoutError:
print("The run timed out")


if __name__ == "__main__":
Expand Down
Loading