name | description | languages | products | page_type | urlFragment | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Cosmic Food with Azure OpenAI and Azure Cosmos DB for MongoDB vCore |
A Demo application for a streamlined ordering system tailored for various food categories. It allows users to request customized meals, such as "high protein dishes," with recommendations provided from our database. Users can further customize their choices before sending their orders from the app to the restaurant, including delivery details. |
|
|
sample |
cosmic-food-rag-app |
A Demo application for a streamlined ordering system tailored for various food categories. It allows users to request customized meals, such as "high protein dishes," with recommendations provided from our database. Users can further customize their choices before sending their orders from the app to the restaurant, including delivery details. A unique feature of our system is its ability to remember user preferences for future orders, using vCore to store that data. With the help of Langchain, this setup can be easily adapted by ISVs with minimal modifications needed for other food chains.
-
Create the following resources on Microsoft Azure:
- Azure Cosmos DB for MongoDB vCore cluster. See the Quick Start guide here.
- Azure OpenAI resource with:
- Embedding model deployment. (ex.
text-embedding-ada-002
) See the guide here. - Chat model deployment. (ex.
gpt-35-turbo
)
- Embedding model deployment. (ex.
-
Open the repository in GitHub Codespaces:
-
📝 Start here 👉 rag-azure-openai-cosmosdb-langchain-notebook.ipynb
Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage. However, you can try the Azure pricing calculator for the resources below.
- Azure App Service:
B1
Basic Tier with 1 CPU core, 1.75 GB RAM. Pricing per hour. Pricing - Azure OpenAI:
S0
Standard tier, GPT and Ada models. Pricing per 1K tokens used, and at least 1K tokens are used per question. Pricing - Azure Cosmos DB for MongoDB vCore:
M25
tier, 2 (Burstable) vCores per Node, 8 GB Memory per Node. Pricing per hour. Pricing
To reduce costs, you can switch to free SKUs for various services, but those SKUs have limitations.
azd down
.
-
Download the project starter code locally
git clone https://github.com/Azure-Samples/Cosmic-Food-RAG-app.git cd Cosmic-Food-RAG-app
-
Initialize and activate a virtualenv using:
python3 -m venv .venv source .venv/bin/activate
Note - In Windows, the
.venv
does not have abin
directory. Therefore, you'd use the analogous command shown below:source .venv/Scripts/activate
-
Install the development dependencies as an editable package:
python3 -m pip install -e 'src[dev]'
-
Run the notebook to generate the .env file and test out everything
-
Execute the following command to build the website inside the
frontend/
folder and return to the root foldercd ./frontend npm install && npm run build cd ../
-
Execute the following command in your terminal to start the quart app
export QUART_APP=src.quartapp.app export QUART_ENV=development export QUART_DEBUG=true quart run -h localhost -p 50505
For Windows, use
setx
command shown below:setx QUART_APP src.quartapp.app setx QUART_ENV development setx QUART_DEBUG true quart run -h localhost -p 50505
-
Verify on the Browser
Navigate to project homepage http://127.0.0.1:50505/ or http://localhost:50505
This repository is set up for deployment on Azure App Service (w/Azure Cosmos DB for MongoDB vCore) using the configuration files in the infra
folder.
To deploy your own instance, follow these steps:
-
Sign up for a free Azure account
-
Install the Azure Dev CLI.
-
Login to your Azure account:
azd auth login
-
Initialize a new
azd
environment:azd init
It will prompt you to provide a name (like "quart-app") that will later be used in the name of the deployed resources.
-
Provision and deploy all the resources:
azd up
It will prompt you to login, pick a subscription, and provide a location (like "eastus"). Then it will provision the resources in your account and deploy the latest code. If you get an error with deployment, changing the location (like to "centralus") can help, as there may be availability constraints for some of the resources.
When azd has finished deploying, you'll see an endpoint URI in the command output. Visit that URI to browse the app! 🎉
Note
If you make any changes to the app code, you can just run this command to redeploy it:
azd deploy
-
Open the Azure portal and sign in.
-
Navigate to your App Service page.
-
Select SSH from the left menu then, select Go.
-
In the SSH terminal, execute the following commands:
pip install -e . python ./scripts/add_data.py --file="./data/food_items.json"