Skip to content

Commit

Permalink
Update JS client
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Jan 9, 2025
1 parent 375f068 commit 37701ee
Show file tree
Hide file tree
Showing 9 changed files with 568 additions and 228 deletions.
5 changes: 4 additions & 1 deletion chromadb/db/mixins/sysdb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import sys
from typing import Optional, Sequence, Any, Tuple, cast, Dict, Union, Set
from uuid import UUID
from overrides import override
Expand Down Expand Up @@ -129,8 +130,10 @@ def list_databases(
.from_(databases)
.select(databases.id, databases.name)
.where(databases.tenant_id == ParameterValue(tenant))
.limit(limit)
.offset(offset)
.limit(
sys.maxsize if limit is None else limit
) # SQLite requires that a limit is provided to use offset
.orderby(databases.created_at)
)
sql, params = get_sql(q, self.parameter_format())
Expand Down
29 changes: 29 additions & 0 deletions clients/js/src/AdminClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,33 @@ export class AdminClient {

return { name: getDatabase.name } as Database;
}

/**
* Lists database for a specific tenant.
*
* @param {Object} params - The parameters for listing databases.
* @param {number} [params.limit] - The maximum number of databases to return.
* @param {number} [params.offset] - The number of databases to skip.
*
* @returns {Promise<Database[]>} A promise that resolves to a list of databases.
* @throws {Error} If there is an issue listing the databases.
*/
public async listDatabases({
limit,
offset,
tenantName,
}: {
limit?: number;
offset?: number;
tenantName: string;
}): Promise<Database[]> {
const listDatabases = (await this.api.listDatabases(
tenantName,
limit,
offset,
this.api.options,
)) as Database[];

return listDatabases.map((db) => ({ name: db.name }));
}
}
4 changes: 2 additions & 2 deletions clients/js/src/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class Collection {
(await prepareRecordRequest(
params,
this.embeddingFunction,
)) as GeneratedApi.AddEmbedding,
)) as GeneratedApi.AddRequest,
this.client.api.options,
);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export class Collection {
(await prepareRecordRequest(
params,
this.embeddingFunction,
)) as GeneratedApi.AddEmbedding,
)) as GeneratedApi.AddRequest,
this.client.api.options,
);
}
Expand Down
361 changes: 217 additions & 144 deletions clients/js/src/generated/api.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clients/js/src/generated/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* Chroma
*
*
* OpenAPI spec version: 0.1.0
* OpenAPI spec version: 0.5.6.dev52
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
Expand Down
4 changes: 2 additions & 2 deletions clients/js/src/generated/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* Chroma
*
*
* OpenAPI spec version: 0.1.0
* OpenAPI spec version: 0.5.6.dev52
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
Expand Down
Loading

0 comments on commit 37701ee

Please sign in to comment.