Skip to content
Open
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
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,25 @@ AI Planning & Orchestration System built for the enterprise. Read more [here](ht

```python
from ai21 import AI21Client

client = AI21Client()

from ai21.models.chat import ChatMessage
client = AI21Client(api_key="your_API_key")
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("\n=== AI21 MAESTRO INFO ===")
print(run_result.result)
print()
```

For a more detailed example, see maestro [sync](examples/studio/maestro/run.py) and [async](examples/studio/maestro/async_run.py) examples.
Expand Down
16 changes: 9 additions & 7 deletions examples/studio/maestro/run.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
from ai21 import AI21Client

client = AI21Client()
from ai21.models.chat import ChatMessage
client = AI21Client(api_key="your_API_key")


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)
print("\n=== AI21 MAESTRO INFO ===")
print(run_result.result)
print()
except TimeoutError:
print("The run timed out")

Expand Down
Loading