Chroma Cloud vector db provider (#4273)
* add chroma cloud as new vector db provider * update docker example env * extend chroma class to chroma cloud * update readme --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
This commit is contained in:
parent
a432f82b4a
commit
c6e1b9c3e2
@ -136,7 +136,7 @@ AnythingLLM divides your documents into objects called `workspaces`. A Workspace
|
||||
- [PGVector](https://github.com/pgvector/pgvector)
|
||||
- [Astra DB](https://www.datastax.com/products/datastax-astra)
|
||||
- [Pinecone](https://pinecone.io)
|
||||
- [Chroma](https://trychroma.com)
|
||||
- [Chroma & ChromaCloud](https://trychroma.com)
|
||||
- [Weaviate](https://weaviate.io)
|
||||
- [Qdrant](https://qdrant.tech)
|
||||
- [Milvus](https://milvus.io)
|
||||
|
||||
@ -212,6 +212,12 @@ GID='1000'
|
||||
# CHROMA_API_HEADER="X-Api-Key"
|
||||
# CHROMA_API_KEY="sk-123abc"
|
||||
|
||||
# Enable all below if you are using vector database: Chroma Cloud.
|
||||
# VECTOR_DB="chromacloud"
|
||||
# CHROMACLOUD_API_KEY="ck-your-api-key"
|
||||
# CHROMACLOUD_TENANT=
|
||||
# CHROMACLOUD_DATABASE=
|
||||
|
||||
# Enable all below if you are using vector database: Pinecone.
|
||||
# VECTOR_DB="pinecone"
|
||||
# PINECONE_API_KEY=
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
export default function ChromaCloudOptions({ settings }) {
|
||||
return (
|
||||
<div className="w-full flex flex-col gap-y-7">
|
||||
<div className="w-full flex items-center gap-[36px] mt-1.5">
|
||||
<div className="flex flex-col w-60">
|
||||
<label className="text-white text-sm font-semibold block mb-3">
|
||||
API Key
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
name="ChromaCloudApiKey"
|
||||
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
|
||||
placeholder="ck-your-api-key-here"
|
||||
defaultValue={settings?.ChromaCloudApiKey ? "*".repeat(20) : ""}
|
||||
required={true}
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col w-60">
|
||||
<label className="text-white text-sm font-semibold block mb-3">
|
||||
Tenant ID
|
||||
</label>
|
||||
<input
|
||||
name="ChromaCloudTenant"
|
||||
autoComplete="off"
|
||||
type="text"
|
||||
defaultValue={settings?.ChromaCloudTenant}
|
||||
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
|
||||
placeholder="your-tenant-id-here"
|
||||
required={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col w-60">
|
||||
<label className="text-white text-sm font-semibold block mb-3">
|
||||
Database Name
|
||||
</label>
|
||||
<input
|
||||
name="ChromaCloudDatabase"
|
||||
autoComplete="off"
|
||||
type="text"
|
||||
defaultValue={settings?.ChromaCloudDatabase}
|
||||
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
|
||||
placeholder="your-database-name"
|
||||
required={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -24,6 +24,7 @@ import PGVectorLogo from "@/media/vectordbs/pgvector.png";
|
||||
|
||||
import LanceDBOptions from "@/components/VectorDBSelection/LanceDBOptions";
|
||||
import ChromaDBOptions from "@/components/VectorDBSelection/ChromaDBOptions";
|
||||
import ChromaCloudOptions from "@/components/VectorDBSelection/ChromaCloudOptions";
|
||||
import PineconeDBOptions from "@/components/VectorDBSelection/PineconeDBOptions";
|
||||
import WeaviateDBOptions from "@/components/VectorDBSelection/WeaviateDBOptions";
|
||||
import QDrantDBOptions from "@/components/VectorDBSelection/QDrantDBOptions";
|
||||
@ -133,6 +134,14 @@ export default function GeneralVectorDatabase() {
|
||||
description:
|
||||
"Open source vector database you can host yourself or on the cloud.",
|
||||
},
|
||||
{
|
||||
name: "Chroma Cloud",
|
||||
value: "chromacloud",
|
||||
logo: ChromaLogo,
|
||||
options: <ChromaCloudOptions settings={settings} />,
|
||||
description:
|
||||
"Fully managed Chroma cloud service with enterprise features and support.",
|
||||
},
|
||||
{
|
||||
name: "Pinecone",
|
||||
value: "pinecone",
|
||||
|
||||
@ -271,6 +271,14 @@ export const VECTOR_DB_PRIVACY = {
|
||||
],
|
||||
logo: ChromaLogo,
|
||||
},
|
||||
chromacloud: {
|
||||
name: "Chroma Cloud",
|
||||
description: [
|
||||
"Your vectors and document text are stored on Chroma's cloud service",
|
||||
"Access to your data is managed by Chroma",
|
||||
],
|
||||
logo: ChromaLogo,
|
||||
},
|
||||
pinecone: {
|
||||
name: "Pinecone",
|
||||
description: [
|
||||
|
||||
@ -202,6 +202,12 @@ SIG_SALT='salt' # Please generate random string at least 32 chars long.
|
||||
# CHROMA_API_HEADER="X-Api-Key"
|
||||
# CHROMA_API_KEY="sk-123abc"
|
||||
|
||||
# Enable all below if you are using vector database: Chroma Cloud.
|
||||
# VECTOR_DB="chromacloud"
|
||||
# CHROMACLOUD_API_KEY="ck-your-api-key"
|
||||
# CHROMACLOUD_TENANT=
|
||||
# CHROMACLOUD_DATABASE=
|
||||
|
||||
# Enable all below if you are using vector database: Pinecone.
|
||||
# VECTOR_DB="pinecone"
|
||||
# PINECONE_API_KEY=
|
||||
|
||||
@ -428,6 +428,11 @@ const SystemSettings = {
|
||||
ChromaApiHeader: process.env.CHROMA_API_HEADER,
|
||||
ChromaApiKey: !!process.env.CHROMA_API_KEY,
|
||||
|
||||
// ChromaCloud DB Keys
|
||||
ChromaCloudApiKey: !!process.env.CHROMACLOUD_API_KEY,
|
||||
ChromaCloudTenant: process.env.CHROMACLOUD_TENANT,
|
||||
ChromaCloudDatabase: process.env.CHROMACLOUD_DATABASE,
|
||||
|
||||
// Weaviate DB Keys
|
||||
WeaviateEndpoint: process.env.WEAVIATE_ENDPOINT,
|
||||
WeaviateApiKey: process.env.WEAVIATE_API_KEY,
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
|
||||
/**
|
||||
* Gets the systems current vector database provider.
|
||||
* @param {('pinecone' | 'chroma' | 'lancedb' | 'weaviate' | 'qdrant' | 'milvus' | 'zilliz' | 'astra') | null} getExactly - If provided, this will return an explit provider.
|
||||
* @param {('pinecone' | 'chroma' | 'chromacloud' | 'lancedb' | 'weaviate' | 'qdrant' | 'milvus' | 'zilliz' | 'astra') | null} getExactly - If provided, this will return an explit provider.
|
||||
* @returns { BaseVectorDatabaseProvider}
|
||||
*/
|
||||
function getVectorDbClass(getExactly = null) {
|
||||
@ -89,6 +89,9 @@ function getVectorDbClass(getExactly = null) {
|
||||
case "chroma":
|
||||
const { Chroma } = require("../vectorDbProviders/chroma");
|
||||
return Chroma;
|
||||
case "chromacloud":
|
||||
const { ChromaCloud } = require("../vectorDbProviders/chromacloud");
|
||||
return ChromaCloud;
|
||||
case "lancedb":
|
||||
const { LanceDb } = require("../vectorDbProviders/lance");
|
||||
return LanceDb;
|
||||
|
||||
@ -332,6 +332,20 @@ const KEY_MAPPING = {
|
||||
checks: [],
|
||||
},
|
||||
|
||||
// ChromaCloud Options
|
||||
ChromaCloudApiKey: {
|
||||
envKey: "CHROMACLOUD_API_KEY",
|
||||
checks: [isNotEmpty],
|
||||
},
|
||||
ChromaCloudTenant: {
|
||||
envKey: "CHROMACLOUD_TENANT",
|
||||
checks: [isNotEmpty],
|
||||
},
|
||||
ChromaCloudDatabase: {
|
||||
envKey: "CHROMACLOUD_DATABASE",
|
||||
checks: [isNotEmpty],
|
||||
},
|
||||
|
||||
// Weaviate Options
|
||||
WeaviateEndpoint: {
|
||||
envKey: "WEAVIATE_ENDPOINT",
|
||||
@ -845,6 +859,7 @@ function supportedEmbeddingModel(input = "") {
|
||||
function supportedVectorDB(input = "") {
|
||||
const supported = [
|
||||
"chroma",
|
||||
"chromacloud",
|
||||
"pinecone",
|
||||
"lancedb",
|
||||
"weaviate",
|
||||
|
||||
29
server/utils/vectorDbProviders/chromacloud/index.js
Normal file
29
server/utils/vectorDbProviders/chromacloud/index.js
Normal file
@ -0,0 +1,29 @@
|
||||
const { CloudClient } = require("chromadb");
|
||||
const { Chroma } = require("../chroma");
|
||||
|
||||
// ChromaCloud works exactly the same as Chroma so we can just extend the
|
||||
// Chroma class and override the connect method to use CloudClient
|
||||
|
||||
const ChromaCloud = {
|
||||
...Chroma,
|
||||
name: "ChromaCloud",
|
||||
connect: async function () {
|
||||
if (process.env.VECTOR_DB !== "chromacloud")
|
||||
throw new Error("ChromaCloud::Invalid ENV settings");
|
||||
|
||||
const client = new CloudClient({
|
||||
apiKey: process.env.CHROMACLOUD_API_KEY,
|
||||
tenant: process.env.CHROMACLOUD_TENANT,
|
||||
database: process.env.CHROMACLOUD_DATABASE,
|
||||
});
|
||||
|
||||
const isAlive = await client.heartbeat();
|
||||
if (!isAlive)
|
||||
throw new Error(
|
||||
"ChromaCloud::Invalid Heartbeat received - is the instance online?"
|
||||
);
|
||||
return { client };
|
||||
},
|
||||
};
|
||||
|
||||
module.exports.ChromaCloud = ChromaCloud;
|
||||
Loading…
Reference in New Issue
Block a user