diff --git a/python/samples/concepts/agents/openai_responses/responses_agent_message_callback.py b/python/samples/concepts/agents/openai_responses/responses_agent_message_callback.py index 2289003060c8..4dd2eab356de 100644 --- a/python/samples/concepts/agents/openai_responses/responses_agent_message_callback.py +++ b/python/samples/concepts/agents/openai_responses/responses_agent_message_callback.py @@ -101,7 +101,7 @@ async def main(): # AuthorRole.USER: 'What is the special drink?' # Host: The special drink is Chai Tea. # AuthorRole.USER: 'How much is that?' - # Host: Could you please specify the menu item you are asking about? + # Host: The Chai Tea is $9.99. Would you like to know more about the menu? # AuthorRole.USER: 'Thank you' # Host: You're welcome! If you have any questions about the menu or need assistance, feel free to ask. diff --git a/python/samples/concepts/agents/openai_responses/responses_agent_message_callback_streaming.py b/python/samples/concepts/agents/openai_responses/responses_agent_message_callback_streaming.py index f89c551406de..3d368bb8ad1f 100644 --- a/python/samples/concepts/agents/openai_responses/responses_agent_message_callback_streaming.py +++ b/python/samples/concepts/agents/openai_responses/responses_agent_message_callback_streaming.py @@ -109,7 +109,7 @@ async def main(): # AuthorRole.USER: 'What is the special drink?' # Host: The special drink is Chai Tea. # AuthorRole.USER: 'How much is that?' - # Host: Could you please specify the menu item you are asking about? + # Host: The Chai Tea is $9.99. Would you like to know more about the menu? # AuthorRole.USER: 'Thank you' # Host: You're welcome! If you have any questions about the menu or need assistance, feel free to ask. diff --git a/python/samples/concepts/agents/openai_responses/responses_agent_plugins_streaming.py b/python/samples/concepts/agents/openai_responses/responses_agent_plugins_streaming.py index ccec784cfeaa..bac6087fb8e9 100644 --- a/python/samples/concepts/agents/openai_responses/responses_agent_plugins_streaming.py +++ b/python/samples/concepts/agents/openai_responses/responses_agent_plugins_streaming.py @@ -78,15 +78,19 @@ async def main(): print() """ - You should see output similar to the following: - - # User: 'Why is the sky blue?' - # Agent: The sky appears blue because molecules in the atmosphere scatter sunlight in all directions, and blue - light is scattered more than other colors because it travels in shorter, smaller waves. - # User: 'What is the speed of light?' - # Agent: The speed of light in a vacuum is approximately 299,792,458 meters per second - (about 186,282 miles per second). - """ + Sample Output: + + # AuthorRole.USER: 'Hello' + # Host: Hi there! How can I assist you with the menu today? + # AuthorRole.USER: 'What is the special soup?' + # Host: The special soup is Clam Chowder. + # AuthorRole.USER: 'What is the special drink?' + # Host: The special drink is Chai Tea. + # AuthorRole.USER: 'How much is that?' + # Host: The Chai Tea is $9.99. Would you like to know more about the menu? + # AuthorRole.USER: 'Thank you' + # Host: You're welcome! If you have any questions about the menu or need assistance, feel free to ask. + """ if __name__ == "__main__": diff --git a/python/samples/getting_started_with_agents/openai_responses/step7_responses_agent_structured_outputs.py b/python/samples/getting_started_with_agents/openai_responses/step7_responses_agent_structured_outputs.py index 095af55efdf1..33aabacafebc 100644 --- a/python/samples/getting_started_with_agents/openai_responses/step7_responses_agent_structured_outputs.py +++ b/python/samples/getting_started_with_agents/openai_responses/step7_responses_agent_structured_outputs.py @@ -54,25 +54,43 @@ async def main(): print(f"# User: {str(user_input)}") # type: ignore # 5. Invoke the agent with the current chat history and print the response response = await agent.get_response(messages=user_input, thread=thread) - reasoned_result = Reasoning.model_validate(json.loads(str(response.content))) - print(f"# {response.name}:\n\n{reasoned_result.model_dump_json(indent=4)}") + reasoned_result = Reasoning.model_validate_json(response.message.content) + print(f"# {response.name}:\n\n{json.dumps(reasoned_result.model_dump(), indent=4, ensure_ascii=False)}") thread = response.thread # 6. Clean up the thread await thread.delete() if thread else None """ - You should see output similar to the following: - - # User: Describe this image. - # Agent: The image depicts a bustling scene of Times Square in New York City... - - # User: What is the main color in this image? - # Agent: The main color in the image is blue. - - # User: Is there an animal in this image? - # Agent: Yes, there is a cat in the image. - """ + # User: how can I solve 8x + 7y = -23, and 4x=12? + # StructuredOutputsAgent: + + { + "steps": [ + { + "explanation": "First, solve the equation 4x = 12 to find the value of x.", + "output": "4x = 12\nx = 12 / 4\nx = 3" + }, + { + "explanation": "Substitute x = 3 into the first equation 8x + 7y = -23.", + "output": "8(3) + 7y = -23" + }, + { + "explanation": "Perform the multiplication and simplify the equation.", + "output": "24 + 7y = -23" + }, + { + "explanation": "Subtract 24 from both sides to isolate the term with y.", + "output": "7y = -23 - 24\n7y = -47" + }, + { + "explanation": "Divide by 7 to solve for y.", + "output": "y = -47 / 7\ny = -6.71 (rounded to two decimal places)" + } + ], + "final_answer": "x = 3 and y = -6.71 (rounded to two decimal places)" + } + """ if __name__ == "__main__":