Skip to content

Commit 91d8eb4

Browse files
authored
Merge pull request #84 from microsoft/integration
Integration
2 parents 98c492a + e6cb9f8 commit 91d8eb4

File tree

13 files changed

+187
-157
lines changed

13 files changed

+187
-157
lines changed

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,11 @@ Visit this section to get an overview of the overall architecture and patterns,
2727

2828
Proceed to this section if you'd like to setup your local development environment. You will install the required tools and libraries, clone the prebuilt app repository, and set up your development environment.
2929

30-
You will also set up the Azure Landing Zone to host the application once deployed.
30+
### [Explore application observability](docs/03_observability/README.md)
3131

32-
### [Build and Run the App Locally](docs/03_build/README.md)
32+
Visit this section to observe application behavior and performance through various tools. See logs, traces, and metrics to understand what your application was doing during the realtime conversation.
3333

34-
In this section, you will get the instructions to build and run the backend (Python) and frontend (React.js) of the app locally. You will understand how to test the app locally to ensure everything is working as expected.
35-
36-
### [Deploy to Azure](docs/04_deploy/README.md)
37-
38-
Visit this section to get the detailed instructions to deploy the application front end and backend services to Azure and proceed with some basic tests to ensure everything is working as expected.
39-
40-
### [Explore this Solution Accelerator with Guided Exercises](docs/05_explore/README.md)
34+
### [Explore this Solution Accelerator with Guided Exercises](docs/04_explore/README.md)
4135

4236
The purpose of this section is to help you learn how to best leverage this solution by walking you through some key scenarios related to different personas involved in the lifecycle of a complex Agentic AI solution. For instance, learn how to add new features to the app, scale it, secure it, monitor and troubleshoot it.
4337

