Skip to content

Commit ef8959a

Browse files
authored
Test with recording for ai search and function tool samples (#44249)
* Test with recording for ai search and function tool samples * re-record
1 parent 46aef6a commit ef8959a

23 files changed

+294
-38
lines changed

sdk/ai/azure-ai-projects/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ai/azure-ai-projects",
5-
"Tag": "python/ai/azure-ai-projects_2204ef492a"
5+
"Tag": "python/ai/azure-ai-projects_d20bfd0fdc"
66
}

sdk/ai/azure-ai-projects/dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ opentelemetry-sdk
77
azure-core-tracing-opentelemetry
88
azure-monitor-opentelemetry
99
azure-mgmt-cognitiveservices
10-
10+
jsonref

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ def print_final_output(response):
159159
final_output += getattr(part, "text", None) or getattr(part, "refusal", None) or "" + "\n"
160160

161161
print(f"Final status: {response.status}")
162-
print(f"Final output: {final_output.strip()}")
162+
print(f"==> Result: {final_output.strip()}")

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
3) AI_SEARCH_PROJECT_CONNECTION_ID - The AI Search project connection ID,
2525
as found in the "Connections" tab in your Microsoft Foundry project.
2626
4) AI_SEARCH_INDEX_NAME - The name of the AI Search index to use for searching.
27+
5) AI_SEARCH_USER_INPUT - (Optional) The question to ask. If not set, you will be prompted.
2728
"""
2829

2930
import os
@@ -74,7 +75,10 @@
7475
)
7576
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})")
7677

77-
user_input = input("Enter your question (e.g., 'Tell me about mental health services'): \n")
78+
# Get user input from environment variable or prompt
79+
user_input = os.environ.get("AI_SEARCH_USER_INPUT")
80+
if not user_input:
81+
user_input = input("Enter your question (e.g., 'Tell me about mental health services'): \n")
7882

7983
stream_response = openai_client.responses.create(
8084
stream=True,
@@ -104,7 +108,7 @@
104108
)
105109
elif event.type == "response.completed":
106110
print(f"\nFollow-up completed!")
107-
print(f"Full response: {event.response.output_text}")
111+
print(f"==> Result: {event.response.output_text}")
108112

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

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@
100100
# Download the generated file if available
101101
if file_id and filename:
102102
file_content = openai_client.containers.files.content.retrieve(file_id=file_id, container_id=container_id)
103+
print(f"File ready for download: {filename}")
103104
with open(filename, "wb") as f:
104105
f.write(file_content.read())
105-
print(f"File {filename} downloaded successfully.")
106-
print(f"File ready for download: {filename}")
106+
107+
# Print result (should contain "file")
108+
print(f"==> Result: file, {filename} downloaded successfully.")
107109
else:
108110
print("No file generated in response")
109111

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ async def main() -> None:
103103
file_content = await openai_client.containers.files.content.retrieve(
104104
file_id=file_id, container_id=container_id
105105
)
106+
print(f"File ready for download: {filename}")
106107
with open(filename, "wb") as f:
107108
f.write(file_content.read())
108-
print(f"File {filename} downloaded successfully.")
109-
print(f"File ready for download: {filename}")
109+
110+
# Print result (should contain "file")
111+
print(f"==> Result: file, {filename} downloaded successfully.")
110112
else:
111113
print("No file generated in response")
112114

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Set these environment variables with your own values:
2626
1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview
2727
page of your Microsoft Foundry portal.
28-
2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
28+
2) (Optional) COMPUTER_USE_MODEL_DEPLOYMENT_NAME - The deployment name of the computer-use-preview model, as found under the "Name" column in
2929
the "Models + endpoints" tab in your Microsoft Foundry project.
3030
"""
3131

@@ -70,7 +70,7 @@
7070
agent = project_client.agents.create_version(
7171
agent_name="ComputerUseAgent",
7272
definition=PromptAgentDefinition(
73-
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
73+
model=os.environ.get("COMPUTER_USE_MODEL_DEPLOYMENT_NAME", "computer-use-preview"),
7474
instructions="""
7575
You are a computer automation assistant.
7676

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Set these environment variables with your own values:
2626
1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview
2727
page of your Microsoft Foundry portal.
28-
2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
28+
2) (Optional) COMPUTER_USE_MODEL_DEPLOYMENT_NAME - The deployment name of the computer-use-preview model, as found under the "Name" column in
2929
the "Models + endpoints" tab in your Microsoft Foundry project.
3030
"""
3131

@@ -72,7 +72,7 @@ async def main():
7272
agent = await project_client.agents.create_version(
7373
agent_name="ComputerUseAgent",
7474
definition=PromptAgentDefinition(
75-
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
75+
model=os.environ.get("COMPUTER_USE_MODEL_DEPLOYMENT_NAME", "computer-use-preview"),
7676
instructions="""
7777
You are a computer automation assistant.
7878

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@
7878
input="Tell me about Contoso products",
7979
extra_body={"agent": {"name": agent.name, "type": "agent_reference"}},
8080
)
81-
print(f"Response: {response.output_text}")
82-
81+
print(f"==> Result: {response.output_text}")
8382
print("\nCleaning up...")
8483
project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version)
8584
print("Agent deleted")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
print(f"File Citation - Filename: {annotation.filename}, File ID: {annotation.file_id}")
141141
elif event.type == "response.completed":
142142
print(f"\nFollow-up completed!")
143-
print(f"Full response: {event.response.output_text}")
143+
print(f"==> Result: {event.response.output_text}")
144144

145145
# Clean up resources
146146
print("\n" + "=" * 60)

0 commit comments

Comments
 (0)