This repo is a sample console application in .NET, showing how to use Semantic Kernel, OpenAI and MongoDB Atlas to create a simple AI Agent for querying missing ingredients to make a recipe, followed by the recpie, another recpie or a recommended restaurant to visit instead.
You will need a few things to run this locally:
- OpenAI account and API Key
- MongoDB Atlas cluster with sample dataset loaded (the free forever M0 tier is adequate)
- MongoDB Atlas Connection String
You will need to add these keys to your environment variables to run the application.
E.G:
export OPENAI_API_KEY="<YOUR OPEN AI API KEY>"
The sample data available from MongoDB for restaurants does not have a field for embeddings yet. Thankfully, Semantic Kernel is able to generate embeddings for us using OpenAI. In Program.cs
you will find a method called GenerateEmbeddingsForCuisine()
.
This needs to be called just ONCE, the first time you run the application. This will go ahead and fetch documents (currently set to 1000 documents) from the sample_restaurants database, restaurants collection, generate the embeddings and then save them in a collection called embedded_cuisines in the format that Semantic Kernel can work with.
- Ensure you have added the required environment variables
- Run
dotnet build
using the DotNET SDK or inside an IDE such as Visual Studio. - Run
dotnet run
to run the application.