|
46 | 46 | "pip install azure-ai-projects azure-identity azure-ai-evaluation\n", |
47 | 47 | "```\n", |
48 | 48 | "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", |
50 | 50 | "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", |
51 | 51 | "3) **AZURE_OPENAI_ENDPOINT** - Azure Open AI Endpoint to be used for evaluation.\n", |
52 | 52 | "4) **AZURE_OPENAI_API_KEY** - Azure Open AI Key to be used for evaluation.\n", |
53 | 53 | "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." |
58 | 55 | ] |
59 | 56 | }, |
60 | 57 | { |
|
73 | 70 | "import os\n", |
74 | 71 | "from azure.ai.projects import AIProjectClient\n", |
75 | 72 | "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", |
77 | 74 | "\n", |
78 | 75 | "# Import your custom functions to be used as Tools for the Agent\n", |
79 | 76 | "from user_functions import user_functions\n", |
80 | 77 | "\n", |
81 | | - "project_client = AIProjectClient.from_connection_string(\n", |
| 78 | + "project_client = AIProjectClient(\n", |
| 79 | + " endpoint=os.environ[\"AZURE_AI_PROJECT\"],\n", |
82 | 80 | " credential=DefaultAzureCredential(),\n", |
83 | | - " conn_str=os.environ[\"PROJECT_CONNECTION_STRING\"],\n", |
84 | 81 | ")\n", |
85 | 82 | "\n", |
86 | 83 | "AGENT_NAME = \"Seattle Tourist Assistant\"\n", |
|
92 | 89 | "toolset.add(functions)\n", |
93 | 90 | "\n", |
94 | 91 | "# 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)" |
96 | 93 | ] |
97 | 94 | }, |
98 | 95 | { |
|
131 | 128 | "metadata": {}, |
132 | 129 | "outputs": [], |
133 | 130 | "source": [ |
134 | | - "thread = project_client.agents.create_thread()\n", |
| 131 | + "thread = project_client.agents.threads.create()\n", |
135 | 132 | "print(f\"Created thread, ID: {thread.id}\")" |
136 | 133 | ] |
137 | 134 | }, |
|
162 | 159 | "\n", |
163 | 160 | "MESSAGE = \"Can you email me weather info for Seattle ?\"\n", |
164 | 161 | "\n", |
165 | | - "message = project_client.agents.create_message(\n", |
| 162 | + "message = project_client.agents.messages.create(\n", |
166 | 163 | " thread_id=thread.id,\n", |
167 | 164 | " role=\"user\",\n", |
168 | 165 | " content=MESSAGE,\n", |
|
183 | 180 | "metadata": {}, |
184 | 181 | "outputs": [], |
185 | 182 | "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", |
187 | 184 | "\n", |
188 | 185 | "print(f\"Run finished with status: {run.status}\")\n", |
189 | 186 | "\n", |
|
206 | 203 | "metadata": {}, |
207 | 204 | "outputs": [], |
208 | 205 | "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", |
210 | 207 | " print(f\"Role: {message.role}\")\n", |
211 | 208 | " print(f\"Content: {message.content[0].text.value}\")\n", |
212 | 209 | " print(\"-\" * 40)" |
|
284 | 281 | " azure_deployment=os.environ[\"MODEL_DEPLOYMENT_NAME\"],\n", |
285 | 282 | ")\n", |
286 | 283 | "# 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", |
292 | 285 | "\n", |
293 | 286 | "intent_resolution = IntentResolutionEvaluator(model_config=model_config)\n", |
294 | 287 | "\n", |
|
319 | 312 | " \"intent_resolution\": intent_resolution,\n", |
320 | 313 | " \"task_adherence\": task_adherence,\n", |
321 | 314 | " },\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", |
327 | 316 | ")\n", |
328 | 317 | "pprint(f'AI Foundary URL: {response.get(\"studio_url\")}')" |
329 | 318 | ] |
|
352 | 341 | ], |
353 | 342 | "metadata": { |
354 | 343 | "kernelspec": { |
355 | | - "display_name": "evaluate-agents-test", |
| 344 | + "display_name": "azureai-sample", |
356 | 345 | "language": "python", |
357 | 346 | "name": "python3" |
358 | 347 | }, |
|
0 commit comments