Explore AI Agent development
In this exercise, you use the Azure AI Agent service tools in the Azure AI Foundry portal to create a simple AI agent that answers questions about expense claims.
This exercise takes approximately 30 minutes.
Create an Azure AI Foundry project
Let’s start by creating an Azure AI Foundry project.
-
In a web browser, open the Azure AI Foundry portal at
https://ai.azure.com
and sign in using your Azure credentials. Close any tips or quick start panes that are opened the first time you sign in, and if necessary use the Azure AI Foundry logo at the top left to navigate to the home page, which looks similar to the following image: - In the home page, select + Create project.
- In the Create a project wizard, enter a suitable project name for (for example,
my-ai-project
) then review the Azure resources that will be automatically created to support your project. - Select Customize and specify the following settings for your hub:
- Hub name: A unique name - for example
my-ai-hub
- Subscription: Your Azure subscription
- Resource group: Create a new resource group with a unique name (for example,
my-ai-resources
), or select an existing one - Location: Select Help me choose and then select gpt-4 in the Location helper window and use the recommended region*
- Connect Azure AI Services or Azure OpenAI: Create a new AI Services resource with an appropriate name (for example,
my-ai-services
) or use an existing one - Connect Azure AI Search: Skip connecting
* Model quotas are constrained at the tenant level by regional quotas. In the event of a quota limit being reached later in the exercise, there’s a possibility you may need to create another project in a different region.
- Hub name: A unique name - for example
- Select Next and review your configuration. Then select Create and wait for the process to complete.
-
When your project is created, close any tips that are displayed and review the project page in Azure AI Foundry portal, which should look similar to the following image:
Deploy a generative AI model
Now you’re ready to deploy a generative AI language model to support your agent.
- In the pane on the left for your project, in the My assets section, select the Models + endpoints page.
- In the Models + endpoints page, in the Model deployments tab, in the + Deploy model menu, select Deploy base model.
- Search for the gpt-4 model in the list, and then select and confirm it.
- Deploy the model with the following settings by selecting Customize in the deployment details:
- Deployment name: A unique name for your model deployment - for example
gpt-4-model
- Deployment type: Standard
- Model version: Select the default version
- Connected AI resource: Select your Azure OpenAI resource connection
- Tokens per Minute Rate Limit (thousands): 5K
- Content filter: DefaultV2
- Enable dynamic quota: Disabled
Note: Reducing the TPM helps avoid over-using the quota available in the subscription you are using. 5,000 TPM is sufficient for the data used in this exercise.
- Deployment name: A unique name for your model deployment - for example
- Wait for the deployment provisioning state to be Completed.
Create an AI agent
Now that you have a model deployed, you’re ready to build an AI agent. In this exercise, you’ll build a simple agent that answers questions based on a corporate expenses policy. You’ll download the expenses policy document, and use it as grounding data for the agent.
- Open another browser tab, and download Expenses_policy.docx from
https://raw.githubusercontent.com/MicrosoftLearning/mslearn-ai-agents/main/Labfiles/Expenses_Policy.docx
, saving it locally. This document contains details of the expenses policy for the fictional Contoso corporation. - Return to the browser tab containing the Azure AI Foundry portal, and in the navigation pane on the left, in the Build and customize section, select the Agents page.
-
Use the + New agent button to create a new agent. Then, in the Setup pane for your new agent, set the Agent name to
ExpensesAgent
, ensure that the gp-4 model deployment you created previously is selected, and set the Instructions toAnswer questions related to expense claims
. - Further down in the Setup pane, next to the Knowledge header, select + Add. Then in the Add knowledge dialog box, select Files.
-
In the Adding files dialog box, create a new vector store named
Expenses_Vector_Store
, uploading the Expenses_policy.docx local file that you downloaded previously. -
In the Setup pane, in the Knowledge section, verify that Expenses_Vector_Store is listed and shown as containing 1 file.
Note: You can also add Actions to an agent to automate tasks. In this simple information retrieval agent example, no actions are required.
Test your agent
Now that you’ve created an agent, you can test it in the Azure AI Foundry portal playground.
- At the top of the Setup pane for your agent, select Try in playground.
-
In the playground, enter the prompt
What's the maximum I can claim for meals?
and review the agent’s response - which should be based on information in the expenses policy document you added as knowledge to the agent setup. - Continue chatting with your agent, asking expenses related questions and reviewing the responses.
Clean up
Now that you’ve finished the exercise, you should delete the cloud resources you’ve created to avoid unnecessary resource usage.
- Open the Azure portal at
https://portal.azure.com
and view the contents of the resource group where you deployed the hub resources used in this exercise. - On the toolbar, select Delete resource group.
- Enter the resource group name and confirm that you want to delete it.