mem0.NET
0.1.8
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package mem0.NET --version 0.1.8
NuGet\Install-Package mem0.NET -Version 0.1.8
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="mem0.NET" Version="0.1.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add mem0.NET --version 0.1.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: mem0.NET, 0.1.8"
#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.
// Install mem0.NET as a Cake Addin #addin nuget:?package=mem0.NET&version=0.1.8 // Install mem0.NET as a Cake Tool #tool nuget:?package=mem0.NET&version=0.1.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
简单入门教程
安装mem0.NET
dotnet add package mem0.NET
dotnet add package mem0.EntityFrameworkCore
dotnet add mem0.NET.Qdrant
集成到项目
打开appsettings.json
文件,添加以下配置
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "Host=localhost;Port=5432;Database=test;Username=token;Password=dd666666"
},
"Mem0": {
"OpenAIEndpoint": "https://api.token-ai.cn",
"OpenAIKey": "sk-666666",
"OpenAIChatCompletionModel": "gpt-4o-mini",
"OpenAITextEmbeddingModel": "text-embedding-ada-002",
"CollectionName": "mem0-test"
},
"Qdrant": {
"Host": "127.0.0.1",
"Port": 6334,
"Https": false,
"ApiKey": "dd666666"
}
}
创建一个EFCore的DbContext,需要继承Mem0DbContext
类,如下所示
MasterDbContext.cs
using mem0.NET.Service.DataAccess;
using Microsoft.EntityFrameworkCore;
namespace mem0.NET.Service;
public class MasterDbContext(DbContextOptions<MasterDbContext> options) : Mem0DbContext<MasterDbContext>(options)
{
}
然后打开Program.cs
文件,添加以下代码
builder.Services.AddOptions<Mem0Options>()
.Bind(builder.Configuration.GetSection("Mem0"));
builder.Services.AddOptions<QdrantOptions>()
.Bind(builder.Configuration.GetSection("Qdrant"));
var options = builder.Configuration.GetSection("Mem0")
.Get<Mem0Options>();
var qdrantOptions = builder.Configuration.GetSection("Qdrant")
.Get<QdrantOptions>();
builder.Services.AddMem0DotNet(options)
.WithMem0EntityFrameworkCore<MasterDbContext>(optionsBuilder =>
{
optionsBuilder.UseNpgsql(builder.Configuration.GetConnectionString("Default"));
})
.WithVectorQdrant(qdrantOptions);
然后使用,如下所示,创建缓存到向量数据库
public TestService(MemoryService memoryService)
{
public async Task CreateAsync(CreateMemoryInput input)
{
}
}
搜索向量服务,
public TestService(MemoryService memoryService)
{
public async Task SearchAsync(string query, string? userId,
string? agentId, string? runId, uint limit = 10)
{
memoryService.SearchMemory(query, userId, agentId, runId, limit);
}
}
安装Qdrant
docker run -d --name qdrant -p 6334:6334 -v /path/to/data:/data qdrant/qdrant
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.SemanticKernel (>= 1.16.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on mem0.NET:
Package | Downloads |
---|---|
mem0.NET.Qdrant
Package Description |
|
mem0.FreeSql
Package Description |
|
mem0.EntityFrameworkCore
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.