VENative.ChromaDB.Client 9.0.2

dotnet add package VENative.ChromaDB.Client --version 9.0.2                
NuGet\Install-Package VENative.ChromaDB.Client -Version 9.0.2                
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="VENative.ChromaDB.Client" Version="9.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VENative.ChromaDB.Client --version 9.0.2                
#r "nuget: VENative.ChromaDB.Client, 9.0.2"                
#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 VENative.ChromaDB.Client as a Cake Addin
#addin nuget:?package=VENative.ChromaDB.Client&version=9.0.2

// Install VENative.ChromaDB.Client as a Cake Tool
#tool nuget:?package=VENative.ChromaDB.Client&version=9.0.2                

VENative.ChromaDB.Client

VENative.ChromaDB.Client is a wrapper around the Chroma API that exposes all functionality of that API to .NET. The project follows the ChromaDB Python and JavaScript client patterns.

Nuget

VENative.ChromaDB.Client

How to Use

ChromaDB is designed to be used against a deployed version of ChromaDB. See HERE for official documentation on how to deploy ChromaDB.

Each Chroma call features a syncronous and and asyncronous version.

// Create your HttpClient and set the base address to the chroma instance
using HttpClient client = new();
client.BaseAddress = new Uri("http://localhost:8000/"); // 
Using local docker version for example.

ChromaDBClient client = new(httpClient);

// Additional options
ChromaDBClient client = new(httpClient, tenantName, databaseName);

string version = client.Version();
long heartbeat = await client.HeartbeatAsync();
  • Creating a client using Dependency Injection.
... //Create app builder
builder.Services.RegisterChromaDBSharp("http://localhost:8000/");

builder.Services.RegisterChromaDBSharp(client => {
// Configure HTTP client here. For example, add authentication.
client.BaseAddress = new Uri("http://localhost:8000/");
byte[] byteArray = Encoding.ASCII.GetBytes("username:password");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
});
  • Creating a collection

Collections rquire an embedding function otherwise an error will through. Define an embedding class as follows:

public sealed class CustomEmbedder : IEmbeddable
{
    public Task<IEnumerable<IEnumerable<float>>> Generate(IEnumerable<string> texts)
    {
        // Embedding logic here
        // For example, call an API, create custom c\# embedding logic, or use library. this is for demonstration only.
        ...
        return embeddings.
    }
}
public sealed class AllMiniEmbedder : IEmbeddable
{
    private readonly IEmbedder _embedder;
    public AllMiniEmbedding()
    {
        _embedder = new AllMiniLmL6V2Embedder(modelPath: "path/to/model", tokenizer: new AllMiniLmL6V2Sharp.Tokenizer.BertTokenizer("path/to/vocab"));
    }
    public async Task<IEnumerable<IEnumerable<float>>> Generate(IEnumerable<string> texts)
    {
        IEnumerable<IEnumerable<float>> result = _embedder.GenerateEmbeddings(texts);
        return await Task.FromResult(result);
    }
}

Pass into collection when fetching.

IEmbeddable customEmbeddingFunction = new CustomEmbedder();
ICollectionClient collection = client.CreateCollection("Collection Name", metadata: new Dictionary<string, object> { {"prop1", "value 1"},{"prop2",2}}, embeddingFunction: customEmbeddingFunction);
  • Add documents
collection.Add(documents: new[] { "This is document 1", "This is document 2" }, metadatas: new[] { new Dictionary<string, object> { { "source", "notion" } }, new Dictionary<string, object> { { "source", "google-docs" } } }, ids: new[] { "doc 1", "doc 2" });
  • Query Documents
QueryResult result = collection.Query(queryTexts: new[] { "This is a query document" }, numberOfResults: 5);
            
  • Query Documents with a where clause.
QueryResult result = collection.Query(queryTexts: new[] { "This is a query document" }, where: new Dictionary<string, object> {{"source", "notion"}},  numberOfResults: 5);
            
Product 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.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.2 332 11/14/2024
9.0.1 83 11/14/2024
9.0.0 89 11/14/2024 9.0.0 is deprecated because it has critical bugs.