Skip to content

Add readme & fix local setup #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Kernel Memory: E-commerce Sample


![Build](https://github.com/demid-ns/kernel-memory-ecommerce-sample/actions/workflows/ci-build.yml/badge.svg)

Support the project by giving it a star! Your feedback and contributions are greatly appreciated.

## Introduction

This repository contains a sample .NET project demonstrating the use of [Kernel Memory](https://github.com/microsoft/kernel-memory) for semantic search and Retrieval-Augmented Generation (RAG) on a small commercial products dataset.
It mimics an **e-shop** environment where users can search for products, and the application retrieves the most relevant results.

The project features a [serverless setup](https://microsoft.github.io/kernel-memory/serverless) of Kernel Memory, with services embedded directly in the .NET application.
You can run this sample using either **Postgres** (with [pgVector](https://github.com/pgvector/pgvector)) or [Qdrant](https://github.com/qdrant/qdrant) as the vector database.

This sample uses **OpenAI's `gpt-4o-mini`** as the language model and **`text-embedding-ada-002`** as the embedding model. Other models are also supported; check the [Kernel Memory repository](https://github.com/microsoft/kernel-memory) for all supported models.

## Setup

1. **Configure API Key**:

Open the `appsettings.json` file in the project root and insert your API token under `KernelMemory:Services:OpenAI:APIKey`. This key is required to authenticate with the OpenAI services used in the sample.

```json
{
"KernelMemory": {
"Services": {
"OpenAI": {
"APIKey": "your-api-key-here"
}
}
}
}
```

2. **Run the Application**:

To start the services, run `docker-compose up -d` **from the repository root**.

Alternatively, you can run the application through the `docker-compose` startup project directly from your IDE ([Visual Studio](https://learn.microsoft.com/en-us/visualstudio/containers/tutorial-multicontainer?view=vs-2022)/Rider/VS Code)

3. **Ingest Sample Dataset**:

After the application is running, open your browser and navigate to [http://localhost:9000](http://localhost:9000).
From there, you can ingest the sample dataset located at `/utils/dataset/products.csv` ([link](./utils/dataset/products.csv))

## Accessing the Application

- [http://localhost:9000](http://localhost:9000) - Application UI
- [http://localhost:9000/swagger](http://localhost:9000/swagger) - Swagger API Documentation
- [http://localhost:5341](http://localhost:5341) - Seq (structured logs, traces). Default login: `admin` Default password: `password`
- [http://localhost:6333/dashboard](http://localhost:6333/dashboard) - Qdrant Dashboard

## Contribution

Feel free to open discussions, submit pull requests, or share suggestions to help improve the project! The authors are very friendly and open to feedback and contributions.



7 changes: 1 addition & 6 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ services:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
- OTEL_EXPORTER_OTLP_ENDPOINT=http://kernelmemory.ecommerce.sample.seq:5341/ingest/otlp/v1/traces
- OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
ports:
- "8080"
- "8081"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro
- ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ services:
dockerfile: src/KernelMemory.Ecommerce.Sample.Api/Dockerfile
ports:
- 9000:8080
- 9001:8081
depends_on:
kernelmemory.ecommerce.sample.database:
condition: service_healthy
Expand Down
1 change: 0 additions & 1 deletion src/KernelMemory.Ecommerce.Sample.Api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5215"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7056;http://localhost:5215"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
Expand All @@ -30,7 +21,6 @@
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
Expand Down
Loading