Skip to content

Commit

Permalink
[DOC] clarify that the async client is always available (#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb authored Jun 17, 2024
1 parent 2ea2ba2 commit 509d509
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions docs/docs.trychroma.com/pages/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ chroma_client = chromadb.HttpClient(host='localhost', port=8000)

That's it! Chroma's API will run in `client-server` mode with just this change.

---

Chroma also provides an async HTTP client. The behaviors and method signatures are identical to the synchronous client, but all methods that would block are now async. To use it, call `AsyncHttpClient` instead:

```python
import asyncio
import chromadb

async def main():
client = await chromadb.AsyncHttpClient()
collection = await client.create_collection(name="my_collection")

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

asyncio.run(main())
```

<!-- #### Run Chroma inside your application
To run the Chroma docker from inside your application code, create a docker-compose file or add to the existing one you have.
Expand Down Expand Up @@ -127,31 +147,15 @@ pip install chromadb-client
import chromadb
# Example setup of the client to connect to your chroma server
client = chromadb.HttpClient(host='localhost', port=8000)

# Or for async usage:
async def main():
client = await chromadb.AsyncHttpClient(host='localhost', port=8000)
```

Note that the `chromadb-client` package is a subset of the full Chroma library and does not include all the dependencies. If you want to use the full Chroma library, you can install the `chromadb` package instead.
Most importantly, there is no default embedding function. If you add() documents without embeddings, you must have manually specified an embedding function and installed the dependencies for it.

#### Using the Python HTTP-only **async** client

If your application is async, we provide a separate lightweight async client. The behaviors and method signatures are identical to the synchronous client, but all methods that would block are now async.

```python
import asyncio
import chromadb

async def main():
client = await chromadb.AsyncHttpClient()
collection = await client.create_collection(name="my_collection")

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

asyncio.run(main())
```

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

Expand Down

0 comments on commit 509d509

Please sign in to comment.