chromadb
Version:
A JavaScript interface for chroma
692 lines (647 loc) • 26.7 kB
text/typescript
// This file is auto-generated by @hey-api/openapi-ts
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
import type { GetUserIdentityData, GetUserIdentityResponse2, GetUserIdentityError, GetCollectionByCrnData, GetCollectionByCrnResponse, GetCollectionByCrnError, HealthcheckData, HealthcheckResponse, HealthcheckError, HeartbeatData, HeartbeatResponse2, HeartbeatError, PreFlightChecksData, PreFlightChecksResponse, PreFlightChecksError, ResetData, ResetResponse, ResetError, CreateTenantData, CreateTenantResponse2, CreateTenantError, GetTenantData, GetTenantResponse2, GetTenantError, UpdateTenantData, UpdateTenantResponse2, UpdateTenantError, ListDatabasesData, ListDatabasesResponse, ListDatabasesError, CreateDatabaseData, CreateDatabaseResponse2, CreateDatabaseError, DeleteDatabaseData, DeleteDatabaseResponse2, DeleteDatabaseError, GetDatabaseData, GetDatabaseResponse, GetDatabaseError, ListCollectionsData, ListCollectionsResponse, ListCollectionsError, CreateCollectionData, CreateCollectionResponse, CreateCollectionError, GetCollectionByIdData, GetCollectionByIdResponse, GetCollectionByIdError, DeleteCollectionData, DeleteCollectionResponse2, DeleteCollectionError, GetCollectionData, GetCollectionResponse, GetCollectionError, UpdateCollectionData, UpdateCollectionResponse2, UpdateCollectionError, CollectionAddData, CollectionAddResponse, AddAttachedFunctionInputData, AddAttachedFunctionInputResponse2, AddAttachedFunctionInputError, DetachFunctionData, DetachFunctionResponse2, DetachFunctionError, CollectionCountData, CollectionCountResponse, CollectionCountError, CollectionDeleteData, CollectionDeleteResponse, CollectionDeleteError, ForkCollectionData, ForkCollectionResponse, ForkCollectionError, ForkCountData, ForkCountResponse2, ForkCountError, AttachFunctionData, AttachFunctionResponse2, AttachFunctionError, GetAttachedFunctionData, GetAttachedFunctionResponse2, GetAttachedFunctionError, CollectionGetData, CollectionGetResponse, CollectionGetError, IndexingStatusData, IndexingStatusResponse, IndexingStatusError, CollectionQueryData, CollectionQueryResponse, CollectionQueryError, CollectionSearchData, CollectionSearchResponse, CollectionSearchError, CollectionUpdateData, CollectionUpdateResponse, CollectionUpsertData, CollectionUpsertResponse, CollectionUpsertError, CountCollectionsData, CountCollectionsResponse, CountCollectionsError, VersionData, VersionResponse } from './types.gen';
import { client as _heyApiClient } from './client.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
/**
* You can provide a client instance returned by `createClient()` instead of
* individual options. This might be also useful if you want to implement a
* custom client.
*/
client?: Client;
/**
* You can pass arbitrary values through the `meta` object. This can be
* used to access values that aren't defined as part of the SDK function.
*/
meta?: Record<string, unknown>;
};
export class AuthenticationService {
/**
* Get user identity
* Returns the current user's identity, tenant, and databases.
*/
public static getUserIdentity<ThrowOnError extends boolean = true>(options?: Options<GetUserIdentityData, ThrowOnError>) {
return (options?.client ?? _heyApiClient).get<GetUserIdentityResponse2, GetUserIdentityError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/auth/identity',
...options
});
}
}
export class CollectionService {
/**
* Get collection by CRN
* Returns a collection by Chroma Resource Name.
*/
public static getCollectionByCrn<ThrowOnError extends boolean = true>(options: Options<GetCollectionByCrnData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<GetCollectionByCrnResponse, GetCollectionByCrnError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/collections/{crn}',
...options
});
}
/**
* List collections
* Lists all collections in a database.
*/
public static listCollections<ThrowOnError extends boolean = true>(options: Options<ListCollectionsData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<ListCollectionsResponse, ListCollectionsError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections',
...options
});
}
/**
* Create collection
* Creates a new collection in a database.
*/
public static createCollection<ThrowOnError extends boolean = true>(options: Options<CreateCollectionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CreateCollectionResponse, CreateCollectionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Get collection by ID
* Returns a collection by its UUID within a specific tenant and database.
*/
public static getCollectionById<ThrowOnError extends boolean = true>(options: Options<GetCollectionByIdData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<GetCollectionByIdResponse, GetCollectionByIdError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/by-id/{collection_id}',
...options
});
}
/**
* Delete collection
* Deletes a collection in a database.
*/
public static deleteCollection<ThrowOnError extends boolean = true>(options: Options<DeleteCollectionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).delete<DeleteCollectionResponse2, DeleteCollectionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}',
...options
});
}
/**
* Get collection
* Returns a collection by ID or name.
*/
public static getCollection<ThrowOnError extends boolean = true>(options: Options<GetCollectionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<GetCollectionResponse, GetCollectionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}',
...options
});
}
/**
* Update collection
* Updates an existing collection's name or metadata.
*/
public static updateCollection<ThrowOnError extends boolean = true>(options: Options<UpdateCollectionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).put<UpdateCollectionResponse2, UpdateCollectionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Fork collection
* Creates a fork of an existing collection.
*/
public static forkCollection<ThrowOnError extends boolean = true>(options: Options<ForkCollectionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<ForkCollectionResponse, ForkCollectionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Get fork count
* Returns the number of forks for a collection.
*/
public static forkCount<ThrowOnError extends boolean = true>(options: Options<ForkCountData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<ForkCountResponse2, ForkCountError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork_count',
...options
});
}
/**
* Get number of collections
* Returns the total number of collections in a database.
*/
public static countCollections<ThrowOnError extends boolean = true>(options: Options<CountCollectionsData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<CountCollectionsResponse, CountCollectionsError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections_count',
...options
});
}
}
export class SystemService {
/**
* Healthcheck
* Returns the health status of the service.
*/
public static healthcheck<ThrowOnError extends boolean = true>(options?: Options<HealthcheckData, ThrowOnError>) {
return (options?.client ?? _heyApiClient).get<HealthcheckResponse, HealthcheckError, ThrowOnError>({
url: '/api/v2/healthcheck',
...options
});
}
/**
* Heartbeat
* Returns a nanosecond timestamp of the current time.
*/
public static heartbeat<ThrowOnError extends boolean = true>(options?: Options<HeartbeatData, ThrowOnError>) {
return (options?.client ?? _heyApiClient).get<HeartbeatResponse2, HeartbeatError, ThrowOnError>({
url: '/api/v2/heartbeat',
...options
});
}
/**
* Pre-flight checks
* Returns basic readiness information.
*/
public static preFlightChecks<ThrowOnError extends boolean = true>(options?: Options<PreFlightChecksData, ThrowOnError>) {
return (options?.client ?? _heyApiClient).get<PreFlightChecksResponse, PreFlightChecksError, ThrowOnError>({
url: '/api/v2/pre-flight-checks',
...options
});
}
/**
* Reset database
* Resets the database. Requires authorization.
*/
public static reset<ThrowOnError extends boolean = true>(options?: Options<ResetData, ThrowOnError>) {
return (options?.client ?? _heyApiClient).post<ResetResponse, ResetError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/reset',
...options
});
}
/**
* Get version
* Returns the version of the server.
*/
public static version<ThrowOnError extends boolean = true>(options?: Options<VersionData, ThrowOnError>) {
return (options?.client ?? _heyApiClient).get<VersionResponse, unknown, ThrowOnError>({
url: '/api/v2/version',
...options
});
}
}
export class TenantService {
/**
* Create tenant
* Creates a new tenant.
*/
public static createTenant<ThrowOnError extends boolean = true>(options: Options<CreateTenantData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CreateTenantResponse2, CreateTenantError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Get tenant
* Returns an existing tenant by name.
*/
public static getTenant<ThrowOnError extends boolean = true>(options: Options<GetTenantData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<GetTenantResponse2, GetTenantError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant_name}',
...options
});
}
/**
* Update tenant
* Updates an existing tenant by name.
*/
public static updateTenant<ThrowOnError extends boolean = true>(options: Options<UpdateTenantData, ThrowOnError>) {
return (options.client ?? _heyApiClient).patch<UpdateTenantResponse2, UpdateTenantError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant_name}',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
}
export class DatabaseService {
/**
* List databases
* Lists all databases for a tenant.
*/
public static listDatabases<ThrowOnError extends boolean = true>(options: Options<ListDatabasesData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<ListDatabasesResponse, ListDatabasesError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases',
...options
});
}
/**
* Create database
* Creates a new database for a tenant.
*/
public static createDatabase<ThrowOnError extends boolean = true>(options: Options<CreateDatabaseData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CreateDatabaseResponse2, CreateDatabaseError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Delete database
* Deletes a database by name.
*/
public static deleteDatabase<ThrowOnError extends boolean = true>(options: Options<DeleteDatabaseData, ThrowOnError>) {
return (options.client ?? _heyApiClient).delete<DeleteDatabaseResponse2, DeleteDatabaseError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}',
...options
});
}
/**
* Get database
* Returns a database by name.
*/
public static getDatabase<ThrowOnError extends boolean = true>(options: Options<GetDatabaseData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<GetDatabaseResponse, GetDatabaseError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}',
...options
});
}
}
export class RecordService {
/**
* Add records
* Adds records to a collection.
*/
public static collectionAdd<ThrowOnError extends boolean = true>(options: Options<CollectionAddData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CollectionAddResponse, unknown, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/add',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Get number of records
* Returns the number of records in a collection.
*/
public static collectionCount<ThrowOnError extends boolean = true>(options: Options<CollectionCountData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<CollectionCountResponse, CollectionCountError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/count',
...options
});
}
/**
* Delete records
* Deletes records in a collection. Can filter by IDs or metadata.
*/
public static collectionDelete<ThrowOnError extends boolean = true>(options: Options<CollectionDeleteData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CollectionDeleteResponse, CollectionDeleteError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/delete',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Get records
* Returns records from a collection by ID or metadata filter.
*/
public static collectionGet<ThrowOnError extends boolean = true>(options: Options<CollectionGetData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CollectionGetResponse, CollectionGetError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/get',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Get indexing status
* Returns the indexing status of a collection.
*/
public static indexingStatus<ThrowOnError extends boolean = true>(options: Options<IndexingStatusData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<IndexingStatusResponse, IndexingStatusError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/indexing_status',
...options
});
}
/**
* Query collection
* Queries a collection using dense vector search with metadata and full-text search filtering.
*/
public static collectionQuery<ThrowOnError extends boolean = true>(options: Options<CollectionQueryData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CollectionQueryResponse, CollectionQueryError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/query',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Search records
* Searches records from a collection with dense, sparse, or hybrid vector search.
*/
public static collectionSearch<ThrowOnError extends boolean = true>(options: Options<CollectionSearchData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CollectionSearchResponse, CollectionSearchError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/search',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Update records
* Updates records in a collection by ID.
*/
public static collectionUpdate<ThrowOnError extends boolean = true>(options: Options<CollectionUpdateData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CollectionUpdateResponse, unknown, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/update',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Upsert records
* Upserts records in a collection (create if not exists, otherwise update).
*/
public static collectionUpsert<ThrowOnError extends boolean = true>(options: Options<CollectionUpsertData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<CollectionUpsertResponse, CollectionUpsertError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/upsert',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
}
export class FunctionService {
/**
* Add attached function input
* Adds a new input collection to an existing async attached function.
*/
public static addAttachedFunctionInput<ThrowOnError extends boolean = true>(options: Options<AddAttachedFunctionInputData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<AddAttachedFunctionInputResponse2, AddAttachedFunctionInputError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/attached_functions/{name}/add_input',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Detach function
* Detaches a function from a collection.
*/
public static detachFunction<ThrowOnError extends boolean = true>(options: Options<DetachFunctionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<DetachFunctionResponse2, DetachFunctionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/attached_functions/{name}/detach',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Attach function
* Attaches a function to a collection.
*/
public static attachFunction<ThrowOnError extends boolean = true>(options: Options<AttachFunctionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).post<AttachFunctionResponse2, AttachFunctionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/functions/attach',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
}
/**
* Get attached function
* Returns an attached function by name.
*/
public static getAttachedFunction<ThrowOnError extends boolean = true>(options: Options<GetAttachedFunctionData, ThrowOnError>) {
return (options.client ?? _heyApiClient).get<GetAttachedFunctionResponse2, GetAttachedFunctionError, ThrowOnError>({
security: [
{
name: 'x-chroma-token',
type: 'apiKey'
}
],
url: '/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/functions/{function_name}',
...options
});
}
}