docs/01_architecture/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,7 @@ Every request—regardless of channel—is tied to a unique session ID (UUID for
155155

156156
---
157157

158-
**This architecture combines the best of cloud-native, real-time interaction, secure AI orchestration, and practical scaling, making it ready for both quick prototyping and robust, enterprise deployments.**
158+
**This architecture combines the best of cloud-native, real-time interaction, secure AI orchestration, and practical scaling, making it ready for both quick prototyping and robust, enterprise deployments.**
159+
160+
---
161+
#### Navigation: [Home](../../README.md) | [Previous Section](../../README.md) | [Next Section](../02_setup/README.md)

docs/02_setup/README.md

Lines changed: 103 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,107 @@
1-
# Setup your Environment (skip is using a Lab environment)
1+
# Setup your Environment
22

3-
## 1. Local Developer env Setup
4-
- Install required tools and libraries
5-
- Clone the prebuilt app repository
6-
- Set up your development environment
3+
## Running this sample
74

8-
## 2. Provision Azure Infrastructure
9-
- Setting up Azure Landing Zones for infrastructure
5+
We'll follow 4 steps to get this example running in your own environment: pre-requisites, creating an index, setting up the environment, and running the app.
6+
7+
### Pre-requisites
8+
9+
You'll need instances of the following Azure services. You can re-use service instances you have already or create new ones.
10+
11+
1. [Azure OpenAI](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesOpenAI), with 2 model deployments, one of the **gpt-4o-realtime-preview** model, a regular **gpt-4o-mini** model.
12+
1. [Optional] Train an intent_detection model with a SLM using Azure AI Studio. Check [the training data](./intent_detection_model)
13+
14+
### Setting up the environment
15+
16+
The app needs to know which service endpoints to use for the Azure OpenAI and Azure AI Search. The following variables can be set as environment variables, or you can create a ".env" file in the "app/backend/" directory with this content.
17+
18+
The voice agent can use a fine-tuned SLM deployment to classify intent to minimize latency. If you do not have this deployment available then you can use the Azure OpenAI **gpt-4o-mini** deployment, which is fast enough to classify intent with minimal impact on latency. To use **gpt-4o-mini** leave the `INTENT_SHIFT_API_*` env variables empty and supply `AZURE_OPENAI_4O_MINI_DEPLOYMENT`.
19+
20+
```bash
21+
AZURE_OPENAI_ENDPOINT="https://.openai.azure.com/"
22+
AZURE_OPENAI_API_KEY=
23+
AZURE_OPENAI_API_VERSION=2024-10-01-preview
24+
AZURE_OPENAI_CHAT_DEPLOYMENT=gpt-4o-mini
25+
AZURE_OPENAI_EMB_DEPLOYMENT="text-embedding-ada-002"
26+
AZURE_OPENAI_EMB_ENDPOINT= [Optional] if different from your realtime endpoint
27+
AZURE_OPENAI_EMB_API_KEY= [Optional] if providing an embedding endpoint
28+
AZURE_OPENAI_4O_MINI_DEPLOYMENT=YOUR_AZURE_OPENAI_4O_MINI_DEPLOYMENT_NAME
29+
INTENT_SHIFT_API_KEY=
30+
INTENT_SHIFT_API_URL=https://YOUR_ML_DEPLOYMENT.westus2.inference.ml.azure.com/score
31+
INTENT_SHIFT_API_DEPLOYMENT=YOUR_ML_DEPLOYMENT_NAME
32+
AZURE_OPENAI_API_VERSION=2024-10-01-preview
33+
AZURE_OPENAI_REALTIME_DEPLOYMENT_NAME=gpt-4o-realtime-preview
34+
```
35+
36+
### Running the app
37+
38+
#### GitHub Codespaces
39+
40+
You can run this repo virtually by using GitHub Codespaces, which will open a web-based VS Code in your browser:
41+
42+
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&skip_quickstart=true&machine=basicLinux32gb&repo=840462613&devcontainer_path=.devcontainer%2Fdevcontainer.json&geo=WestUs2)
43+
44+
Once the codespace opens (this may take several minutes), open a new terminal.
45+
46+
#### VS Code Dev Containers
47+
48+
You can run the project in your local VS Code Dev Container using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers):
49+
50+
1. Start Docker Desktop (install it if not already installed)
51+
2. Open the project:
52+
53+
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/multi-modal-customer-service-agent)
54+
3. In the VS Code window that opens, once the project files show up (this may take several minutes), open a new terminal.
55+
56+
#### Local environment
57+
58+
1. Install the required tools:
59+
- [Node.js](https://nodejs.org/en)
60+
- [Python >=3.11](https://www.python.org/downloads/)
61+
- **Important**: Python and the pip package manager must be in the path in Windows for the setup scripts to work.
62+
- **Important**: Ensure you can run `python --version` from console. On Ubuntu, you might need to run `sudo apt install python-is-python3` to link `python` to `python3`.
63+
- [Powershell](https://learn.microsoft.com/powershell/scripting/install/installing-powershell)
64+
65+
1. Clone the repo (`git clone https://github.com/microsoft/multi-modal-customer-service-agent`)
66+
1. Ensure env variables are set per [Setting up the environment](#2-setting-up-the-environment)
67+
1. Run this command to start the app:
68+
69+
Windows:
70+
71+
```pwsh
72+
cd voice_agent\app
73+
pwsh .\start.ps1
74+
```
75+
76+
Linux/Mac:
77+
78+
```bash
79+
cd voice_agent/app
80+
./start.sh
81+
```
82+
83+
1. The app is available on http://localhost:8765
84+
85+
#### Deploy to Azure using azd
86+
87+
1. Download and install [azd](https://aka.ms/azd/install) (Azure Developer CLI)
88+
89+
1. Change directory to:
90+
91+
```bash
92+
cd voice_agent/app
93+
```
94+
95+
1. Execute this command:
96+
97+
```bash
98+
azd up
99+
```
100+
101+
1. When prompted provided the following names:
102+
1. Environment name (used as the name of the new resource group to deploy into)
103+
1. Azure Subscription to use
104+
1. Azure location to use
10105
11106
---
12-
#### Navigation: [Home](../../README.md) | [Previous Section](../01_architecture/README.md) | [Next Section](../03_build/README.md)
107+
#### Navigation: [Home](../../README.md) | [Previous Section](../01_architecture/README.md) | [Next Section](../03_observability/README.md)

docs/03_build/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/03_observability/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Observe application behavior
2+
3+
## Semantic Kernel and Observability
4+
5+
It's worth taking a minute to read these two pages about observability with semantic kernel:
6+
[Observability in Semantic Kernel](https://learn.microsoft.com/en-us/semantic-kernel/concepts/enterprise-readiness/observability)
7+
8+
## Observability Architecture
9+
10+
This application uses the [Open Telemetry](https://opentelemetry.io/) standard for shipping application tracing data to three telemetry destinations:
11+
- [.NET Aspire Dashboard](https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/dashboard/overview?tabs=bash), an OTEL-based dashboard for viewing application behavior.
12+
- [Application Insights](https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview), Azure's application observability service.
13+
- Console log
14+
15+
## How does the app send telemetry data to observability destinations?
16+
17+
The application uses the python `opentelemetry` sdk to send data to various destinations. The sdk uses base classes `LogProvider`, `SpanProvider` and `MetricProvider` to send data to various endpoints. In [utility.py]('..\..\voice_agent\app\backend\utility.py) the application uses specific implementations of those classes to send telemetry data to the destinations.
18+
19+
## What observability resources are deployed to my resource group?
20+
21+
### Aspire Dashboard
22+
23+
The bicep infrastructure deploys Aspire Dashboard as a standalone ACA container called `aspire-dashboard`. You can find it in the list of resources in your resource group. Browse the dashboard by clicking the container link.
24+
25+
![Logical architecture](../../media/aspire_dashboard.png)
26+
27+
### Application Insights Resource
28+
29+
The bicep infrastructure deploys an Application Insights resource where you can observe your telemetry data. Use the following features to observe semantic kernel behavior in App Insights:
30+
31+
## Observe Application Behavior
32+
33+
### Conduct a conversation with the customer service agents
34+
35+
Conduct a conversation with the customer service agents following this sequence:
36+
- Ask about your upcoming hotel stay
37+
- Upgrade the room to a suite
38+
- Ask about your upcoming flights
39+
- Upgrade your seat to Business class
40+
41+
### Observe application behavior in Aspire Dashboard
42+
43+
- Go to your resource group in Azure Portal
44+
- Click on the `aspire-dashboard` resource
45+
- Click on the `Application URL` in the top right corner to navigate to the dashboard
46+
![Logs](../../media/aspire_dashboard_logs.png)
47+
- Observe the application log showing the conversation you conducted. Locate an entry: "Function hotel_tools-load_user_reservation_info invoking." and click on the Trace link. This navigates you to the Trace page for that function call.
48+
- Observe the details of the trace, such as the duration and other metadata.
49+
![Trace Details](../../media/aspire_dashboard_trace_details.png)
50+
- Click on the Traces navigation on the left.
51+
- Observe the sequence of function calls and confirm it matches the conversation you had. Drill into traces to see information as desired.
52+
![Traces](../../media/aspire_dashboard_traces.png)
53+
- Click on the Metrics navigation on the left.
54+
- Click on the function duration metric to see the duration on the most recent function calls.
55+
![Metrics](../../media/aspire_dashboard_metrics.png)
56+
57+
58+
## Application Environment Variables
59+
60+
- You can disable specific OTEL destinations by adjusting the `TELEMETRY_SCENARIO` variable. By default it is `console,application_insights,aspire_dashboard`. You can remove any destination from the list by and re-deploy by this sequence:
61+
- Go to the `backend` ACA app
62+
- Click on containers
63+
- Click on Environment Variables
64+
- Adjust the value as desired
65+
- Click `Deploy as new revision`. This will deploy a new revision of the backend app with your new value.
66+
---
67+
#### Navigation: [Home](../../README.md) | [Previous Section](../02_setup/README.md) | [Next Section](../04_explore/README.md)

docs/04_deploy/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/05_explore/README.md renamed to docs/04_explore/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
1. First, create a new car rental tools plugin. Create file car_rental_plugins.py in voice_agent\app\backend\agents\tools and add the following code:
66

77
<details>
8-
<summary> Click to expand/collaspse</summary>
8+
<summary> Click to expand/collapse</summary>
99

1010
```python
1111
from typing import List
@@ -44,7 +44,7 @@
4444
2. Create a car rental agent profile. Create car_rental_agent_profile.yaml in voice_agent\app\backend\agents\agent_profiles and add the following:
4545

4646
<details>
47-
<summary> Click to expand/collaspse</summary>
47+
<summary> Click to expand/collapse</summary>
4848

4949
```python
5050
name: car_rental_agent
@@ -67,7 +67,7 @@
6767
3. Modify the RTMiddleTier class to include the new car rental agent. Add the following to the _load_agents method of voice_agent\app\backend\rtmt.py:
6868

6969
<details>
70-
<summary> Click to expand/collaspse</summary>
70+
<summary> Click to expand/collapse</summary>
7171

7272
```python
7373
from agents.tools.car_rental_plugins import Car_Rental_Tools
@@ -113,7 +113,7 @@
113113
4. Next steps are to update the system message to include the car rental agent along with the intent detection functionality. Update the utility.py detect_intent method to now include car rental agent as part of the system message. Add the below code to the messages block.
114114

115115
<details>
116-
<summary> Click to expand/collaspse</summary>
116+
<summary> Click to expand/collapse</summary>
117117

118118
```python
119119
- **car_rental_agent**: Deal with car rentals, vehicle reservations, changes, and general car rental policy questions.
@@ -128,7 +128,7 @@
128128
Create a JSON file for car rental policies. Name the file car_rental_policy.json and store it in the data folder along with the flight & hotel policies:
129129

130130
<details>
131-
<summary> Click to expand/collaspse</summary>
131+
<summary> Click to expand/collapse</summary>
132132

133133
```python
134134
[
@@ -156,7 +156,7 @@
156156
Update the plugin to setup Azure OpenAI client for embeddings, create get_embedding method to generate text embeddings. Define the SearchClient class with semantic search functionality and finally initialize the search client.
157157

158158
<details>
159-
<summary> Click to expand/collaspse</summary>
159+
<summary> Click to expand/collapse</summary>
160160

161161
```python
162162
# Azure OpenAI client setup
@@ -199,7 +199,7 @@
199199
Update the Car_Rental_Tools class to include policy search:
200200

201201
<details>
202-
<summary> Click to expand/collaspse</summary>
202+
<summary> Click to expand/collapse</summary>
203203

204204
```python
205205
from openai import AzureOpenAI
@@ -225,7 +225,7 @@
225225
Create an embedding generation script & store it in ./scripts/generate_car_rental_policy_embeddings.py :
226226

227227
<details>
228-
<summary> Click to expand/collaspse</summary>
228+
<summary> Click to expand/collapse</summary>
229229

230230
```python
231231
import json
@@ -272,7 +272,7 @@
272272
Run the embedding generation script in the terminal
273273

274274
<details>
275-
<summary> Click to expand/collaspse</summary>
275+
<summary> Click to expand/collapse</summary>
276276

277277
```
278278
cd c:\Code\multi-modal-customer-service-agent\voice_agent\app\backend
@@ -739,4 +739,4 @@ This approach provides quantitative metrics to measure the impact of upgrading y
739739
- (phase-2 / consider once this functionality is integrated into the AI Foundry Agent Service post Build 2025): Exercise 4: real-time monitoring around generative quality & safety (RAI)
740740

741741
---
742-
#### Navigation: [Home](../../README.md) | [Previous Section](../04_deploy/README.md)
742+
#### Navigation: [Home](../../README.md) | [Previous Section](../03_observability/README.md)

media/aspire_dashboard.png

70.6 KB
Loading

media/aspire_dashboard_logs.png

77.3 KB
Loading

media/aspire_dashboard_metrics.png

64.8 KB
Loading
69.5 KB
Loading

media/aspire_dashboard_traces.png

66 KB
Loading

0 commit comments

Comments
 (0)