diff --git a/README.md b/README.md new file mode 100644 index 0000000..5520ee5 --- /dev/null +++ b/README.md @@ -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. + + + diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 3d0a871..618c5e3 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -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 \ No newline at end of file + - ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ef84349..c39eaf3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/src/KernelMemory.Ecommerce.Sample.Api/Dockerfile b/src/KernelMemory.Ecommerce.Sample.Api/Dockerfile index ba9b855..e71ebb5 100644 --- a/src/KernelMemory.Ecommerce.Sample.Api/Dockerfile +++ b/src/KernelMemory.Ecommerce.Sample.Api/Dockerfile @@ -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 diff --git a/src/KernelMemory.Ecommerce.Sample.Api/Properties/launchSettings.json b/src/KernelMemory.Ecommerce.Sample.Api/Properties/launchSettings.json index 48d2c32..2aaa9cf 100644 --- a/src/KernelMemory.Ecommerce.Sample.Api/Properties/launchSettings.json +++ b/src/KernelMemory.Ecommerce.Sample.Api/Properties/launchSettings.json @@ -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, @@ -30,7 +21,6 @@ "launchBrowser": true, "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", "environmentVariables": { - "ASPNETCORE_HTTPS_PORTS": "8081", "ASPNETCORE_HTTP_PORTS": "8080" }, "publishAllPorts": true,