Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions examples/Python/ai-agent-sample-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Azure App Configuration - AI Agent chat application

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.

## Features

- Integrates with Azure AI Agent Framework to create a conversational AI agent
- Loads agent YAML specifications from Azure App Configuration.

## Prerequisites

- Python 3.8 or later
- An Azure subscription with access to:
- Azure App Configuration service
- Microsoft Foundry project
- Required environment variables:
- `AZURE_APPCONFIGURATION_ENDPOINT`: Endpoint URL of your Azure App Configuration instance

## Setup

1. Clone the repository
1. Install the required packages:

```bash
pip install -r requirements.txt
```

1. Configure your Azure App Configuration store with the agent YAML specification:

```yaml
kind: Prompt
name: WeatherAgent
description: Weather Agent
instructions: You are a helpful assistant.
model:
id: gpt-4.1
connection:
kind: remote
```

1. Configure your Azure App Configuration store with project endpoint:

```console
Agent:ProjectEndpoint - Your Foundry project endpoint
```

1. Set the required environment variables:

```bash
export AZURE_APPCONFIGURATION_ENDPOINT="https://your-appconfig.azconfig.io"
```

## Running the Application

Start the console application:

```bash
python app.py
```
35 changes: 35 additions & 0 deletions examples/Python/ai-agent-sample-app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import asyncio
import os
from agent_framework.declarative import AgentFactory
from azure.identity.aio import AzureCliCredential
from azure.identity import DefaultAzureCredential
from azure.appconfiguration.provider import load

async def main():
endpoint = os.environ["APP_CONFIGURATION_ENDPOINT"]
credential = DefaultAzureCredential()

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

yaml_str = config["Agent:Spec"]

async with (
AzureCliCredential() as credential,
AgentFactory(client_kwargs={"async_credential": credential, "project_endpoint": config["Agent:ProjectEndpoint"]}).create_agent_from_yaml(yaml_str) as agent,
):
while True:
print("How can I help? (type 'quit' to exit)")

user_input = input("User: ")

if user_input.lower() in ['quit', 'exit', 'bye']:
break

response = await agent.run(user_input)
print("Agent response: ", response.text)
input("Press enter to continue...")

print("Exiting... Goodbye...")

if __name__ == "__main__":
asyncio.run(main())
Binary file added examples/Python/ai-agent-sample-app/requirements.txt
Binary file not shown.
Loading