Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
spikechroma committed Sep 11, 2024
1 parent 68c1f7d commit fa84e7f
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 90 deletions.
24 changes: 23 additions & 1 deletion docs/docs.trychroma.com/pages/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,23 @@ const collection = await client.createCollection({

### 4. Add some text documents to the collection

Chroma will store your text and handle embedding and indexing automatically. You can also customize the embedding model.
Chroma will store your text and handle embedding and indexing automatically. You can also customize the embedding model. When you add documents, IDs are optional. If you don't provide `ids`, Chroma will automatically generate `ids` for you.

{% tabs group="code-lang" hideTabs=true %}
{% tab label="Python" %}

```python
# Add docs without IDs
result = collection.add(
documents=[
"This is a document about pineapple",
"This is a document about oranges"
]
)

ids = result["ids"]

# Add docs with IDs
collection.add(
documents=[
"This is a document about pineapple",
Expand All @@ -162,6 +173,17 @@ collection.add(
{% tab label="Javascript" %}

```js
// Add docs without Ids
result = await client.addRecords(collection, {
documents: [
"This is a document about pineapple",
"This is a document about oranges",
]
});

ids = result.ids

// Add docs with Ids
await collection.add({
documents: [
"This is a document about pineapple",
Expand Down
19 changes: 6 additions & 13 deletions docs/docs.trychroma.com/pages/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ async def main():
collection = await client.create_collection(name="my_collection")

await collection.add(
documents=["hello world"],
ids=["id1"]
documents=["hello world"]
)

asyncio.run(main())
Expand Down Expand Up @@ -358,26 +357,24 @@ Raw documents:
```python
collection.add(
documents=["lorem ipsum...", "doc2", "doc3", ...],
metadatas=[{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...],
ids=["id1", "id2", "id3", ...]
metadatas=[{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...]
)
```

{% /tab %}
{% tab label="Javascript" %}

Add data to Chroma with `.addRecords`.
Add data to Chroma with `.add`.

Raw documents:

```javascript
await collection.add({
ids: ["id1", "id2", "id3", ...],
metadatas: [{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...],
documents: ["lorem ipsum...", "doc2", "doc3", ...],
})
// input order
// ids - required
// ids - optional
// embeddings - optional
// metadata - optional
// documents - optional
Expand All @@ -400,8 +397,7 @@ Alternatively, you can supply a list of document-associated `embeddings` directl
collection.add(
documents=["doc1", "doc2", "doc3", ...],
embeddings=[[1.1, 2.3, 3.2], [4.5, 6.9, 4.4], [1.1, 2.3, 3.2], ...],
metadatas=[{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...],
ids=["id1", "id2", "id3", ...]
metadatas=[{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...]
)
```

Expand All @@ -410,7 +406,6 @@ collection.add(

```javascript
await collection.add({
ids: ["id1", "id2", "id3", ...],
embeddings: [[1.1, 2.3, 3.2], [4.5, 6.9, 4.4], [1.1, 2.3, 3.2], ...],
metadatas: [{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...],
documents: ["lorem ipsum...", "doc2", "doc3", ...],
Expand All @@ -432,8 +427,7 @@ You can also store documents elsewhere, and just supply a list of `embeddings` a
```python
collection.add(
embeddings=[[1.1, 2.3, 3.2], [4.5, 6.9, 4.4], [1.1, 2.3, 3.2], ...],
metadatas=[{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...],
ids=["id1", "id2", "id3", ...]
metadatas=[{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...]
)
```

Expand All @@ -442,7 +436,6 @@ collection.add(

```javascript
await collection.add({
ids: ["id1", "id2", "id3", ...],
embeddings: [[1.1, 2.3, 3.2], [4.5, 6.9, 4.4], [1.1, 2.3, 3.2], ...],
metadatas: [{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...],
})
Expand Down
3 changes: 0 additions & 3 deletions docs/docs.trychroma.com/pages/guides/multimodal.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ You can add data to a multi-modal collection by specifying the data modality. Fo

```python
collection.add(
ids=['id1', 'id2', 'id3'],
images=[...] # A list of numpy arrays representing images
)
```
Expand All @@ -76,7 +75,6 @@ However, you can use Chroma in combination with data stored elsewhere, by adding

```python
collection.add(
ids=['id1', 'id2', 'id3'],
uris=[...] # A list of strings representing URIs to data
)
```
Expand All @@ -85,7 +83,6 @@ Since the embedding function is multi-modal, you can also add text to the same c

```python
collection.add(
ids=['id4', 'id5', 'id6'],
texts=["This is a document", "This is another document", "This is a third document"]
)
```
Expand Down
11 changes: 2 additions & 9 deletions docs/docs.trychroma.com/pages/reference/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,17 @@ collection.count()
# add new items to a collection
# either one at a time
collection.add(
embeddings=[1.5, 2.9, 3.4],
metadatas={"uri": "img9.png", "style": "style1"},
documents="doc1000101",
ids="uri9",
)
# or many, up to 100k+!
collection.add(
embeddings=[[1.5, 2.9, 3.4], [9.8, 2.3, 2.9]],
metadatas=[{"style": "style1"}, {"style": "style2"}],
ids=["uri9", "uri10"],
metadatas=[{"style": "style1"}, {"style": "style2"}]
)
collection.add(
documents=["doc1000101", "doc288822"],
metadatas=[{"style": "style1"}, {"style": "style2"}],
ids=["uri9", "uri10"],
metadatas=[{"style": "style1"}, {"style": "style2"}]
)

# update items in a collection
Expand Down Expand Up @@ -200,21 +196,18 @@ await collection.count()
// add new items to a collection
// either one at a time
await collection.add({
ids: "id1",
embeddings: [1.5, 2.9, 3.4],
metadatas: {"source": "my_source"},
documents: "This is a document",
})
// or many, up to 100k+!
await collection.add({
ids: ["uri9", "uri10"],
embeddings: [[1.5, 2.9, 3.4], [9.8, 2.3, 2.9]],
metadatas: [{"style": "style1"}, {"style": "style2"}],
documents: ["This is a document", 'that is a document']
})
// including just documents
await collection.add({
ids: ["uri9", "uri10"],
metadatas: [{"style": "style1"}, {"style": "style2"}],
documents: ["doc1000101", "doc288822"],
})
Expand Down
6 changes: 3 additions & 3 deletions docs/docs.trychroma.com/pages/reference/js-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ___

### add

**add**(`params`): `Promise`\<`void`\>
**add**(`params`): `Promise`\<`AddResponse`\>

Add items to the collection

Expand All @@ -40,7 +40,7 @@ Add items to the collection

#### Returns

`Promise`\<`void`\>
`Promise`\<`AddResponse`\>

- The response from the API. True if successful.

Expand Down Expand Up @@ -294,7 +294,7 @@ Upsert items to the collection

| Name | Type | Description |
| :------ | :------ | :------ |
| `params` | `AddRecordsParams` | The parameters for the query. |
| `params` | `UpsertRecordsParams` | The parameters for the query. |

#### Returns

Expand Down
Loading

0 comments on commit fa84e7f

Please sign in to comment.