Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Update sample output #11349

Merged
merged 2 commits into from
Apr 3, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
Loading