diff --git a/sdk/ai/azure-ai-projects/.env.template b/sdk/ai/azure-ai-projects/.env.template index a89bd766f143..14effd0c4418 100644 --- a/sdk/ai/azure-ai-projects/.env.template +++ b/sdk/ai/azure-ai-projects/.env.template @@ -62,6 +62,8 @@ WORK_IQ_PROJECT_CONNECTION_ID= WORK_IQ_USER_INPUT= FABRIC_IQ_PROJECT_CONNECTION_ID= FABRIC_IQ_USER_INPUT= +WEB_IQ_PROJECT_CONNECTION_ID= +WEB_IQ_USER_INPUT= AI_SEARCH_CONNECTION_NAME= INDEX_NAME= INDEX_VERSION= diff --git a/sdk/ai/azure-ai-projects/CHANGELOG.md b/sdk/ai/azure-ai-projects/CHANGELOG.md index 4c282c7c4883..52fdc2188ab1 100644 --- a/sdk/ai/azure-ai-projects/CHANGELOG.md +++ b/sdk/ai/azure-ai-projects/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.7.0 (Unreleased) + +### Sample updates + +* Added `sample_agent_web_iq.py` under `samples/agents/tools/`, demonstrating a Prompt Agent using the `WebIQPreviewTool`. + ## 2.6.0 (2026-09-04) ### Features Added diff --git a/sdk/ai/azure-ai-projects/assets.json b/sdk/ai/azure-ai-projects/assets.json index caef94c4b521..ec95a4d7b3d7 100644 --- a/sdk/ai/azure-ai-projects/assets.json +++ b/sdk/ai/azure-ai-projects/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/ai/azure-ai-projects", - "Tag": "python/ai/azure-ai-projects_80e35fe70b" + "Tag": "python/ai/azure-ai-projects_81db4bd08f" } diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_version.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_version.py index 454133e48caa..e626e19dbb69 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_version.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.6.0" +VERSION = "2.7.0" diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_iq.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_iq.py new file mode 100644 index 000000000000..05943496eb3e --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_iq.py @@ -0,0 +1,66 @@ +# pylint: disable=line-too-long,useless-suppression +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + This sample demonstrates how to run a Prompt Agent that uses the + WebIQ preview tool with a synchronous client. + +USAGE: + python sample_agent_web_iq.py + + Before running the sample: + + pip install "azure-ai-projects>=2.6.0" python-dotenv + + Set these environment variables with your own values: + 1) FOUNDRY_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview + page of your Microsoft Foundry portal. + 2) FOUNDRY_MODEL_NAME - The deployment name of the AI model, as found under the "Name" column in + the "Models + endpoints" tab in your Microsoft Foundry project. + 3) FOUNDRY_AGENT_NAME - Optional. The name of the AI agent. If not set, defaults to "MyAgent". + 4) WEB_IQ_PROJECT_CONNECTION_ID - The fully-qualified resource ID of the WebIQ project connection. + 5) WEB_IQ_USER_INPUT - Optional. The natural-language question to send to the agent. +""" + +import os + +from dotenv import load_dotenv +from util import create_version_with_endpoint + +from azure.ai.projects import AIProjectClient +from azure.ai.projects.models import PromptAgentDefinition, WebIQPreviewTool +from azure.identity import DefaultAzureCredential + +load_dotenv() + +endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"] +agent_name = os.environ.get("FOUNDRY_AGENT_NAME") or "MyAgent" + +web_iq_tool = WebIQPreviewTool( + project_connection_id=os.environ["WEB_IQ_PROJECT_CONNECTION_ID"], + require_approval="never", +) + +with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential, allow_preview=True) as project_client, + create_version_with_endpoint( + project_client=project_client, + agent_name=agent_name, + definition=PromptAgentDefinition( + model=os.environ["FOUNDRY_MODEL_NAME"], + instructions="Use the available WebIQ tool to answer the user's question.", + tools=[web_iq_tool], + ), + ), + project_client.get_openai_client(agent_name=agent_name) as openai_client, +): + user_input = os.environ.get("WEB_IQ_USER_INPUT") or input("Enter your question:\n") + + response = openai_client.responses.create(input=user_input) + + print(f"Agent response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/tests/test_base.py b/sdk/ai/azure-ai-projects/tests/test_base.py index 4069479fdcb3..5e6e48fef69f 100644 --- a/sdk/ai/azure-ai-projects/tests/test_base.py +++ b/sdk/ai/azure-ai-projects/tests/test_base.py @@ -57,6 +57,7 @@ sharepoint_project_connection_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sanitized-resource-group/providers/Microsoft.CognitiveServices/accounts/sanitized-account/projects/sanitized-project/connections/sanitized-sharepoint-connection", fabric_iq_project_connection_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sanitized-resource-group/providers/Microsoft.CognitiveServices/accounts/sanitized-account/projects/sanitized-project/connections/sanitized-fabric-iq-connection", work_iq_project_connection_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sanitized-resource-group/providers/Microsoft.CognitiveServices/accounts/sanitized-account/projects/sanitized-project/connections/sanitized-work-iq-connection", + web_iq_project_connection_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sanitized-resource-group/providers/Microsoft.CognitiveServices/accounts/sanitized-account/projects/sanitized-project/connections/sanitized-web-iq-connection", bing_custom_search_instance_name="sanitized-bing-custom-search-instance", completed_oai_model_sft_fine_tuning_job_id="sanitized-ftjob-id", completed_oai_model_rft_fine_tuning_job_id="sanitized-ftjob-id", @@ -73,6 +74,7 @@ bing_custom_user_input="Tell me more about foundry agent service", fabric_iq_user_input="Tell me weather history in London, Ohio", work_iq_user_input="What is the Work IQ?", + web_iq_user_input="What is Microsoft Foundry?", memory_store_chat_model_deployment_name="sanitized-model-deployment-name", memory_store_embedding_model_deployment_name="text-embedding-ada-002", foundry_agent_container_image="sanitizedregistry.azurecr.io/sanitized/sessions-agent:latest",