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
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,22 @@ from ai21 import AI21Client
client = AI21Client()

run_result = client.beta.maestro.runs.create_and_poll(
input="Write a poem about the ocean",
input="Tell me about AI21 Maestro",
requirements=[
{
"name": "length requirement",
"description": "The length of the poem should be less than 1000 characters",
"description": "The length of the response should be less than 2000 characters",
},
{
"name": "rhyme requirement",
"description": "The poem should rhyme",
"name": "source requirement",
"description": (
"Should rely on information from these websites: "
"https://www.ai21.com/, https://www.ai21.com/maestro/, "
"https://docs.ai21.com/home"
),
},
],
include=["requirements_result"]
include=["requirements_result"] # Include additional fields in the result
)
```

Expand Down
15 changes: 9 additions & 6 deletions examples/studio/maestro/async_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@
async def main():
try:
run_result = await client.beta.maestro.runs.create_and_poll(
input="Write a poem about the ocean",
input="Tell me about AI21 Maestro",
requirements=[
{
"name": "length requirement",
"description": "The length of the poem should be less than 1000 characters",
"description": "The length of the response should be less than 2000 characters",
},
{
"name": "rhyme requirement",
"description": "The poem should rhyme",
"name": "source requirement",
"description": (
"Should rely on information from these websites: "
"https://www.ai21.com/, https://www.ai21.com/maestro/, "
"https://docs.ai21.com/home"
),
},
],
include=["requirements_result"],
)

print(run_result)
print(run_result.result)
except TimeoutError:
print("The run timed out")

Expand Down
13 changes: 8 additions & 5 deletions examples/studio/maestro/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
def main():
try:
run_result = client.beta.maestro.runs.create_and_poll(
input="Write a poem about the ocean",
input="Tell me about AI21 Maestro",
requirements=[
{
"name": "length requirement",
"description": "The length of the poem should be less than 1000 characters",
"description": "The length of the response should be less than 2000 characters",
},
{
"name": "rhyme requirement",
"description": "The poem should rhyme",
"name": "source requirement",
"description": (
"Should rely on information from these websites: "
"https://www.ai21.com/, https://www.ai21.com/maestro/, "
"https://docs.ai21.com/home"
),
},
],
include=["requirements_result"],
)

print(run_result)
except TimeoutError:
print("The run timed out")
Expand Down
4 changes: 0 additions & 4 deletions tests/integration_tests/clients/test_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def test_studio(test_file_name: str):
argvalues=[
("chat/async_chat_completions.py",),
("chat/async_stream_chat_completions.py",),
("conversational_rag/conversational_rag.py",),
("conversational_rag/async_conversational_rag.py",),
("maestro/run.py",),
("maestro/async_run.py",),
("agents/agent_crud.py",),
Expand All @@ -61,8 +59,6 @@ def test_studio(test_file_name: str):
ids=[
"when_chat_completions__should_return_ok",
"when_stream_chat_completions__should_return_ok",
"when_conversational_rag__should_return_ok",
"when_async_conversational_rag__should_return_ok",
"when_maestro_runs__should_return_ok",
"when_maestro_async_runs__should_return_ok",
"when_agent_crud__should_return_ok",
Expand Down
Loading