Support API client for chroma
This commit is contained in:
Timothy Carambat 2023-09-29 22:20:06 +02:00 committed by GitHub
parent 3c844363fb
commit 62d39eb4fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 0 deletions
docker
frontend/src/components/Modals/Settings/VectorDbs
server

View file

@ -22,6 +22,8 @@ OPEN_MODEL_PREF='gpt-3.5-turbo'
# Enable all below if you are using vector database: Chroma.
# VECTOR_DB="chroma"
# CHROMA_ENDPOINT='http://host.docker.internal:8000'
# CHROMA_API_HEADER="X-Api-Key"
# CHROMA_API_KEY="sk-123abc"
# Enable all below if you are using vector database: Pinecone.
VECTOR_DB="pinecone"

View file

@ -44,6 +44,8 @@ Out of the box, all vector databases are supported. Any vector databases requiri
VECTOR_DB="chroma"
CHROMA_ENDPOINT='http://host.docker.internal:8000' # Allow docker to look on host port, not container.
# CHROMA_API_HEADER="X-Api-Key" // If you have an Auth middleware on your instance.
# CHROMA_API_KEY="sk-123abc"
...other configs

View file

@ -182,6 +182,41 @@ export default function VectorDBSelection({
spellCheck={false}
/>
</div>
<div className="">
<div className="mb-2 flex flex-col gap-y-1">
<label
htmlFor="ChromaAuthTokenHeader"
className="block text-sm font-medium text-gray-800 dark:text-slate-200"
>
API Header & Key
</label>
<p className="text-xs text-gray-800 dark:text-slate-200">
If your hosted Chroma instance is protected by an API
key - enter the header and api key here.
</p>
</div>
<div className="flex w-full items-center gap-x-4">
<input
name="ChromaApiHeader"
autoComplete="off"
type="text"
defaultValue={settings?.ChromaApiHeader}
className="w-[20%] bg-gray-50 border border-gray-500 text-gray-900 placeholder-gray-500 text-sm rounded-lg dark:bg-stone-700 focus:border-stone-500 block w-full p-2.5 dark:text-slate-200 dark:placeholder-stone-500 dark:border-slate-200"
placeholder="X-Api-Key"
/>
<input
name="ChromaApiKey"
autoComplete="off"
type="password"
defaultValue={
settings?.ChromaApiKey ? "*".repeat(20) : ""
}
className="bg-gray-50 border border-gray-500 text-gray-900 placeholder-gray-500 text-sm rounded-lg dark:bg-stone-700 focus:border-stone-500 block w-full p-2.5 dark:text-slate-200 dark:placeholder-stone-500 dark:border-slate-200"
placeholder="sk-myApiKeyToAccessMyChromaInstance"
/>
</div>
</div>
</>
)}
{vectorDB === "lancedb" && (

View file

@ -21,6 +21,8 @@ OPEN_MODEL_PREF='gpt-3.5-turbo'
# Enable all below if you are using vector database: Chroma.
# VECTOR_DB="chroma"
# CHROMA_ENDPOINT='http://localhost:8000'
# CHROMA_API_HEADER="X-Api-Key"
# CHROMA_API_KEY="sk-123abc"
# Enable all below if you are using vector database: Pinecone.
# VECTOR_DB="pinecone"

View file

@ -34,6 +34,8 @@ const SystemSettings = {
...(vectorDB === "chroma"
? {
ChromaEndpoint: process.env.CHROMA_ENDPOINT,
ChromaApiHeader: process.env.CHROMA_API_HEADER,
ChromaApiKey: !!process.env.CHROMA_API_KEY,
}
: {}),
...(vectorDB === "weaviate"

View file

@ -35,10 +35,22 @@ const KEY_MAPPING = {
envKey: "VECTOR_DB",
checks: [isNotEmpty, supportedVectorDB],
},
// Chroma Options
ChromaEndpoint: {
envKey: "CHROMA_ENDPOINT",
checks: [isValidURL, validChromaURL],
},
ChromaApiHeader: {
envKey: "CHROMA_API_HEADER",
checks: [],
},
ChromaApiKey: {
envKey: "CHROMA_API_KEY",
checks: [],
},
// Weaviate Options
WeaviateEndpoint: {
envKey: "WEAVIATE_ENDPOINT",
checks: [isValidURL],
@ -47,6 +59,8 @@ const KEY_MAPPING = {
envKey: "WEAVIATE_API_KEY",
checks: [],
},
// QDrant Options
QdrantEndpoint: {
envKey: "QDRANT_ENDPOINT",
checks: [isValidURL],

View file

@ -16,9 +16,13 @@
- `docker-compose up -d --build`
- set the `CHROMA_ENDPOINT=` .env variable in `server` and also set `VECTOR_DB=` to `chroma`.
* If you have an API Gateway or auth middleway be sure to set the `CHROMA_API_HEADER` and `CHROMA_API_KEY` keys.
eg: `server/.env.development`
```
VECTOR_DB="chroma"
CHROMA_ENDPOINT='http://localhost:8000'
# CHROMA_API_HEADER="X-Api-Key" // If you have an Auth middleware on your instance.
# CHROMA_API_KEY="sk-123abc" // If you have an Auth middleware on your instance.
```

View file

@ -13,6 +13,16 @@ const Chroma = {
const client = new ChromaClient({
path: process.env.CHROMA_ENDPOINT, // if not set will fallback to localhost:8000
...(!!process.env.CHROMA_API_HEADER && !!process.env.CHROMA_API_KEY
? {
fetchOptions: {
headers: {
[process.env.CHROMA_API_HEADER || "X-Api-Key"]:
process.env.CHROMA_API_KEY,
},
},
}
: {}),
});
const isAlive = await client.heartbeat();