MemNet 2.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package MemNet --version 2.0.4
                    
NuGet\Install-Package MemNet -Version 2.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MemNet" Version="2.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MemNet" Version="2.0.4" />
                    
Directory.Packages.props
<PackageReference Include="MemNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MemNet --version 2.0.4
                    
#r "nuget: MemNet, 2.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MemNet@2.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MemNet&version=2.0.4
                    
Install as a Cake Addin
#tool nuget:?package=MemNet&version=2.0.4
                    
Install as a Cake Tool

MemNet

MemNet is a "self-improving" memory layer designed for .NET developers, providing long-term and short-term memory management, similarity search, memory consolidation/refinement, and persistence for LLM-based applications. It facilitates context reuse in conversations, recommendations, personalization, and context-aware applications.

In simple terms: LLMs are stateless, and MemNet helps you remember users' previous behaviors and conversation content, making your applications smarter and more personalized.

Why Use MemNet

  • Transform scattered conversations/events into retrievable memories to enhance context awareness.
  • Built-in vector search and memory consolidation strategies to reduce duplicate memories and noise.
  • Support for multiple storage backends (in-memory, Qdrant, Redis, Chroma, Milvus, etc.) for easy expansion and persistence.
  • Integration with any LLM/Embedding provider (pluggable embedding layer).

Installation

Using dotnet CLI:

dotnet add package MemNet

Using NuGet Package Manager Console:

Install-Package MemNet

Quick Start

1. Configure appsettings.json

First, configure the Embedder, LLM, and VectorStore in your project's appsettings.json file:

{
  "MemNet": {
    "Embedder": {
      "Endpoint": "https://api.openai.com/v1/",
      "Model": "text-embedding-3-large",
      "ApiKey": "your-embedding-api-key"
    },
    "LLM": {
      "Endpoint": "https://api.openai.com/v1/",
      "Model": "gpt-4",
      "ApiKey": "your-llm-api-key"
    }
  }
}

Tip: For security purposes, it's recommended to use more secure methods to store API keys rather than writing them directly in the configuration file.

2. Register Services

Register MemNet services in Program.cs:

using MemNet;
using MemNet.Abstractions;
using MemNet.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json") // Requires NuGet Package: Microsoft.Extensions.Configuration.Json
    .Build();

var services = new ServiceCollection();
services.AddMemNet(configuration);

await using var serviceProvider = services.BuildServiceProvider();
var memoryService = serviceProvider.GetRequiredService<IMemoryService>();
await memoryService.InitializeAsync();

3. Add Memories

await memoryService.AddAsync(new AddMemoryRequest
{
    Messages =
    [
        new MessageContent
        {
            Role = "User",
            Content = "My name is Zack. I love programming."
        },
        new MessageContent
        {
            Role = "User",
            Content = "As a 18-years-old boy, I'm into Chinese food."
        },
        new MessageContent
        {
            Role = "User",
            Content = "I'm allergic to nuts."
        }
    ],
    UserId = "user001"
});

UserId is used to distinguish memory data between different users. It also supports finer-grained differentiation through dimensions such as AgentId and RunId.

4. Search Memories

var searchResults = await memoryService.SearchAsync(new SearchMemoryRequest
{
    Query = "Please recommend some food.",
    UserId = "user001"
});

Console.WriteLine("Search Results:");
foreach (var item in searchResults)
{
    Console.WriteLine($"- {item.Memory.Data}");
}

Execution result:

Search Results:
- Cuisine preference: Chinese food
- Allergy: nuts

5. Using Different Vector Stores

MemNet uses in-memory vector storage by default, which is suitable for development and testing environments. For production environments, it's recommended to use persistent vector storage backends to ensure data persistence and scalability.

MemNet supports multiple vector storage backends:

Using Qdrant

Add vector database configuration to appsettings.json (replace the values with your actual values):

"VectorStore": {
    "Endpoint": "your-Qdrant-endpoint, e.g., http://localhost:6333",
    "ApiKey": "your-Qdrant-apikey (optional)",
    "CollectionName": "your-collection-name (optional, default is 'memnet_collection')"
}

Then modify the registration code:

services.AddMemNet(configuration).WithQdrant();
Using Chroma

Add vector database configuration to appsettings.json (replace the values with your actual values):

"VectorStore": {
    "Endpoint": "your-Chroma-endpoint, e.g., http://localhost:8000",
    "ApiKey": "your-Chroma-apikey (optional)",
    "CollectionName": "your-collection-name (optional, default is 'memnet_collection')",
    "Database": "YourDatabaseName",
    "Tenant": "YourTenantName"
}

Then modify the registration code:

services.AddMemNet(configuration).WithChromaV2();
Using Milvus

Add vector database configuration to appsettings.json (replace the values with your actual values):

"VectorStore": {
    "Endpoint": "your-Milvus-endpoint, e.g., http://localhost:19530",
    "ApiKey": "your-Milvus-apikey (optional)",
    "CollectionName": "your-collection-name (optional, default is 'memnet_collection')"
}

Then modify the registration code:

services.AddMemNet(configuration).WithMilvusV2();
Using Redis (Requires MemNet.Redis package)

Add vector database configuration to appsettings.json (replace the values with your actual values):

"VectorStore": {
    "Endpoint": "your-Redis-address, e.g., localhost:6379",
    "ApiKey": "your-Redis-username-and-password (optional), e.g. user:password",
    "CollectionName": "your-collection-name (optional, default is 'memnet_collection')"
}
services.AddMemNet().WithMemNetRedis("connection-string, e.g., localhost:6379");
More Vector Store Support

Please refer to the MemNet.Redis project to customize support for other vector stores. Contributions via pull requests to add new integrations are welcome.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MemNet:

Package Downloads
MemNet.Redis

Redis vector store implementation for MemNet - providing vector similarity search capabilities using Redis Stack.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.5 257 12/22/2025
2.0.4 400 11/4/2025
2.0.3 233 11/4/2025
2.0.2 225 11/4/2025
1.0.0 235 11/4/2025