chroma-core / chroma

the AI-native open-source embedding database
https://www.trychroma.com/
Apache License 2.0
14.77k stars 1.23k forks source link

How to create a new tenant and database while creating a collection? #1474

Closed Praj-23 closed 9 months ago

Praj-23 commented 10 months ago

I wanted to create a collection with different tenant and database other than the default one, how can I do that?

tazarov commented 10 months ago

@Praj-23, have a look here https://github.com/chroma-core/chroma/blob/main/chromadb/test/client/test_database_tenant.py

tazarov commented 9 months ago

@Praj-23, did the test example address your question?

Praj-23 commented 9 months ago

Yes, that resolved my issue Thank you

etiennebonnafoux commented 3 months ago

Hello,

Sorry to re-open this issue. Just to be sure the AdminClient has two methodes create_tenant and create_database. They create database and tenant if I use chromadb on standalone mode.

But if I want to use chroma db in server/client mode (so with a HttpClient) how can I create a db and tenant in the server ?

etiennebonnafoux commented 3 months ago

A second question related create_tenant and create_database raise error if the tenant or database already exist. Is there a simple why to ignore the instruction if the object already exist, or should I do a try/except to catch the Exception ?

RuthNjeri6 commented 1 month ago

@etiennebonnafoux try the solution from https://cookbook.chromadb.dev/strategies/multi-tenancy/naive-multi-tenancy/#user-per-tenant it works for me. You use get_tenant in the try block and create_tenant in the except block.