diff --git a/python/samples/getting_started/agents/azure_ai/README.md b/python/samples/getting_started/agents/azure_ai/README.md index aac3a7d01e..8fd883b0cb 100644 --- a/python/samples/getting_started/agents/azure_ai/README.md +++ b/python/samples/getting_started/agents/azure_ai/README.md @@ -8,6 +8,7 @@ This folder contains examples demonstrating different ways to create and use age |------|-------------| | [`azure_ai_basic.py`](azure_ai_basic.py) | The simplest way to create an agent using `AzureAIClient`. Demonstrates both streaming and non-streaming responses with function tools. Shows automatic agent creation and basic weather functionality. | | [`azure_ai_use_latest_version.py`](azure_ai_use_latest_version.py) | Demonstrates how to reuse the latest version of an existing agent instead of creating a new agent version on each instantiation using the `use_latest_version=True` parameter. | +| [`azure_ai_with_agent_to_agent.py`](azure_ai_with_agent_to_agent.py) | Shows how to use Agent-to-Agent (A2A) capabilities with Azure AI agents to enable communication with other agents using the A2A protocol. Requires an A2A connection configured in your Azure AI project. | | [`azure_ai_with_azure_ai_search.py`](azure_ai_with_azure_ai_search.py) | Shows how to use Azure AI Search with Azure AI agents to search through indexed data and answer user questions with proper citations. Requires an Azure AI Search connection and index configured in your Azure AI project. | | [`azure_ai_with_bing_grounding.py`](azure_ai_with_bing_grounding.py) | Shows how to use Bing Grounding search with Azure AI agents to search the web for current information and provide grounded responses with citations. Requires a Bing connection configured in your Azure AI project. | | [`azure_ai_with_bing_custom_search.py`](azure_ai_with_bing_custom_search.py) | Shows how to use Bing Custom Search with Azure AI agents to search custom search instances and provide responses with relevant results. Requires a Bing Custom Search connection and instance configured in your Azure AI project. | @@ -19,6 +20,7 @@ This folder contains examples demonstrating different ways to create and use age | [`azure_ai_with_file_search.py`](azure_ai_with_file_search.py) | Shows how to use the `HostedFileSearchTool` with Azure AI agents to upload files, create vector stores, and enable agents to search through uploaded documents to answer user questions. | | [`azure_ai_with_hosted_mcp.py`](azure_ai_with_hosted_mcp.py) | Shows how to integrate hosted Model Context Protocol (MCP) tools with Azure AI Agent. | | [`azure_ai_with_response_format.py`](azure_ai_with_response_format.py) | Shows how to use structured outputs (response format) with Azure AI agents using Pydantic models to enforce specific response schemas. | +| [`azure_ai_with_sharepoint.py`](azure_ai_with_sharepoint.py) | Shows how to use SharePoint grounding with Azure AI agents to search through SharePoint content and answer user questions with proper citations. Requires a SharePoint connection configured in your Azure AI project. | | [`azure_ai_with_thread.py`](azure_ai_with_thread.py) | Demonstrates thread management with Azure AI agents, including automatic thread creation for stateless conversations and explicit thread management for maintaining conversation context across multiple interactions. | | [`azure_ai_with_image_generation.py`](azure_ai_with_image_generation.py) | Shows how to use the `ImageGenTool` with Azure AI agents to generate images based on text prompts. | | [`azure_ai_with_microsoft_fabric.py`](azure_ai_with_microsoft_fabric.py) | Shows how to use Microsoft Fabric with Azure AI agents to query Fabric data sources and provide responses based on data analysis. Requires a Microsoft Fabric connection configured in your Azure AI project. | diff --git a/python/samples/getting_started/agents/azure_ai/azure_ai_with_agent_to_agent.py b/python/samples/getting_started/agents/azure_ai/azure_ai_with_agent_to_agent.py new file mode 100644 index 0000000000..8efb3d9473 --- /dev/null +++ b/python/samples/getting_started/agents/azure_ai/azure_ai_with_agent_to_agent.py @@ -0,0 +1,42 @@ +# Copyright (c) Microsoft. All rights reserved. +import asyncio +import os + +from agent_framework.azure import AzureAIClient +from azure.identity.aio import AzureCliCredential + +""" +Azure AI Agent with Agent-to-Agent (A2A) Example + +This sample demonstrates usage of AzureAIClient with Agent-to-Agent (A2A) capabilities +to enable communication with other agents using the A2A protocol. + +Prerequisites: +1. Set AZURE_AI_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME environment variables. +2. Ensure you have an A2A connection configured in your Azure AI project + and set A2A_PROJECT_CONNECTION_ID environment variable. +""" + + +async def main() -> None: + async with ( + AzureCliCredential() as credential, + AzureAIClient(async_credential=credential).create_agent( + name="MyA2AAgent", + instructions="""You are a helpful assistant that can communicate with other agents. + Use the A2A tool when you need to interact with other agents to complete tasks + or gather information from specialized agents.""", + tools={ + "type": "a2a_preview", + "project_connection_id": os.environ["A2A_PROJECT_CONNECTION_ID"], + }, + ) as agent, + ): + query = "What can the secondary agent do?" + print(f"User: {query}") + result = await agent.run(query) + print(f"Result: {result}\n") + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/python/samples/getting_started/agents/azure_ai/azure_ai_with_sharepoint.py b/python/samples/getting_started/agents/azure_ai/azure_ai_with_sharepoint.py new file mode 100644 index 0000000000..cdd81a33af --- /dev/null +++ b/python/samples/getting_started/agents/azure_ai/azure_ai_with_sharepoint.py @@ -0,0 +1,43 @@ +# Copyright (c) Microsoft. All rights reserved. +import asyncio +import os + +from agent_framework.azure import AzureAIClient +from azure.identity.aio import AzureCliCredential + +""" +Azure AI Agent with SharePoint Example + +This sample demonstrates usage of AzureAIClient with SharePoint +to search through SharePoint content and answer user questions about it. + +Prerequisites: +1. Set AZURE_AI_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME environment variables. +2. Ensure you have a SharePoint connection configured in your Azure AI project + and set SHAREPOINT_PROJECT_CONNECTION_ID environment variable. +""" + + +async def main() -> None: + async with ( + AzureCliCredential() as credential, + AzureAIClient(async_credential=credential).create_agent( + name="MySharePointAgent", + instructions="""You are a helpful agent that can use SharePoint tools to assist users. + Use the available SharePoint tools to answer questions and perform tasks.""", + tools={ + "type": "sharepoint_grounding_preview", + "sharepoint_grounding_preview": { + "project_connection_id": os.environ["SHAREPOINT_PROJECT_CONNECTION_ID"] + }, + }, + ) as agent, + ): + query = "What is Contoso whistleblower policy?" + print(f"User: {query}") + result = await agent.run(query) + print(f"Result: {result}\n") + + +if __name__ == "__main__": + asyncio.run(main())