Skip to content

Commit 6cb3b7b

Browse files
committed
updated readme
1 parent adde8da commit 6cb3b7b

File tree

1 file changed

+134
-11
lines changed

1 file changed

+134
-11
lines changed

README.md

Lines changed: 134 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,119 @@
1-
Coming Soon!
1+
---
2+
page_type: sample
3+
languages:
4+
- azdeveloper
5+
- csharp
6+
- sql
7+
- tsql
8+
- javascript
9+
- html
10+
- bicep
11+
products:
12+
- azure-functions
13+
- azure-sql-database
14+
- static-web-apps
15+
- sql-server
16+
- azure-sql-managed-instance
17+
- azure-sqlserver-vm
18+
- dotnet
19+
- azure-openai
20+
urlFragment: azure-sql-db-session-recommender
21+
name: Session Recommender using Azure SQL DB, Open AI and Vector Search
22+
description: Build a session recommender using Jamstack and Event-Driven architecture, using Azure SQL DB to store and search vectors embeddings generated using OpenAI
23+
---
24+
<!-- YAML front-matter schema: https://review.learn.microsoft.com/en-us/help/contribute/samples/process/onboarding?branch=main#supported-metadata-fields-for-readmemd -->
225

3-
In the meantime take a look at v1 of this project:
26+
# Session Assistant Sample - Retrieveal Augmented Generation with Azure SQL DB and OpenAI
427

