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

Commit

Permalink
docs: Updated js example to align with implementation.
Browse files Browse the repository at this point in the history
- Also added a note about the max batch size.

Ref: chroma-core/chroma#1271
  • Loading branch information
tazarov committed Apr 6, 2024
1 parent 578e332 commit 60293cc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docs/embeddings/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ Chroma provides a convenient wrapper around Cloudflare Workers AI REST API. This

Visit the [Cloudflare Workers AI documentation](https://developers.cloudflare.com/workers-ai/) for more information on getting started.

:::note
Currently cloudflare embeddings endpoints allow batches of maximum 100 documents in a single request. The EF has a hard limit of 100 documents per request, and will raise an error if you try to pass more than 100 documents.
:::

<Tabs queryString groupId="lang" className="hideTabSwitcher">
<TabItem value="py" label="Python">

```python
import chromadb.utils.embedding_functions as embedding_functions
cf_ef = embedding_functions.CloudflareWorkersAIEmbeddingFunction(
api_key = "YOUR_API_KEY",
account_id = "YOUR_ACCOUNT_ID",
account_id = "YOUR_ACCOUNT_ID", # or gateway_endpoint
model_name = "@cf/baai/bge-base-en-v1.5",
)
cf_ef(input=["This is my first text to embed", "This is my second document"])
Expand All @@ -39,9 +43,9 @@ You can pass in an optional `model_name` argument, which lets you choose which C
// const {CloudflareWorkersAIEmbeddingFunction} = require('chromadb'); //CJS import
import {CloudflareWorkersAIEmbeddingFunction} from "chromadb"; //ESM import
const embedder = new CloudflareWorkersAIEmbeddingFunction({
api_key: 'YOUR_API_KEY',
account_id: "YOUR_ACCOUNT_ID",
model_name: '@cf/baai/bge-base-en-v1.5',
apiToken: 'YOUR_API_KEY',
accountId: "YOUR_ACCOUNT_ID", // or gatewayEndpoint
model: '@cf/baai/bge-base-en-v1.5',
});

// use directly
Expand Down

0 comments on commit 60293cc

Please sign in to comment.