Skip to content

Commit 11abb6a

Browse files
moonbox3glorious-beard
authored andcommitted
Python: Update sample output (microsoft#11349)
### Motivation and Context Fix some sample output strings for OpenAIResponsesAgent samples. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Fix some sample output strings for OpenAIResponsesAgent samples. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄
1 parent a7622ec commit 11abb6a

File tree

4 files changed

+46
-24
lines changed

4 files changed

+46
-24
lines changed

python/samples/concepts/agents/openai_responses/responses_agent_message_callback.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def main():
101101
# AuthorRole.USER: 'What is the special drink?'
102102
# Host: The special drink is Chai Tea.
103103
# AuthorRole.USER: 'How much is that?'
104-
# Host: Could you please specify the menu item you are asking about?
104+
# Host: The Chai Tea is $9.99. Would you like to know more about the menu?
105105
# AuthorRole.USER: 'Thank you'
106106
# Host: You're welcome! If you have any questions about the menu or need assistance, feel free to ask.
107107

python/samples/concepts/agents/openai_responses/responses_agent_message_callback_streaming.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async def main():
109109
# AuthorRole.USER: 'What is the special drink?'
110110
# Host: The special drink is Chai Tea.
111111
# AuthorRole.USER: 'How much is that?'
112-
# Host: Could you please specify the menu item you are asking about?
112+
# Host: The Chai Tea is $9.99. Would you like to know more about the menu?
113113
# AuthorRole.USER: 'Thank you'
114114
# Host: You're welcome! If you have any questions about the menu or need assistance, feel free to ask.
115115

python/samples/concepts/agents/openai_responses/responses_agent_plugins_streaming.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,19 @@ async def main():
7878
print()
7979

8080
"""
81-
You should see output similar to the following:
82-
83-
# User: 'Why is the sky blue?'
84-
# Agent: The sky appears blue because molecules in the atmosphere scatter sunlight in all directions, and blue
85-
light is scattered more than other colors because it travels in shorter, smaller waves.
86-
# User: 'What is the speed of light?'
87-
# Agent: The speed of light in a vacuum is approximately 299,792,458 meters per second
88-
(about 186,282 miles per second).
89-
"""
81+
Sample Output:
82+
83+
# AuthorRole.USER: 'Hello'
84+
# Host: Hi there! How can I assist you with the menu today?
85+
# AuthorRole.USER: 'What is the special soup?'
86+
# Host: The special soup is Clam Chowder.
87+
# AuthorRole.USER: 'What is the special drink?'
88+
# Host: The special drink is Chai Tea.
89+
# AuthorRole.USER: 'How much is that?'
90+
# Host: The Chai Tea is $9.99. Would you like to know more about the menu?
91+
# AuthorRole.USER: 'Thank you'
92+
# Host: You're welcome! If you have any questions about the menu or need assistance, feel free to ask.
93+
"""
9094

9195

9296
if __name__ == "__main__":

python/samples/getting_started_with_agents/openai_responses/step7_responses_agent_structured_outputs.py

+31-13
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,43 @@ async def main():
5454
print(f"# User: {str(user_input)}") # type: ignore
5555
# 5. Invoke the agent with the current chat history and print the response
5656
response = await agent.get_response(messages=user_input, thread=thread)
57-
reasoned_result = Reasoning.model_validate(json.loads(str(response.content)))
58-
print(f"# {response.name}:\n\n{reasoned_result.model_dump_json(indent=4)}")
57+
reasoned_result = Reasoning.model_validate_json(response.message.content)
58+
print(f"# {response.name}:\n\n{json.dumps(reasoned_result.model_dump(), indent=4, ensure_ascii=False)}")
5959
thread = response.thread
6060

6161
# 6. Clean up the thread
6262
await thread.delete() if thread else None
6363

6464
"""
65-
You should see output similar to the following:
66-
67-
# User: Describe this image.
68-
# Agent: The image depicts a bustling scene of Times Square in New York City...
69-
70-
# User: What is the main color in this image?
71-
# Agent: The main color in the image is blue.
72-
73-
# User: Is there an animal in this image?
74-
# Agent: Yes, there is a cat in the image.
75-
"""
65+
# User: how can I solve 8x + 7y = -23, and 4x=12?
66+
# StructuredOutputsAgent:
67+
68+
{
69+
"steps": [
70+
{
71+
"explanation": "First, solve the equation 4x = 12 to find the value of x.",
72+
"output": "4x = 12\nx = 12 / 4\nx = 3"
73+
},
74+
{
75+
"explanation": "Substitute x = 3 into the first equation 8x + 7y = -23.",
76+
"output": "8(3) + 7y = -23"
77+
},
78+
{
79+
"explanation": "Perform the multiplication and simplify the equation.",
80+
"output": "24 + 7y = -23"
81+
},
82+
{
83+
"explanation": "Subtract 24 from both sides to isolate the term with y.",
84+
"output": "7y = -23 - 24\n7y = -47"
85+
},
86+
{
87+
"explanation": "Divide by 7 to solve for y.",
88+
"output": "y = -47 / 7\ny = -6.71 (rounded to two decimal places)"
89+
}
90+
],
91+
"final_answer": "x = 3 and y = -6.71 (rounded to two decimal places)"
92+
}
93+
"""
7694

7795

7896
if __name__ == "__main__":

0 commit comments

Comments
 (0)