Support Chroma v2 API #35
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #30.
Summary
To use the Chroma v2 API, Chroma version 0.6.3 or later is required. The v1 API has already been deprecated and is therefore not supported by this chroma-db gem: chroma-core/chroma#3498
This PR includes the following changes:
Existing API
Chroma v2 API URLs are updated to include
tenants/#{tenant}/databases/{database}. For compatibility, the Ruby interfaces forChroma::Resources::DatabaseandChroma::Resources::Collectionremain unchanged.New API
The following APIs have been added. As these are new APIs, they should not affect the existing ones. The corresponding Ruby implementation methods for each endpoint URL are as follows.
GET /auth/identity
Chroma::Resources::Database.auth_identityGET /healthcheck
Chroma::Resources::Database.healthcheckGET /pre-flight-checks
Chroma::Resources::Database.pre_flight_checksPOST /tenants/#{tenant}/databases/#{database}/collections_count
Both an instance method on
Databaseand a class method onDatabaseare provided to retrieve the number ofCollections. The latter follows the value set inChroma.database(default isdefault_database).Chroma::Resources::Database#collections_countChroma::Resources::Collection.collections_countTenant,Database, andCollectionhave a parent-child relationship as shown.Two experimental APIs are currently provided for this functionality, and if the interface useful, the same pattern can be applied to other APIs as well.
Alternatively, if only one approach is sufficient, either can be removed, please feel free to suggest which.
POST /tenants/#{tenant}/databases/#{database}/collections/#{collection_id}/fork
Chroma::Resources::Collection#forkPOST /api/v2/tenants
Chroma::Resources::Tenant.create(name)GET /api/v2/tenants/#{tenant}
Chroma::Resources::Tenant.get(name)GET /api/v2/tenants/#{tenant}/databases
Chroma::Resources::Database.listPOST /api/v2/tenants/#{tenant}/databases
Chroma::Resources::Database.create(name)GET /api/v2/tenants/#{tenant}/databases/#{database}
Chroma::Resources::Database.get(name)DELETE /api/v2/tenants/#{tenant}/databases/#{database}
Chroma::Resources::Database.delete(name)Additional Information
This PR adds support for the Chroma v2 API in a backward-compatible manner. It may be possible to design a better Ruby API that more explicitly reflects the parent-child relationship between
Tenant,Database, andCollection, but such improvements can be explored in a furure step, after ensuring compatibility.Note that compatibility here refers only to usage of the Ruby API. As noted in the addition to README.md, the Chroma database itself requires version 0.6.3 or higher, which supports Chroma v2 API.