Skip to content

Commit abb8123

Browse files
authored
Fix openai samples (#44250)
1 parent 4fb5bb0 commit abb8123

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

sdk/ai/azure-ai-projects/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ tool = OpenApiAgentTool(
348348
openapi=OpenApiFunctionDefinition(
349349
name="get_weather",
350350
spec=openapi_weather,
351-
description="Retrieve weather information for a location",
351+
description="Retrieve weather information for a location.",
352352
auth=OpenApiAnonymousAuthDetails(),
353353
)
354354
)

sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
openapi=OpenApiFunctionDefinition(
5757
name="get_weather",
5858
spec=openapi_weather,
59-
description="Retrieve weather information for a location",
59+
description="Retrieve weather information for a location.",
6060
auth=OpenApiAnonymousAuthDetails(),
6161
)
6262
)
@@ -73,10 +73,11 @@
7373
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})")
7474

7575
response = openai_client.responses.create(
76-
input="What is the name and population of the country that uses currency with abbreviation THB?",
76+
input="Use the OpenAPI tool to print out, what is the weather in Seattle, WA today.",
7777
extra_body={"agent": {"name": agent.name, "type": "agent_reference"}},
7878
)
79-
print(f"Response created: {response.output_text}")
79+
# The response to the question may contain non ASCII letters. To avoid error, encode and re decode them.
80+
print(f"Response created: {response.output_text.encode().decode('ascii', errors='ignore')}")
8081

8182
print("\nCleaning up...")
8283
project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version)

sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi_with_project_connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@
8888
input="Recommend me 5 top hotels in paris, France",
8989
extra_body={"agent": {"name": agent.name, "type": "agent_reference"}},
9090
)
91-
print(f"Response created: {response.output_text}")
91+
# The response to the question may contain non ASCII letters. To avoid error, encode and re decode them.
92+
print(f"Response created: {response.output_text.encode().decode('ascii', errors='ignore')}")
9293

9394
print("\nCleaning up...")
9495
project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version)

0 commit comments

Comments
 (0)