Skip to content

Commit 1d818ae

Browse files
authored
Updating Agent Samples to use new Foundry Project (#281)
* Add files via upload * Removing loading env code * Running nb-clean
1 parent 20b8c07 commit 1d818ae

File tree

5 files changed

+31
-73
lines changed

5 files changed

+31
-73
lines changed

scenarios/evaluate/Supported_Evaluation_Metrics/Agent_Evaluation/AI_Judge_Evaluator_Intent_Resolution.ipynb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
"pip install azure-ai-projects azure-identity azure-ai-evaluation\n",
2424
"```\n",
2525
"Set these environment variables with your own values:\n",
26-
"1) **PROJECT_CONNECTION_STRING** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
26+
"1) **AZURE_AI_PROJECT** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
2727
"2) **MODEL_DEPLOYMENT_NAME** - The deployment name of the model for this AI-assisted evaluator, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project.\n",
2828
"3) **AZURE_OPENAI_ENDPOINT** - Azure Open AI Endpoint to be used for evaluation.\n",
2929
"4) **AZURE_OPENAI_API_KEY** - Azure Open AI Key to be used for evaluation.\n",
30-
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n",
31-
"6) **AZURE_SUBSCRIPTION_ID** - Azure Subscription Id of Azure AI Project\n",
32-
"7) **PROJECT_NAME** - Azure AI Project Name\n",
33-
"8) **RESOURCE_GROUP_NAME** - Azure AI Project Resource Group Name\n"
30+
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation."
3431
]
3532
},
3633
{
@@ -324,19 +321,15 @@
324321
" evaluators={\n",
325322
" \"intent_resolution\": intent_resolution_evaluator,\n",
326323
" },\n",
327-
" azure_ai_project={\n",
328-
" \"subscription_id\": os.environ[\"AZURE_SUBSCRIPTION_ID\"],\n",
329-
" \"project_name\": os.environ[\"PROJECT_NAME\"],\n",
330-
" \"resource_group_name\": os.environ[\"RESOURCE_GROUP_NAME\"],\n",
331-
" },\n",
324+
" azure_ai_project=os.environ[\"AZURE_AI_PROJECT\"],\n",
332325
")\n",
333326
"pprint(f'AI Foundary URL: {response.get(\"studio_url\")}')"
334327
]
335328
}
336329
],
337330
"metadata": {
338331
"kernelspec": {
339-
"display_name": "test_agent_eval_sample",
332+
"display_name": "azureai-sample",
340333
"language": "python",
341334
"name": "python3"
342335
},

scenarios/evaluate/Supported_Evaluation_Metrics/Agent_Evaluation/AI_Judge_Evaluator_Task_Adherence.ipynb

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@
2525
"pip install azure-ai-projects azure-identity azure-ai-evaluation\n",
2626
"```\n",
2727
"Set these environment variables with your own values:\n",
28-
"1) **PROJECT_CONNECTION_STRING** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
28+
"1) **AZURE_AI_PROJECT** - The project url, as found in the overview page of your Azure AI Foundry project.\n",
2929
"2) **MODEL_DEPLOYMENT_NAME** - The deployment name of the model for this AI-assisted evaluator, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project.\n",
3030
"3) **AZURE_OPENAI_ENDPOINT** - Azure Open AI Endpoint to be used for evaluation.\n",
3131
"4) **AZURE_OPENAI_API_KEY** - Azure Open AI Key to be used for evaluation.\n",
32-
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n",
33-
"6) **AZURE_SUBSCRIPTION_ID** - Azure Subscription Id of Azure AI Project\n",
34-
"7) **PROJECT_NAME** - Azure AI Project Name\n",
35-
"8) **RESOURCE_GROUP_NAME** - Azure AI Project Resource Group Name\n"
32+
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n"
3633
]
3734
},
3835
{
@@ -47,14 +44,11 @@
4744
"pip install azure-ai-projects azure-identity azure-ai-evaluation\n",
4845
"```\n",
4946
"Set these environment variables with your own values:\n",
50-
"1) **PROJECT_CONNECTION_STRING** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
47+
"1) **AZURE_AI_PROJECT** - The project url, as found in the overview page of your Azure AI Foundry project.\n",
5148
"2) **MODEL_DEPLOYMENT_NAME** - The deployment name of the AI model, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project.\n",
5249
"3) **AZURE_OPENAI_ENDPOINT** - Azure Open AI Endpoint to be used for evaluation.\n",
5350
"4) **AZURE_OPENAI_API_KEY** - Azure Open AI Key to be used for evaluation.\n",
54-
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n",
55-
"6) **AZURE_SUBSCRIPTION_ID** - Azure Subscription Id of Azure AI Project\n",
56-
"7) **PROJECT_NAME** - Azure AI Project Name\n",
57-
"8) **RESOURCE_GROUP_NAME** - Azure AI Project Resource Group Name"
51+
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation."
5852
]
5953
},
6054
{
@@ -262,19 +256,15 @@
262256
" evaluators={\n",
263257
" \"task_adherence\": task_adherence_evaluator,\n",
264258
" },\n",
265-
" azure_ai_project={\n",
266-
" \"subscription_id\": os.environ[\"AZURE_SUBSCRIPTION_ID\"],\n",
267-
" \"project_name\": os.environ[\"PROJECT_NAME\"],\n",
268-
" \"resource_group_name\": os.environ[\"RESOURCE_GROUP_NAME\"],\n",
269-
" },\n",
259+
" azure_ai_project=os.environ[\"AZURE_AI_PROJECT\"],\n",
270260
")\n",
271261
"pprint(f'AI Foundary URL: {response.get(\"studio_url\")}')"
272262
]
273263
}
274264
],
275265
"metadata": {
276266
"kernelspec": {
277-
"display_name": "test_agent_eval_sample",
267+
"display_name": "azureai-sample",
278268
"language": "python",
279269
"name": "python3"
280270
},

scenarios/evaluate/Supported_Evaluation_Metrics/Agent_Evaluation/AI_Judge_Evaluator_Tool_Call_Accuracy.ipynb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
"pip install azure-ai-projects azure-identity azure-ai-evaluation\n",
2424
"```\n",
2525
"Set these environment variables with your own values:\n",
26-
"1) **PROJECT_CONNECTION_STRING** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
26+
"1) **AZURE_AI_PROJECT** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
2727
"2) **MODEL_DEPLOYMENT_NAME** - The deployment name of the model for this AI-assisted evaluator, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project.\n",
2828
"3) **AZURE_OPENAI_ENDPOINT** - Azure Open AI Endpoint to be used for evaluation.\n",
2929
"4) **AZURE_OPENAI_API_KEY** - Azure Open AI Key to be used for evaluation.\n",
30-
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n",
31-
"6) **AZURE_SUBSCRIPTION_ID** - Azure Subscription Id of Azure AI Project\n",
32-
"7) **PROJECT_NAME** - Azure AI Project Name\n",
33-
"8) **RESOURCE_GROUP_NAME** - Azure AI Project Resource Group Name\n"
30+
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n"
3431
]
3532
},
3633
{
@@ -328,19 +325,15 @@
328325
" evaluators={\n",
329326
" \"tool_call_accuracy\": tool_call_accuracy,\n",
330327
" },\n",
331-
" azure_ai_project={\n",
332-
" \"subscription_id\": os.environ[\"AZURE_SUBSCRIPTION_ID\"],\n",
333-
" \"project_name\": os.environ[\"PROJECT_NAME\"],\n",
334-
" \"resource_group_name\": os.environ[\"RESOURCE_GROUP_NAME\"],\n",
335-
" },\n",
328+
" azure_ai_project=os.environ[\"AZURE_AI_PROJECT\"],\n",
336329
")\n",
337330
"pprint(f'AI Foundary URL: {response.get(\"studio_url\")}')"
338331
]
339332
}
340333
],
341334
"metadata": {
342335
"kernelspec": {
343-
"display_name": "test_agent_eval_sample",
336+
"display_name": "azureai-sample",
344337
"language": "python",
345338
"name": "python3"
346339
},

scenarios/evaluate/Supported_Evaluation_Metrics/Agent_Evaluation/AI_Judge_Evaluators_Response_Completeness.ipynb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@
2727
"pip install azure-ai-projects azure-identity azure-ai-evaluation\n",
2828
"```\n",
2929
"Set these environment variables with your own values:\n",
30-
"1) **PROJECT_CONNECTION_STRING** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
30+
"1) **AZURE_AI_PROJECT** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
3131
"2) **MODEL_DEPLOYMENT_NAME** - The deployment name of the model for this AI-assisted evaluator, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project.\n",
3232
"3) **AZURE_OPENAI_ENDPOINT** - Azure Open AI Endpoint to be used for evaluation.\n",
3333
"4) **AZURE_OPENAI_API_KEY** - Azure Open AI Key to be used for evaluation.\n",
34-
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n",
35-
"6) **AZURE_SUBSCRIPTION_ID** - Azure Subscription Id of Azure AI Project\n",
36-
"7) **PROJECT_NAME** - Azure AI Project Name\n",
37-
"8) **RESOURCE_GROUP_NAME** - Azure AI Project Resource Group Name\n"
34+
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n"
3835
]
3936
},
4037
{
@@ -197,11 +194,7 @@
197194
"source": [
198195
"from azure.ai.evaluation import evaluate\n",
199196
"\n",
200-
"azure_ai_project = {\n",
201-
" \"subscription_id\": os.environ[\"AZURE_SUBSCRIPTION_ID\"],\n",
202-
" \"project_name\": os.environ[\"PROJECT_NAME\"],\n",
203-
" \"resource_group_name\": os.environ[\"RESOURCE_GROUP_NAME\"],\n",
204-
"}\n",
197+
"azure_ai_project = os.environ[\"AZURE_AI_PROJECT\"]\n",
205198
"\n",
206199
"response = evaluate(\n",
207200
" data=file_path,\n",
@@ -217,7 +210,7 @@
217210
],
218211
"metadata": {
219212
"kernelspec": {
220-
"display_name": "test_agent_eval_sample",
213+
"display_name": "azureai-sample",
221214
"language": "python",
222215
"name": "python3"
223216
},

scenarios/evaluate/Supported_Evaluation_Metrics/Agent_Evaluation/Evaluate_Azure_AI_Agent_Quality.ipynb

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@
4646
"pip install azure-ai-projects azure-identity azure-ai-evaluation\n",
4747
"```\n",
4848
"Set these environment variables with your own values:\n",
49-
"1) **PROJECT_CONNECTION_STRING** - The project connection string, as found in the overview page of your Azure AI Foundry project.\n",
49+
"1) **AZURE_AI_PROJECT** - The project url, as found in the overview page of your Azure AI Foundry project.\n",
5050
"2) **MODEL_DEPLOYMENT_NAME** - The deployment name of the model for AI-assisted evaluators, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project.\n",
5151
"3) **AZURE_OPENAI_ENDPOINT** - Azure Open AI Endpoint to be used for evaluation.\n",
5252
"4) **AZURE_OPENAI_API_KEY** - Azure Open AI Key to be used for evaluation.\n",
5353
"5) **AZURE_OPENAI_API_VERSION** - Azure Open AI Api version to be used for evaluation.\n",
54-
"6) **AZURE_SUBSCRIPTION_ID** - Azure Subscription Id of Azure AI Project\n",
55-
"7) **PROJECT_NAME** - Azure AI Project Name\n",
56-
"8) **RESOURCE_GROUP_NAME** - Azure AI Project Resource Group Name\n",
57-
"9) **AGENT_MODEL_DEPLOYMENT_NAME** - The deployment name of the model for your Azure AI agent, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project."
54+
"6) **AGENT_MODEL_DEPLOYMENT_NAME** - The deployment name of the model for your Azure AI agent, as found under the \"Name\" column in the \"Models + endpoints\" tab in your Azure AI Foundry project."
5855
]
5956
},
6057
{
@@ -73,14 +70,14 @@
7370
"import os\n",
7471
"from azure.ai.projects import AIProjectClient\n",
7572
"from azure.identity import DefaultAzureCredential\n",
76-
"from azure.ai.projects.models import FunctionTool, ToolSet\n",
73+
"from azure.ai.agents.models import FunctionTool, ToolSet\n",
7774
"\n",
7875
"# Import your custom functions to be used as Tools for the Agent\n",
7976
"from user_functions import user_functions\n",
8077
"\n",
81-
"project_client = AIProjectClient.from_connection_string(\n",
78+
"project_client = AIProjectClient(\n",
79+
" endpoint=os.environ[\"AZURE_AI_PROJECT\"],\n",
8280
" credential=DefaultAzureCredential(),\n",
83-
" conn_str=os.environ[\"PROJECT_CONNECTION_STRING\"],\n",
8481
")\n",
8582
"\n",
8683
"AGENT_NAME = \"Seattle Tourist Assistant\"\n",
@@ -92,7 +89,7 @@
9289
"toolset.add(functions)\n",
9390
"\n",
9491
"# To enable tool calls executed automatically\n",
95-
"project_client.agents.enable_auto_function_calls(toolset=toolset)"
92+
"project_client.agents.enable_auto_function_calls(toolset)"
9693
]
9794
},
9895
{
@@ -131,7 +128,7 @@
131128
"metadata": {},
132129
"outputs": [],
133130
"source": [
134-
"thread = project_client.agents.create_thread()\n",
131+
"thread = project_client.agents.threads.create()\n",
135132
"print(f\"Created thread, ID: {thread.id}\")"
136133
]
137134
},
@@ -162,7 +159,7 @@
162159
"\n",
163160
"MESSAGE = \"Can you email me weather info for Seattle ?\"\n",
164161
"\n",
165-
"message = project_client.agents.create_message(\n",
162+
"message = project_client.agents.messages.create(\n",
166163
" thread_id=thread.id,\n",
167164
" role=\"user\",\n",
168165
" content=MESSAGE,\n",
@@ -183,7 +180,7 @@
183180
"metadata": {},
184181
"outputs": [],
185182
"source": [
186-
"run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)\n",
183+
"run = project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)\n",
187184
"\n",
188185
"print(f\"Run finished with status: {run.status}\")\n",
189186
"\n",
@@ -206,7 +203,7 @@
206203
"metadata": {},
207204
"outputs": [],
208205
"source": [
209-
"for message in project_client.agents.list_messages(thread.id, order=\"asc\").data:\n",
206+
"for message in project_client.agents.messages.list(thread.id, order=\"asc\"):\n",
210207
" print(f\"Role: {message.role}\")\n",
211208
" print(f\"Content: {message.content[0].text.value}\")\n",
212209
" print(\"-\" * 40)"
@@ -284,11 +281,7 @@
284281
" azure_deployment=os.environ[\"MODEL_DEPLOYMENT_NAME\"],\n",
285282
")\n",
286283
"# Needed to use content safety evaluators\n",
287-
"azure_ai_project = {\n",
288-
" \"subscription_id\": os.environ[\"AZURE_SUBSCRIPTION_ID\"],\n",
289-
" \"project_name\": os.environ[\"PROJECT_NAME\"],\n",
290-
" \"resource_group_name\": os.environ[\"RESOURCE_GROUP_NAME\"],\n",
291-
"}\n",
284+
"azure_ai_project = os.environ[\"AZURE_AI_PROJECT\"]\n",
292285
"\n",
293286
"intent_resolution = IntentResolutionEvaluator(model_config=model_config)\n",
294287
"\n",
@@ -319,11 +312,7 @@
319312
" \"intent_resolution\": intent_resolution,\n",
320313
" \"task_adherence\": task_adherence,\n",
321314
" },\n",
322-
" azure_ai_project={\n",
323-
" \"subscription_id\": os.environ[\"AZURE_SUBSCRIPTION_ID\"],\n",
324-
" \"project_name\": os.environ[\"PROJECT_NAME\"],\n",
325-
" \"resource_group_name\": os.environ[\"RESOURCE_GROUP_NAME\"],\n",
326-
" },\n",
315+
" azure_ai_project=azure_ai_project,\n",
327316
")\n",
328317
"pprint(f'AI Foundary URL: {response.get(\"studio_url\")}')"
329318
]
@@ -352,7 +341,7 @@
352341
],
353342
"metadata": {
354343
"kernelspec": {
355-
"display_name": "evaluate-agents-test",
344+
"display_name": "azureai-sample",
356345
"language": "python",
357346
"name": "python3"
358347
},

0 commit comments

Comments
 (0)