diff --git a/docs/api-reference.md b/docs/api-reference.md index 9db18ab..c8beafb 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -157,7 +157,12 @@ Run `chroma run --path /db_path` to run the Chroma backend as a standalone serve ## Initialize client - JS ```javascript -import { ChromaClient } from "chromadb"; +// CJS +const { ChromaClient } = require("chromadb"); + +// ESM +import { ChromaClient } from 'chromadb' + const client = new ChromaClient(); ``` diff --git a/docs/embeddings.md b/docs/embeddings.md index c6031f2..d33d036 100644 --- a/docs/embeddings.md +++ b/docs/embeddings.md @@ -136,7 +136,13 @@ openai_ef = embedding_functions.OpenAIEmbeddingFunction( ```javascript +//CJS const {OpenAIEmbeddingFunction} = require('chromadb'); + +//ESM +import {OpenAIEmbeddingFunction} from 'chromadb' + + const embedder = new OpenAIEmbeddingFunction({openai_api_key: "apiKey"}) // use directly @@ -172,7 +178,12 @@ cohere_ef(texts=["document1","document2"]) ```javascript +//CJS const {CohereEmbeddingFunction} = require('chromadb'); + +//ESM +import {CohereEmbeddingFunction} from 'chromadb' + const embedder = new CohereEmbeddingFunction("apiKey") // use directly @@ -215,7 +226,12 @@ cohere_ef(texts=multilingual_texts) ```javascript +//CJS const {CohereEmbeddingFunction} = require('chromadb'); + +//ESM +import {CohereEmbeddingFunction} from 'chromadb' + const embedder = new CohereEmbeddingFunction("apiKey") multilingual_texts = [ 'Hello from Cohere!', 'مرحبًا من كوهير!', diff --git a/docs/getting-started.md b/docs/getting-started.md index af02963..8161edd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -69,7 +69,12 @@ chroma run --path /db_path Then create a client which connects to it: ```js +// CJS const { ChromaClient } = require("chromadb"); + +// ESM +import { ChromaClient } from 'chromadb' + const client = new ChromaClient(); ``` @@ -98,7 +103,12 @@ Please take steps to secure your API when interacting with frontend systems. ::: ```js +// CJS const { OpenAIEmbeddingFunction } = require("chromadb"); + +// ESM +import { OpenAIEmbeddingFunction } from 'chromadb' + const embedder = new OpenAIEmbeddingFunction({ openai_api_key: "your_api_key", }); diff --git a/docs/usage-guide.md b/docs/usage-guide.md index ade035d..8350668 100644 --- a/docs/usage-guide.md +++ b/docs/usage-guide.md @@ -42,7 +42,11 @@ Having many clients that are loading and saving to the same path can cause stran ```js -import { ChromaClient } from "chromadb"; +// CJS +const { ChromaClient } = require("chromadb"); + +// ESM +import { ChromaClient } from 'chromadb' ``` :::note Connecting to the backend @@ -153,7 +157,12 @@ chroma run --path /db_path The JS client then talks to the chroma server backend. ```js -import { ChromaClient } from "chromadb"; +// CJS +const { ChromaClient } = require("chromadb"); + +// ESM +import { ChromaClient } from 'chromadb' + const client = new ChromaClient(); ``` @@ -196,7 +205,11 @@ The embedding function takes text as input, and performs tokenization and embedd ```js -import { ChromaClient } from "chromadb"; +// CJS +const { ChromaClient } = require("chromadb"); + +// ESM +import { ChromaClient } from 'chromadb' ``` The JS client talks to a chroma server backend. This can run on your local computer or be easily deployed to AWS.