Skip to content

Commit

Permalink
modify reference
Browse files Browse the repository at this point in the history
  • Loading branch information
spikechroma committed Aug 26, 2024
1 parent 8386d5f commit 0e6ce9d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 26 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` using uuid v4 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 client.addRecords(collection, {
documents: [
"This is a document about pineapple",
Expand Down
13 changes: 3 additions & 10 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,8 +357,7 @@ 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"}, ...]
)
```

Expand All @@ -372,7 +370,6 @@ Raw documents:

```javascript
await client.addRecords(collection, {
ids: ["id1", "id2", "id3", ...],
metadatas: [{"chapter": "3", "verse": "16"}, {"chapter": "3", "verse": "5"}, {"chapter": "29", "verse": "11"}, ...],
documents: ["lorem ipsum...", "doc2", "doc3", ...],
})
Expand Down Expand Up @@ -401,7 +398,6 @@ 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", ...]
)
```

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

```javascript
await client.addRecords(collection, {
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 client.addRecords(collection, {
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
6 changes: 0 additions & 6 deletions docs/docs.trychroma.com/pages/reference/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,15 @@ 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"],
)
collection.add(
documents=["doc1000101", "doc288822"],
metadatas=[{"style": "style1"}, {"style": "style2"}],
ids=["uri9", "uri10"],
)

# update items in a collection
Expand Down Expand Up @@ -200,21 +197,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
3 changes: 1 addition & 2 deletions docs/docs.trychroma.com/pages/reference/js-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Add items to the collection

```javascript
const response = await collection.add({
ids: ["id1", "id2"],
embeddings: [
[1, 2, 3],
[4, 5, 6],
Expand All @@ -51,7 +50,7 @@ const response = await collection.add({
| `params` | `Object` | The parameters for the query. |
| `params.documents?` | `string` \| `Documents` | Optional documents of the items to add. |
| `params.embeddings?` | `Embedding` \| `Embeddings` | Optional embeddings of the items to add. |
| `params.ids` | `string` \| `IDs` | IDs of the items to add. |
| `params.ids` | `string` \| `IDs` | Optional IDs of the items to add. |
| `params.metadatas?` | `Metadata` \| `Metadatas` | Optional metadata of the items to add. |

#### Returns
Expand Down
8 changes: 4 additions & 4 deletions docs/docs.trychroma.com/pages/reference/py-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ The total number of embeddings added to the database
### add

```python
def add(ids: OneOrMany[ID],
def add(ids: Optiona[OneOrMany[ID]] = None,
embeddings: Optional[OneOrMany[Embedding]] = None,
metadatas: Optional[OneOrMany[Metadata]] = None,
documents: Optional[OneOrMany[Document]] = None) -> None
documents: Optional[OneOrMany[Document]] = None) -> AddResult
```

Add embeddings to the data store.

**Arguments**:

- `ids` - The ids of the embeddings you wish to add
- `ids` - The ids of the embeddings you wish to add. If None, Chroma will generate the ids using uuid v4.
- `embeddings` - The embeddings to add. If None, embeddings will be computed based on the documents using the embedding_function set for the Collection. Optional.
- `metadatas` - The metadata to associate with the embeddings. When querying, you can filter on this metadata. Optional.
- `documents` - The documents to associate with the embeddings. Optional.


**Returns**:

None
- `AddResult` - An AddResult object containing IDs.


**Raises**:
Expand Down

0 comments on commit 0e6ce9d

Please sign in to comment.