5-
- https://sessionfinder.dotnetconf.net/
6-
- https://github.com/Azure-Samples/azure-sql-db-session-recommender
28+
This repository is a evoution of the [Session Recommender](https://github.com/azure-samples/azure-sql-db-session-recommender) sample. In addition to vector search, also Retrival Augmented Generation (RAG) is used to generate the response to the user query. If you are completely new to this topic, you may want to start there, and then come back here.
729

8-
Coming Soon!
30+
![Architecture Diagram](./_docs/session-recommender-architecture.png)
931

10-
In the meantime take a look at v1 of this project:
32+
A session recommender built using
1133

12-
- https://sessionfinder.dotnetconf.net/
13-
- https://github.com/Azure-Samples/azure-sql-db-session-recommender
34+
- [Azure Static Web Apps](https://learn.microsoft.com/en-us/azure/static-web-apps/overview)
35+
- [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/)
36+
- [Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp)
37+
- [Azure SQL Database](https://www.sqlservercentral.com/articles/the-sql-developer-experience-beyond-rdbms)
38+
- [Data API builder](https://aka.ms/dab)
1439

15-
# Session Recommender V2
40+
For more details on the solution check also the following articles:
1641

17-
Coming soon...
42+
- [How I built a session recommender in 1 hour using Open AI](https://dev.to/azure/how-i-built-a-session-recommender-in-1-hour-using-open-ai-5419)
43+
- [Vector Similarity Search with Azure SQL database and OpenAI](https://devblogs.microsoft.com/azure-sql/vector-similarity-search-with-azure-sql-database-and-openai/)
1844

45+
# Deploy the sample using the Azure Developer CLI (azd) template
1946

47+
The Azure Developer CLI (`azd`) is a developer-centric command-line interface (CLI) tool for creating Azure applications.
48+
49+
## Prerequisites
50+
51+
- Install [AZD CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd).
52+
- Install [.NET SDK](https://dotnet.microsoft.com/download).
53+
- Install [Node.js](https://nodejs.org/download/).
54+
- Install [SWA CLI](https://azure.github.io/static-web-apps-cli/docs/use/install#installing-the-cli).
55+
56+
## Install AZD CLI
57+
58+
You need to install it before running and deploying with the Azure Developer CLI.
59+
60+
### Windows
61+
62+
```powershell
63+
powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression"
64+
```
65+
66+
### Linux/MacOS
67+
68+
```bash
69+
curl -fsSL https://aka.ms/install-azd.sh | bash
70+
```
71+
72+
After logging in with the following command, you will be able to use azd cli to quickly provision and deploy the application.
73+
74+
## Authenticate with Azure
75+
76+
Make sure AZD CLI can access Azure resources. You can use the following command to log in to Azure:
77+
78+
```bash
79+
azd auth login
2080
```
2181

82+
## Initialize the template
83+
84+
Then, execute the `azd init` command to initialize the environment (You do not need to run this command if you already have the code or have opened this in a Codespace or DevContainer).
85+
86+
```bash
87+
azd init -t Azure-Samples/azure-sql-db-session-recommender-v2
88+
```
89+
90+
Enter an environment name.
91+
92+
## Deploy the sample
93+
94+
Run `azd up` to provision all the resources to Azure and deploy the code to those resources.
95+
96+
```bash
97+
azd up
98+
```
99+
100+
Select your desired `subscription` and `location`. Then choose a resource group or create a new resource group. Wait a moment for the resource deployment to complete, click the Website endpoint and you will see the web app page.
101+
102+
**Note**: Make sure to pick a region where all services are available like, for example, *West Europe* or *East US 2*
103+
104+
## GitHub Actions
105+
106+
Using the Azure Developer CLI, you can setup your pipelines, monitor your application, test and debug locally.
107+
108+
```bash
109+
azd pipeline config
110+
```
111+
112+
## Test the solution
113+
114+
Add a new row to the `Sessions` table using the following SQL statement (you can use tools like [Azure Data Studio](https://learn.microsoft.com/en-us/azure-data-studio/quickstart-sql-database) or [SQL Server Management Studio](https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-ssms?view=azuresql) to connect to the database. No need to install them if you don't want. In that case you can use the [SQL Editor in the Azure Portal](https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-portal?view=azuresql)):
115+
116+
```sql
22117
insert into web.sessions
23118
(title, abstract, external_id, start_time_PST, end_time_PST, require_embeddings_update)
24119
values
@@ -30,10 +125,34 @@ values
30125
'2024-03-10 11:00:00',
31126
1
32127
)
128+
```
129+
130+
immediately the deployed Azure Function will get executed in response to the `INSERT` statement. The Azure Function will call the OpenAI service to generate the text embedding for the session title and abstract, and then store the embedding in the database, specifically in the `web.sessions_embeddings` table.
33131

132+
```sql
133+
select * from web.sessions_embeddings
34134
```
35135

136+
You can now open the URL associated with the created Static Web App to see the session recommender in action. You can get the URL from the Static Web App overview page in the Azure portal.
137+
138+
![Website running](./_docs/session-recommender.png)
139+
140+
## Run the solution locally
141+
142+
The whole solution can be executed locally, using [Static Web App CLI](https://github.com/Azure/static-web-apps-cli) and [Azure Function CLI](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&pivots=programming-language-csharp).
143+
144+
Install the required node packages needed by the fronted:
145+
146+
```bash
147+
cd client
148+
npm install
36149
```
150+
151+
once finished, create a `./func/local.settings.json` and `.env` starting from provided samples files, and fill out the settings using the correct values for your environment.
152+
153+
From the sample root folder run:
154+
155+
```bash
37156
swa start ./client --api-location ./func --data-api-location ./swa-db-connections
38157
```
39158

@@ -42,4 +161,8 @@ swa start ./client --api-location ./func --data-api-location ./swa-db-connection
42161
The solution uses Fluent UI for the UI components. The Fluent UI is a collection of UX frameworks from Microsoft that provides a consistent design language for web, mobile, and desktop applications. More details about Fluent UI can be found at the following links:
43162

44163
- https://github.com/microsoft/fluentui
45-
- https://react.fluentui.dev/
164+
- https://react.fluentui.dev/
165+
166+
## Credits
167+
168+
Thanks a lot to [Aaron Powell](https://www.aaron-powell.com/) for having helped in building the RAG sample, doing a complete UI revamp using the Fluent UI and for the implementaiton of the `ask` endpoint.

0 commit comments

Comments
 (0)