This project is a sample application designed to showcase how easy it is to develop a Generative AI (GenAI) application using Azure OpenAI, Azure Cache for Redis, and the Semantic Kernel .NET package. The application demonstrates the integration of these powerful technologies to vectorize and search product reviews. By leveraging Azure OpenAI for natural language processing and Redis for fast data storage and retrieval, this sample provides a practical example of building intelligent applications with advanced AI capabilities. Additionally, the project showcases the Retrieval-Augmented Generation (RAG) pattern, using Redis as both a data store and a vector storage solution to enhance the search and retrieval of relevant information.
- .NET 9 SDK
- Azure OpenAI account
- Redis instance
The application requires the following configuration values:
- Azure OpenAI Endpoint
- Azure OpenAI API Key
- Azure OpenAI Embedding Model Deployment Name
- Azure OpenAI Chat Completion Model Deployment Name
- Redis Host
- Redis Port
- Redis Password
These values should be set in the user secrets for the project.
- Right-click on your project in Visual Studio and select "Manage User Secrets".
- Add the following JSON to the
secrets.json
file:
{
"AzureOpenAI:Endpoint": "your-endpoint",
"AzureOpenAI:Key": "your-api-key",
"AzureOpenAI:EmbeddingDeployment": "your-embedding-deployment",
"AzureOpenAI:CompletionsDeployment": "your-completions-deployment",
"Redis:Host": "your-redis-host",
"Redis:Port": "your-redis-port",
"Redis:Password": "your-redis-password"
}
- Open a terminal and navigate to your project directory.
- Run the following commands to set the user secrets:
dotnet user-secrets set "AzureOpenAI:Endpoint" "your-endpoint"
dotnet user-secrets set "AzureOpenAI:Key" "your-api-key"
dotnet user-secrets set "AzureOpenAI:EmbeddingDeployment" "your-embedding-deployment"
dotnet user-secrets set "AzureOpenAI:CompletionsDeployment" "your-completions-deployment"
dotnet user-secrets set "Redis:Host" "your-redis-host"
dotnet user-secrets set "Redis:Port" "your-redis-port"
dotnet user-secrets set "Redis:Password" "your-redis-password"
- Clone the repository.
- Open the solution in Visual Studio.
- Ensure that the user secrets are set as described above.
- Build and run the application.
When you run the application, you will see a menu with the following options:
- Vectorize the review(s) and store it in Redis
- Ask AI Assistant (search for a review by asking a question)
- Exit this Application
Select the first option to read reviews from a CSV file located in the assets
directory with the file name reviews.csv
, vectorize them using Azure OpenAI, and store them in Redis.
Select the second option to ask a question and search for reviews based on the query. The application will use Azure OpenAI to generate embeddings for the query and perform a vector search in Redis.
You can run Redis locally using the redis-stack
Docker image. Follow these steps to spin up a Redis container:
- Ensure you have Docker installed on your machine.
- Open a terminal and run the following command to pull the
redis-stack
image:
docker pull redis/redis-stack:latest
- Run the Redis container with the following command:
docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
This command will start a Redis container with the default Redis port (6379) and the RedisInsight port (8001) exposed.
This project is licensed under the MIT License.