Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 8b98559

Browse files
committed
esm and cjs syntax for imports for chromadb 1.6.1 release
1 parent f66f10b commit 8b98559

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

docs/api-reference.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ Run `chroma run --path /db_path` to run the Chroma backend as a standalone serve
157157
## Initialize client - JS
158158

159159
```javascript
160-
import { ChromaClient } from "chromadb";
160+
// CJS
161+
const { ChromaClient } = require("chromadb");
162+
163+
// ESM
164+
import { ChromaClient } from 'chromadb'
165+
161166
const client = new ChromaClient();
162167
```
163168

docs/embeddings.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ openai_ef = embedding_functions.OpenAIEmbeddingFunction(
136136
<TabItem value="js" label="JavaScript">
137137

138138
```javascript
139+
//CJS
139140
const {OpenAIEmbeddingFunction} = require('chromadb');
141+
142+
//ESM
143+
import {OpenAIEmbeddingFunction} from 'chromadb'
144+
145+
140146
const embedder = new OpenAIEmbeddingFunction({openai_api_key: "apiKey"})
141147

142148
// use directly
@@ -172,7 +178,12 @@ cohere_ef(texts=["document1","document2"])
172178
<TabItem value="js" label="JavaScript">
173179

174180
```javascript
181+
//CJS
175182
const {CohereEmbeddingFunction} = require('chromadb');
183+
184+
//ESM
185+
import {CohereEmbeddingFunction} from 'chromadb'
186+
176187
const embedder = new CohereEmbeddingFunction("apiKey")
177188

178189
// use directly
@@ -215,7 +226,12 @@ cohere_ef(texts=multilingual_texts)
215226
<TabItem value="js" label="JavaScript">
216227

217228
```javascript
229+
//CJS
218230
const {CohereEmbeddingFunction} = require('chromadb');
231+
232+
//ESM
233+
import {CohereEmbeddingFunction} from 'chromadb'
234+
219235
const embedder = new CohereEmbeddingFunction("apiKey")
220236

221237
multilingual_texts = [ 'Hello from Cohere!', 'مرحبًا من كوهير!',

docs/getting-started.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ chroma run --path /db_path
6969
Then create a client which connects to it:
7070

7171
```js
72+
// CJS
7273
const { ChromaClient } = require("chromadb");
74+
75+
// ESM
76+
import { ChromaClient } from 'chromadb'
77+
7378
const client = new ChromaClient();
7479
```
7580

@@ -98,7 +103,12 @@ Please take steps to secure your API when interacting with frontend systems.
98103
:::
99104

100105
```js
106+
// CJS
101107
const { OpenAIEmbeddingFunction } = require("chromadb");
108+
109+
// ESM
110+
import { OpenAIEmbeddingFunction } from 'chromadb'
111+
102112
const embedder = new OpenAIEmbeddingFunction({
103113
openai_api_key: "your_api_key",
104114
});

docs/usage-guide.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ Having many clients that are loading and saving to the same path can cause stran
4242
<TabItem value="js" label="JavaScript">
4343

4444
```js
45-
import { ChromaClient } from "chromadb";
45+
// CJS
46+
const { ChromaClient } = require("chromadb");
47+
48+
// ESM
49+
import { ChromaClient } from 'chromadb'
4650
```
4751

4852
:::note Connecting to the backend
@@ -153,7 +157,12 @@ chroma run --path /db_path
153157
The JS client then talks to the chroma server backend.
154158

155159
```js
156-
import { ChromaClient } from "chromadb";
160+
// CJS
161+
const { ChromaClient } = require("chromadb");
162+
163+
// ESM
164+
import { ChromaClient } from 'chromadb'
165+
157166
const client = new ChromaClient();
158167
```
159168

@@ -196,7 +205,11 @@ The embedding function takes text as input, and performs tokenization and embedd
196205
<TabItem value="js" label="JavaScript">
197206

198207
```js
199-
import { ChromaClient } from "chromadb";
208+
// CJS
209+
const { ChromaClient } = require("chromadb");
210+
211+
// ESM
212+
import { ChromaClient } from 'chromadb'
200213
```
201214

202215
The JS client talks to a chroma server backend. This can run on your local computer or be easily deployed to AWS.

0 commit comments

Comments
 (0)