diff --git a/sdk/ai/azure-ai-projects/.env.template b/sdk/ai/azure-ai-projects/.env.template index 0ca16cf1517e..372246508144 100644 --- a/sdk/ai/azure-ai-projects/.env.template +++ b/sdk/ai/azure-ai-projects/.env.template @@ -41,6 +41,7 @@ SHAREPOINT_PROJECT_CONNECTION_ID= A2A_PROJECT_CONNECTION_ID= BROWSER_AUTOMATION_PROJECT_CONNECTION_ID= OPENAPI_PROJECT_CONNECTION_ID= +WORK_IQ_PROJECT_CONNECTION_ID= AI_SEARCH_USER_INPUT= SHAREPOINT_USER_INPUT= FABRIC_USER_INPUT= diff --git a/sdk/ai/azure-ai-projects/CHANGELOG.md b/sdk/ai/azure-ai-projects/CHANGELOG.md index 5f53a475e06e..3864773b2f2a 100644 --- a/sdk/ai/azure-ai-projects/CHANGELOG.md +++ b/sdk/ai/azure-ai-projects/CHANGELOG.md @@ -6,6 +6,7 @@ * New Agent tool `FabricIQPreviewTool`. * New Agent tool `ToolboxSearchPreviewTool`. +* New string properties `description` and `name` added to all Agent tools. * New `.beta.datasets` sub-client with data generation job operations: `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job`. * New read-only property `content_hash` on `CodeConfiguration`, returning the SHA-256 hex digest of the uploaded code zip. * New evaluator generation job operations on `.beta.evaluators`: `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job`. diff --git a/sdk/ai/azure-ai-projects/docs/subclients.md b/sdk/ai/azure-ai-projects/docs/subclients.md new file mode 100644 index 000000000000..e87bdabc8fd4 --- /dev/null +++ b/sdk/ai/azure-ai-projects/docs/subclients.md @@ -0,0 +1,90 @@ +# AIProjectClient Subclients + +This document lists all subclients available on `AIProjectClient` and their public method counts. + +## Top-level Subclients + +| Subclient | Class Name | Public Methods | +|-----------|------------|----------------| +| `agents` | AgentsOperations | 8 | +| `evaluation_rules` | EvaluationRulesOperations | 4 | +| `connections` | ConnectionsOperations | 3 | +| `datasets` | DatasetsOperations | 9 | +| `deployments` | DeploymentsOperations | 2 | +| `indexes` | IndexesOperations | 5 | +| `telemetry` | TelemetryOperations | 1 | +| `beta` | BetaOperations | 0 (container only) | + +## Nested Subclients on `.beta` + +| Subclient | Class Name | Public Methods | +|-----------|------------|----------------| +| `beta.agents` | BetaAgentsOperations | 10 | +| `beta.evaluation_taxonomies` | BetaEvaluationTaxonomiesOperations | 5 | +| `beta.evaluators` | BetaEvaluatorsOperations | 11 | +| `beta.insights` | BetaInsightsOperations | 3 | +| `beta.memory_stores` | BetaMemoryStoresOperations | 8 | +| `beta.red_teams` | BetaRedTeamsOperations | 3 | +| `beta.schedules` | BetaSchedulesOperations | 6 | +| `beta.toolboxes` | BetaToolboxesOperations | 8 | +| `beta.skills` | BetaSkillsOperations | 7 | +| `beta.datasets` | BetaDatasetsOperations | 5 | + +## Summary + +**Total: 98 unique public methods across all subclients** + +--- + +### Method Details + +#### AgentsOperations (8) +`get`, `delete`, `list`, `create_version`, `create_version_from_manifest`, `get_version`, `delete_version`, `list_versions` + +#### EvaluationRulesOperations (4) +`get`, `delete`, `create_or_update`, `list` + +#### ConnectionsOperations (3) +`list`, `get`, `get_default` + +#### DatasetsOperations (9) +`list_versions`, `list`, `get`, `delete`, `create_or_update`, `pending_upload`, `get_credentials`, `upload_file`, `upload_folder` + +#### DeploymentsOperations (2) +`get`, `list` + +#### IndexesOperations (5) +`list_versions`, `list`, `get`, `delete`, `create_or_update` + +#### TelemetryOperations (1) +`get_application_insights_connection_string` + +#### BetaAgentsOperations (10) +`patch_agent_details`, `create_session`, `get_session`, `delete_session`, `list_sessions`, `get_session_log_stream`, `download_session_file`, `get_session_files`, `delete_session_file`, `upload_session_file` + +#### BetaEvaluationTaxonomiesOperations (5) +`get`, `list`, `delete`, `create`, `update` + +#### BetaEvaluatorsOperations (11) +`list_versions`, `list`, `get_version`, `delete_version`, `create_version`, `update_version`, `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job` + +#### BetaInsightsOperations (3) +`generate`, `get`, `list` + +#### BetaMemoryStoresOperations (8) +`create`, `update`, `get`, `list`, `delete`, `delete_scope`, `search_memories`, `begin_update_memories` + +#### BetaRedTeamsOperations (3) +`get`, `list`, `create` + +#### BetaSchedulesOperations (6) +`delete`, `get`, `list`, `create_or_update`, `get_run`, `list_runs` + +#### BetaToolboxesOperations (8) +`create_version`, `get`, `list`, `list_versions`, `get_version`, `update`, `delete`, `delete_version` + +#### BetaSkillsOperations (7) +`create`, `create_from_package`, `get`, `download`, `list`, `update`, `delete` + +#### BetaDatasetsOperations (5) +`get_generation_job`, `list_generation_jobs`, `create_generation_job`, `cancel_generation_job`, `delete_generation_job` diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq_preview.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq_preview.py new file mode 100644 index 000000000000..c0350810abdc --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq_preview.py @@ -0,0 +1,101 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + This sample demonstrates how to create an AI agent with WorkIQ capabilities + using the WorkIQPreviewTool and synchronous Azure AI Projects client. The agent can + access Microsoft 365 data through WorkIQ to provide insights from emails, calendar events, + Teams messages, and other Microsoft 365 content. + + The sample shows: + - Creating an agent with WorkIQPreviewTool configured for Microsoft 365 data access + - Making requests that leverage WorkIQ to search and retrieve relevant information + - Processing responses with insights from Microsoft 365 content + +USAGE: + python sample_agent_work_iq_preview.py + + Before running the sample: + + pip install "azure-ai-projects>=2.1.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) WORK_IQ_PROJECT_CONNECTION_ID - The WorkIQ project connection ID, + as found in the "Connections" tab in your Microsoft Foundry project. +""" + +import os +from dotenv import load_dotenv +from azure.identity import DefaultAzureCredential +from azure.ai.projects import AIProjectClient +from azure.ai.projects.models import ( + PromptAgentDefinition, + WorkIQPreviewTool, + WorkIQPreviewToolParameters, +) + +load_dotenv() + +endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"] + +with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential) as project_client, + project_client.get_openai_client() as openai_client, +): + + tool = WorkIQPreviewTool( + work_iq_preview=WorkIQPreviewToolParameters( + project_connection_id=os.environ["WORK_IQ_PROJECT_CONNECTION_ID"] + ) + ) + + agent = project_client.agents.create_version( + agent_name="MyAgent", + definition=PromptAgentDefinition( + model=os.environ["FOUNDRY_MODEL_NAME"], + instructions="""You are a helpful assistant that can access Microsoft 365 data through WorkIQ. + Use the WorkIQ tool to search and retrieve information from emails, calendar events, + Teams messages, and other Microsoft 365 content to assist users with their questions.""", + tools=[tool], + ), + description="Agent with WorkIQ capabilities for Microsoft 365 data access.", + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + # Send a request that will trigger the WorkIQ tool + user_input = "What meetings do I have scheduled today?" + stream_response = openai_client.responses.create( + stream=True, + input=user_input, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + ) + + for event in stream_response: + if event.type == "response.created": + print(f"Response created with ID: {event.response.id}") + elif event.type == "response.output_text.delta": + print(f"Delta: {event.delta}") + elif event.type == "response.text.done": + print("\nResponse done!") + elif event.type == "response.output_item.done": + if event.item.type == "message": + item = event.item + if item.content[-1].type == "output_text": + text_content = item.content[-1] + for annotation in text_content.annotations: + if annotation.type == "url_citation": + print( + f"URL Citation: {annotation.url}, " + f"Start index: {annotation.start_index}, " + f"End index: {annotation.end_index}" + ) + elif event.type == "response.completed": + print("\nResponse completed!") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq_preview_non_streaming.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq_preview_non_streaming.py new file mode 100644 index 000000000000..4c88c9517de8 --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq_preview_non_streaming.py @@ -0,0 +1,82 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + This sample demonstrates how to create an AI agent with WorkIQ capabilities + using the WorkIQPreviewTool and synchronous Azure AI Projects client. The agent can + access Microsoft 365 data through WorkIQ to provide insights from emails, calendar events, + Teams messages, and other Microsoft 365 content. + + This non-streaming version waits for the complete response before returning. + + The sample shows: + - Creating an agent with WorkIQPreviewTool configured for Microsoft 365 data access + - Making requests that leverage WorkIQ to search and retrieve relevant information + - Processing responses with insights from Microsoft 365 content + +USAGE: + python sample_agent_work_iq_preview_non_streaming.py + + Before running the sample: + + pip install "azure-ai-projects>=2.1.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) WORK_IQ_PROJECT_CONNECTION_ID - The WorkIQ project connection ID, + as found in the "Connections" tab in your Microsoft Foundry project. +""" + +import os +from dotenv import load_dotenv +from azure.identity import DefaultAzureCredential +from azure.ai.projects import AIProjectClient +from azure.ai.projects.models import ( + PromptAgentDefinition, + WorkIQPreviewTool, + WorkIQPreviewToolParameters, +) + +load_dotenv() + +endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"] + +with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential) as project_client, + project_client.get_openai_client() as openai_client, +): + + tool = WorkIQPreviewTool( + work_iq_preview=WorkIQPreviewToolParameters( + project_connection_id=os.environ["WORK_IQ_PROJECT_CONNECTION_ID"] + ) + ) + + agent = project_client.agents.create_version( + agent_name="MyAgent", + definition=PromptAgentDefinition( + model=os.environ["FOUNDRY_MODEL_NAME"], + instructions="""You are a helpful assistant that can access Microsoft 365 data through WorkIQ. + Use the WorkIQ tool to search and retrieve information from emails, calendar events, + Teams messages, and other Microsoft 365 content to assist users with their questions.""", + tools=[tool], + ), + description="Agent with WorkIQ capabilities for Microsoft 365 data access.", + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + # Send a request that will trigger the WorkIQ tool (non-streaming) + user_input = "What meetings do I have scheduled today?" + response = openai_client.responses.create( + input=user_input, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + ) + + print(f"Response output: {response.output_text}")