Skip to content

Commit f8d8936

Browse files
author
Maryanne Gichohi
committed
Address PR comments
1 parent 72f7442 commit f8d8936

5 files changed

Lines changed: 109 additions & 91 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Azure App Configuration - AI Agent chat application
2+
3+
This sample demonstrates using Azure App Configuration to load agent YAML specifications that define AI agent behavior, prompts, and model configurations for a chat application.
4+
5+
## Features
6+
7+
- Integrates with Azure AI Agent Framework to create a conversational AI agent
8+
- Loads agent YAML specifications from Azure App Configuration.
9+
10+
## Prerequisites
11+
12+
- Python 3.8 or later
13+
- An Azure subscription with access to:
14+
- Azure App Configuration service
15+
- Microsoft Foundry project
16+
17+
## Setup
18+
19+
1. Clone the repository and navigate to the `examples\Python\ChatAgent` directory:
20+
```bash
21+
git clone https://github.com/Azure/AppConfiguration.git
22+
cd examples\Python\ChatAgent
23+
```
24+
25+
1. Next, create a new Python virtual environment where you can safely install the packages:
26+
27+
On macOS or Linux run the following command:
28+
```bash
29+
python -m venv .venv
30+
source .venv/bin/activate
31+
```
32+
33+
On Windows run:
34+
```bash
35+
python -m venv .venv
36+
.venv\scripts\activate
37+
```
38+
39+
1. Install the required packages:
40+
41+
```bash
42+
pip install -r requirements.txt
43+
```
44+
45+
1. Add the following key-values to your Azure App Configuration store.
46+
47+
| Key | Value |
48+
|-----|-------|
49+
| ChatAgent:Spec | _See YAML below_ |
50+
| CharAgent:ProjectEndpoint | _Your Foundry project endpoint_ |
51+
52+
**YAML specification for _ChatAgent:Spec_:**
53+
```yaml
54+
kind: Prompt
55+
name: ChatAgent
56+
description: Agent example with web search
57+
instructions: You are a helpful assistant with access to web search.
58+
model:
59+
id: gpt-4.1
60+
connection:
61+
kind: remote
62+
tools:
63+
- kind: web_search
64+
name: WebSearchTool
65+
description: Search the web for live information.
66+
```
67+
68+
1. Set the required environment variables:
69+
70+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
71+
72+
```cmd
73+
setx AZURE_APPCONFIGURATION_ENDPOINT "<endpoint-of-your-app-configuration-store>"
74+
```
75+
76+
If you use PowerShell, run the following command:
77+
```powershell
78+
$Env:AZURE_APPCONFIGURATION_ENDPOINT="<endpoint-of-your-app-configuration-store>"
79+
```
80+
81+
If you use macOS or Linux run the following command:
82+
```bash
83+
export AZURE_APPCONFIGURATION_ENDPOINT='<endpoint-of-your-app-configuration-store>'
84+
```
85+
86+
## Run the Application
87+
88+
1. Start the console application:
89+
90+
```bash
91+
python app.py
92+
```
93+
94+
2. Type the message "What is the weather in Seattle today?" when prompted with "How can I help?" and then press the Enter key
95+
96+
```output
97+
How can I help? (type 'quit' to exit)
98+
User: What is the weather today in Seattle ?
99+
Agent response: Today in Seattle, expect steady rain throughout the day with patchy fog, and a high temperature around 57°F (14°C).
100+
Winds are from the south-southwest at 14 to 17 mph, with gusts as high as 29 mph. Flood and wind advisories are in effect due to ongoing heavy rain and saturated conditions. Rain is likely to continue into the night, with a low near 49°F. Please stay aware of weather alerts if you are traveling or in low-lying areas [National Weather Service Seattle](https://forecast.weather.gov/zipcity.php?inputstring=Seattle%2CWA) [The Weather Channel Seattle Forecast](https://weather.com/weather/today/l/Seattle+Washington?canonicalCityId=1138ce33fd1be51ab7db675c0da0a27c).
101+
Press enter to continue...
102+
```
103+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ async def main():
1111

1212
config = load(endpoint=endpoint, credential=credential)
1313

14-
yaml_str = config["WeatherAgent:Spec"]
14+
yaml_str = config["ChatAgent:Spec"]
1515

1616
async with (
1717
AsyncDefaultCredential() as credential,
18-
AgentFactory(client_kwargs={"async_credential": credential, "project_endpoint": config["WeatherAgent:ProjectEndpoint"]}).create_agent_from_yaml(yaml_str) as agent,
18+
AgentFactory(client_kwargs={"async_credential": credential, "project_endpoint": config["ChatAgent:ProjectEndpoint"]}).create_agent_from_yaml(yaml_str) as agent,
1919
):
2020
while True:
2121
print("How can I help? (type 'quit' to exit)")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
agent-framework-azure-ai
2+
azure-appconfiguration
3+
azure-appconfiguration-provider
4+
azure-identity

examples/Python/WeatherAgent/README.md

Lines changed: 0 additions & 89 deletions
This file was deleted.
-196 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)