{"id":1743,"date":"2025-02-19T18:19:45","date_gmt":"2025-02-19T18:19:45","guid":{"rendered":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2025\/02\/19\/announcing-chroma-db-c-sdk\/"},"modified":"2025-02-19T18:19:45","modified_gmt":"2025-02-19T18:19:45","slug":"announcing-chroma-db-c-sdk","status":"publish","type":"post","link":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2025\/02\/19\/announcing-chroma-db-c-sdk\/","title":{"rendered":"Announcing Chroma DB C# SDK"},"content":{"rendered":"<p>We\u2019re excited to announce the Chroma C# SDK.<\/p>\n<p>Whether you\u2019re building AI solutions or enhancing existing projects with advanced search capabilities, you now have the option of using Chroma as a database provider in your .NET applications.<\/p>\n<h2>What is Chroma?<\/h2>\n<p>Chroma is an open-source database for your AI applications.<\/p>\n<p>With support for storing embeddings, metadata filtering, vector search, full-text search, document storage, and multi-modal retrieval, you can use Chroma to power semantic search and Retrieval Augmented Generation (RAG) features in your app.<\/p>\n<p>For more details, check out the <a href=\"https:\/\/trychroma.com\/\">Chroma website<\/a>.<\/p>\n<h2>Get started with Chroma in your C# application<\/h2>\n<p>In this scenario, we\u2019ll be using the ChromaDB.Client package to connect to a Chroma database and search for movies using vector search.<\/p>\n<p>The easiest way to start is locally using the <a href=\"https:\/\/docs.trychroma.com\/production\/containers\/docker\">Chroma Docker image<\/a>. You can also <a href=\"https:\/\/docs.trychroma.com\/production\/cloud-providers\/azure\">deploy an instance in Azure<\/a>.<\/p>\n<h3>Connect to the database<\/h3>\n<p>Create a C# console application.<br \/>\nInstall the <a href=\"https:\/\/www.nuget.org\/packages\/ChromaDB.Client\">ChromaDB.Client<\/a> NuGet package.<\/p>\n<p>Create a ChromaClient with configuration options.<\/p>\n<p>using ChromaDB.Client;<\/p>\n<p>var configOptions = new ChromaConfigurationOptions(uri: &#8220;http:\/\/localhost:8000\/api\/v1\/&#8221;);<br \/>\nusing var httpClient = new HttpClient();<br \/>\nvar client = new ChromaClient(configOptions, httpClient);<\/p>\n<p>When using a hosted version of Chroma, replace the uri with your hosted endpoint.<\/p>\n<h2>Create a collection<\/h2>\n<p>Now that you have a client, create a collection to store movie data.<\/p>\n<p>var collection = await client.GetOrCreateCollection(&#8220;movies&#8221;);<\/p>\n<p>To perform operations on that collection, you\u2019ll then need to create a collection client.<\/p>\n<p>var collectionClient = new ChromaCollectionClient(collection, configOptions, httpClient);<\/p>\n<h2>Add data to your collection<\/h2>\n<p>Once your collection is created, it\u2019s time to add data to it. The data we\u2019re storing will consist of:<\/p>\n<p>Movie IDs<br \/>\nEmbeddings to represent the movie description.<br \/>\nMetadata containing the movie title<\/p>\n<p>ID<br \/>\nTitle<br \/>\nEmbedding<br \/>\nMovie Description<\/p>\n<p>1<br \/>\nThe Lion King<br \/>\n[0.10022575, -0.23998135]<br \/>\nThe Lion King is a classic Disney animated film that tells the story of a young lion named Simba who embarks on a journey to reclaim his throne as the king of the Pride Lands after the tragic death of his father.<\/p>\n<p>2<br \/>\nInception<br \/>\n[0.10327095, 0.2563685]<br \/>\nInception is a mind-bending science fiction film directed by Christopher Nolan. It follows the story of Dom Cobb, a skilled thief who specializes in entering people\u2019s dreams to steal their secrets. However, he is offered a final job that involves planting an idea into someone\u2019s mind.<\/p>\n<p>3<br \/>\nToy Story<br \/>\n[0.095857024, -0.201278]<br \/>\nToy Story is a groundbreaking animated film from Pixar. It follows the secret lives of toys when their owner, Andy, is not around. Woody and Buzz Lightyear are the main characters in this heartwarming tale.<\/p>\n<p>4<br \/>\nPulp Fiction<br \/>\n[0.106827796, 0.21676421]<br \/>\nPulp Fiction is a crime film directed by Quentin Tarantino. It weaves together interconnected stories of mobsters, hitmen, and other colorful characters in a non-linear narrative filled with dark humor and violence.<\/p>\n<p>5<br \/>\nShrek<br \/>\n[0.09568083, -0.21177962]<br \/>\nShrek is an animated comedy film that follows the adventures of Shrek, an ogre who embarks on a quest to rescue Princess Fiona from a dragon-guarded tower in order to get his swamp back.<\/p>\n<p>List&lt;string&gt; movieIds = [&#8220;1&#8221;, &#8220;2&#8221;, &#8220;3&#8221;, &#8220;4&#8221;, &#8220;5&#8221; ];<\/p>\n<p>List&lt;ReadOnlyMemory&lt;float&gt;&gt; descriptionEmbeddings = [<\/p>\n<p>    new [] { 0.10022575f, -0.23998135f },<br \/>\n    new [] { 0.10327095f, 0.2563685f },<br \/>\n    new [] { 0.095857024f, -0.201278f },<br \/>\n    new [] { 0.106827796f, 0.21676421f },<br \/>\n    new [] { 0.09568083f, -0.21177962f },<br \/>\n];<\/p>\n<p>List&lt;Dictionary&lt;string,object&gt;&gt; metadata =<br \/>\n[<br \/>\n    new Dictionary&lt;string, object&gt; { [&#8220;Title&#8221;] = &#8220;The Lion King&#8221; },<br \/>\n    new Dictionary&lt;string, object&gt; { [&#8220;Title&#8221;] = &#8220;Inception&#8221;  },<br \/>\n    new Dictionary&lt;string, object&gt; { [&#8220;Title&#8221;] = &#8220;Toy Story&#8221;  },<br \/>\n    new Dictionary&lt;string, object&gt; { [&#8220;Title&#8221;] = &#8220;Pulp Fiction&#8221; },<br \/>\n    new Dictionary&lt;string, object&gt; { [&#8220;Title&#8221;] = &#8220;Shrek&#8221;  },<br \/>\n];<\/p>\n<p>await collectionClient.Add(movieIds, descriptionEmbeddings, metadata);<\/p>\n<h2>Search for movies (using vector search)<\/h2>\n<p>Now that your data is in the database, you can query it. In this case, we\u2019re using vector search.<\/p>\n<p>Text<br \/>\nEmbedding<\/p>\n<p>A family friendly movie<br \/>\n[0.12217915, -0.034832448]<\/p>\n<p>List&lt;ReadOnlyMemory&lt;float&gt;&gt; queryEmbedding = [new([0.12217915f, -0.034832448f])];<\/p>\n<p>var queryResult = await collectionClient.Query(<br \/>\n    queryEmbeddings: queryEmbedding,<br \/>\n    nResults: 2,<br \/>\n    include: ChromaQueryInclude.Metadatas | ChromaQueryInclude.Distances);<\/p>\n<p>foreach (var result in queryResult)<br \/>\n{<br \/>\n    foreach (var item in result)<br \/>\n    {<br \/>\n        Console.WriteLine($&#8221;Title: {(string)item.Metadata[&#8220;Title&#8221;] ?? string.Empty} {(item.Distance)}&#8221;);<br \/>\n    }<br \/>\n}<\/p>\n<p>The result should look similar to the following output.<\/p>\n<p>Title: Toy Story 0.028396977<br \/>\nTitle: Shrek 0.032012463<\/p>\n<h2>Watch it live<\/h2>\n<p>Join Ji\u0159\u00ed \u010cin\u010dura on the <a href=\"https:\/\/www.youtube.com\/watch?v=Nj0vYJ9HVGk\">.NET Data Community Standup on February 26<\/a> to learn more about how to use Chroma and the new C# SDK.  <\/p>\n\n<h2>Conclusion<\/h2>\n<p>This latest addition enhances the growing AI ecosystem in .NET. It paves the way for a simpler implementation of the existing Semantic Kernel connector and seamless integration into your .NET apps using foundational components like <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/introducing-microsoft-extensions-vector-data\/\">Microsoft.Extensions.VectorData<\/a> and <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/introducing-microsoft-extensions-ai-preview\/\">Microsoft.Extensions.AI<\/a>.<\/p>\n<p>We\u2019d like to thank <a href=\"https:\/\/github.com\/ssone95\">@ssone95<\/a> for his work and contributions to the project. We\u2019re excited to continue building partnerships and working with the community to enable .NET developers to build AI applications.<\/p>\n<p>To learn how you can start building AI apps using databases like Chroma, check out the <a href=\"https:\/\/learn.microsoft.com\/dotnet\/ai\/quickstarts\/quickstart-ai-chat-with-data?tabs=azd&amp;pivots=openai\">.NET AI documentation<\/a>.<\/p>\n<p>Try out the Chroma C# SDK today and <a href=\"https:\/\/github.com\/ssone95\/ChromaDB.Client\">provide feedback<\/a>.<\/p>\n<p>The post <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-chroma-db-csharp-sdk\/\">Announcing Chroma DB C# SDK<\/a> appeared first on <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\">.NET Blog<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>We\u2019re excited to announce the Chroma C# SDK. Whether you\u2019re building AI solutions or enhancing existing projects with advanced search [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1743","post","type-post","status-publish","format-standard","hentry","category-dotnet"],"_links":{"self":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/1743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/comments?post=1743"}],"version-history":[{"count":0,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/1743\/revisions"}],"wp:attachment":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/media?parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/categories?post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/tags?post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}