ChromaDotNet.Client
2.13.0
Prefix Reserved
See the version list below for details.
dotnet add package ChromaDotNet.Client --version 2.13.0
NuGet\Install-Package ChromaDotNet.Client -Version 2.13.0
<PackageReference Include="ChromaDotNet.Client" Version="2.13.0" />
<PackageVersion Include="ChromaDotNet.Client" Version="2.13.0" />
<PackageReference Include="ChromaDotNet.Client" />
paket add ChromaDotNet.Client --version 2.13.0
#r "nuget: ChromaDotNet.Client, 2.13.0"
#:package ChromaDotNet.Client@2.13.0
#addin nuget:?package=ChromaDotNet.Client&version=2.13.0
#tool nuget:?package=ChromaDotNet.Client&version=2.13.0
ChromaDB.Client
ChromaDB.Client, published on NuGet as ChromaDotNet.Client, is a .NET client for Chroma and Chroma Cloud. It covers:
- collections, tenants and databases;
- writing and reading records, and nearest neighbor queries with filters;
- the Search API of Chroma Cloud, with hybrid BM25 search;
- OpenTelemetry traces and metrics.
This is a community project, the continuation of ssone95/ChromaDB.Client, kept up to date with current Chroma versions. It is not affiliated with or endorsed by Chroma. See About this fork.
Website: chromadotnet.org
Used by
- CommunityToolkit.VectorData.Chroma, the Chroma provider for Microsoft.Extensions.VectorData in the AI Community Toolkit of the .NET Foundation. It works with Semantic Kernel and Agent Framework.
Installation
dotnet add package ChromaDotNet.Client
ChromaDotNet.Client.DependencyInjection for Microsoft.Extensions.DependencyInjection: Dependency injection.
Example
The models, like ChromaRecords, ChromaQuery and ChromaCollectionDefinition, are in ChromaDB.Client.Models. AddChromaClient is in ChromaDB.Client.DependencyInjection.
using ChromaDB.Client;
using ChromaDB.Client.Models;
var configOptions = new ChromaConfigurationOptions(uri: "http://localhost:8000/api/v2/");
using var httpClient = new HttpClient();
var client = new ChromaClient(configOptions, httpClient);
Console.WriteLine(await client.GetVersionAsync());
var string5Collection = await client.GetOrCreateCollectionAsync("string5");
var string5Client = new ChromaCollectionClient(string5Collection, configOptions, httpClient);
await string5Client.AddAsync(["340a36ad-c38a-406c-be38-250174aee5a4"], embeddings: [new([1f, 0.5f, 0f, -0.5f, -1f])]);
var getResult = await string5Client.GetAsync("340a36ad-c38a-406c-be38-250174aee5a4", include: ChromaGetInclude.Metadatas | ChromaGetInclude.Documents | ChromaGetInclude.Embeddings);
Console.WriteLine($"ID: {getResult!.Id}");
var queryData = await string5Client.QueryAsync([new([1f, 0.5f, 0f, -0.5f, -1f]), new([1.5f, 0f, 2f, -1f, -1.5f])], include: ChromaQueryInclude.Metadatas | ChromaQueryInclude.Distances);
foreach (var item in queryData)
{
foreach (var entry in item)
{
Console.WriteLine($"ID: {entry.Id} | Distance: {entry.Distance}");
}
}
The URI, the HttpClient and the use from more threads: Connecting.
Compatibility
docs/COMPATIBILITY.md lists every tested release, the differences between them and the versions the CI runs.
The compatibility table shows every check of the latest release on Chroma 1.5.9 and on Chroma Cloud, on each .NET runtime and platform.
Documentation
- Connecting: the URI, the
HttpClient, threads, the API version, authentication and connection strings. - Dependency injection:
AddChromaClientandAddKeyedChromaClient. - Collections: collections, tenants and databases, collections by id.
- Records: URIs, large writes, deletes and base64 embeddings.
- Metadata values: values, lists, deletions in updates and upserts, document copies, conversions.
- Queries and filters: queries,
GetAsyncin pages, where and document filters. - Upsert strategies:
ServerandSkipUnchangedEmbeddings. - Index settings: the distance, the HNSW and SPANN settings,
ModifyConfigurationAsync. - Errors:
ChromaExceptionandCollectionExistsAsync. - Mocks in tests: mocking
ChromaClientandChromaCollectionClient. - Health, traces and metrics:
HealthcheckAsyncand OpenTelemetry. - Chroma Cloud: options, identity, batches, quotas and the operations of Chroma Cloud.
- Search: the Search API and hybrid search with BM25.
- Sparse vectors and schema: sparse vectors, BM25 indexes and the indexes of a schema.
- Platforms: the builds, trimming and NativeAOT.
- About this fork: the original project and what this fork does.
Migrating from ChromaDB.Client 1.x
The migration guide has the details, and the release notes list the changes of every version.
Contributing
CONTRIBUTING.md and SECURITY.md.
License
The project is released under the MIT License, keeping the original copyright notice.
| Product | Versions 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 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 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 is compatible. 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. |
-
.NETFramework 4.6.2
- System.Diagnostics.DiagnosticSource (>= 10.0.12)
- System.Memory (>= 4.6.3)
- System.Text.Json (>= 10.0.12)
-
.NETStandard 2.0
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
- System.Memory (>= 4.5.5)
- System.Text.Json (>= 8.0.6)
-
net8.0
- System.Diagnostics.DiagnosticSource (>= 9.0.20)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ChromaDotNet.Client:
| Package | Downloads |
|---|---|
|
ChromaDotNet.Client.DependencyInjection
Dependency injection for ChromaDotNet.Client, the .NET client for Chroma and Chroma Cloud: AddChromaClient, AddKeyedChromaClient and CreateChromaClient. Tested with Chroma 0.4.10 to 1.5.9. Community project, not affiliated with Chroma. |
|
|
ChromaDotNet.VectorData
Deprecated: use CommunityToolkit.VectorData.Chroma. |
|
|
CommunityToolkit.VectorData.Chroma
Chroma provider for Microsoft.Extensions.VectorData by the .NET Community Toolkit |
|
|
ChromaDotNet.Local.Core
The code of ChromaDotNet.Local, without the Chroma executables. At the first start it downloads the executable of the platform from the GitHub release of ChromaDB.Local and checks its SHA-256. To work offline, add the ChromaDotNet.Local.Runtime package of each platform, or reference ChromaDotNet.Local, which brings them all. ChromaLocalServer.StartAsync starts Chroma 1.5.9 as a child process on 127.0.0.1, for ChromaDotNet.Client, and stops it with Dispose or when the application ends. Community project, not affiliated with Chroma. |
GitHub repositories
This package is not used by any popular GitHub repositories.
2.13.0: UpdateAsync and UpsertAsync delete metadata keys and documents without reading the records first, so two writes of the same record at the same time leave the record of one of them. A collection client chooses once how NullDocumentsDelete deletes a document: WithDocumentCopyKey, or the new WithDocumentDeletionKey and WithEmptyDocumentDeletions; without one, a null document with NullDocumentsDelete throws an ArgumentException, and another way or key throws an InvalidOperationException. On Chroma Cloud, a write with nulls beyond the quota of 32 metadata keys throws an ArgumentException, unless ChromaConfigurationOptions.WithReadsBeyondKeyQuota, and so does a filter on the documents that Chroma Cloud answers with the wrong records: a $regex whose pattern takes an empty text, and a $contains of fewer than 3 characters. An empty text gets an empty BM25 vector. All the releases: https://github.com/ChromaDotNet/ChromaDB.Client/releases. Tested versions: https://github.com/ChromaDotNet/ChromaDB.Client/blob/main/docs/COMPATIBILITY.md. Migration from 1.x: https://github.com/ChromaDotNet/ChromaDB.Client#migrating-from-chromadbclient-1x
