From c7749aef9a0ca2b50d7cee7898d3597242dbb36f Mon Sep 17 00:00:00 2001 From: Moti Tenzer Date: Wed, 12 Nov 2025 15:29:43 +0200 Subject: [PATCH] Update Maestro example to demonstrate AI21 info retrieval --- README.md | 17 ++++++++++------- examples/studio/maestro/run.py | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 76350901..2ca6697b 100644 --- a/README.md +++ b/README.md @@ -255,22 +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. diff --git a/examples/studio/maestro/run.py b/examples/studio/maestro/run.py index 72024f33..4c7c2dd3 100644 --- a/examples/studio/maestro/run.py +++ b/examples/studio/maestro/run.py @@ -1,24 +1,27 @@ from ai21 import AI21Client - -client = AI21Client() +from ai21.models.chat import ChatMessage +client = AI21Client(api_key="your_API_key") def main(): 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() if __name__ == "__main__":