Skip to content

Commit a871e2b

Browse files
[ENH] add collection forking to js client (chroma-core#4372)
1 parent b19ce22 commit a871e2b

File tree

2 files changed

+166
-8
lines changed
  • clients/js/packages/chromadb-core/src/generated
  • rust/frontend/src

2 files changed

+166
-8
lines changed

clients/js/packages/chromadb-core/src/generated/api.ts

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,6 +3561,89 @@ export const ApiApiFetchParamCreator = function (
35613561
options: localVarRequestOptions,
35623562
};
35633563
},
3564+
/**
3565+
* @summary Forks an existing collection.
3566+
* @param {string} tenant <p>Tenant ID</p>
3567+
* @param {string} database <p>Database name</p>
3568+
* @param {string} collectionId <p>UUID of the collection to update</p>
3569+
* @param {Api.ForkCollectionPayload} request
3570+
* @param {RequestInit} [options] Override http request option.
3571+
* @throws {RequiredError}
3572+
*/
3573+
forkCollection(
3574+
tenant: string,
3575+
database: string,
3576+
collectionId: string,
3577+
request: Api.ForkCollectionPayload,
3578+
options: RequestInit = {},
3579+
): FetchArgs {
3580+
// verify required parameter 'tenant' is not null or undefined
3581+
if (tenant === null || tenant === undefined) {
3582+
throw new RequiredError(
3583+
"tenant",
3584+
"Required parameter tenant was null or undefined when calling forkCollection.",
3585+
);
3586+
}
3587+
// verify required parameter 'database' is not null or undefined
3588+
if (database === null || database === undefined) {
3589+
throw new RequiredError(
3590+
"database",
3591+
"Required parameter database was null or undefined when calling forkCollection.",
3592+
);
3593+
}
3594+
// verify required parameter 'collectionId' is not null or undefined
3595+
if (collectionId === null || collectionId === undefined) {
3596+
throw new RequiredError(
3597+
"collectionId",
3598+
"Required parameter collectionId was null or undefined when calling forkCollection.",
3599+
);
3600+
}
3601+
// verify required parameter 'request' is not null or undefined
3602+
if (request === null || request === undefined) {
3603+
throw new RequiredError(
3604+
"request",
3605+
"Required parameter request was null or undefined when calling forkCollection.",
3606+
);
3607+
}
3608+
let localVarPath =
3609+
`/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`
3610+
.replace("{tenant}", encodeURIComponent(String(tenant)))
3611+
.replace("{database}", encodeURIComponent(String(database)))
3612+
.replace("{collection_id}", encodeURIComponent(String(collectionId)));
3613+
const localVarPathQueryStart = localVarPath.indexOf("?");
3614+
const localVarRequestOptions: RequestInit = Object.assign(
3615+
{ method: "POST" },
3616+
options,
3617+
);
3618+
const localVarHeaderParameter: Headers = options.headers
3619+
? new Headers(options.headers)
3620+
: new Headers();
3621+
const localVarQueryParameter = new URLSearchParams(
3622+
localVarPathQueryStart !== -1
3623+
? localVarPath.substring(localVarPathQueryStart + 1)
3624+
: "",
3625+
);
3626+
if (localVarPathQueryStart !== -1) {
3627+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
3628+
}
3629+
3630+
localVarHeaderParameter.set("Content-Type", "application/json");
3631+
3632+
localVarRequestOptions.headers = localVarHeaderParameter;
3633+
3634+
if (request !== undefined) {
3635+
localVarRequestOptions.body = JSON.stringify(request || {});
3636+
}
3637+
3638+
const localVarQueryParameterString = localVarQueryParameter.toString();
3639+
if (localVarQueryParameterString) {
3640+
localVarPath += "?" + localVarQueryParameterString;
3641+
}
3642+
return {
3643+
url: localVarPath,
3644+
options: localVarRequestOptions,
3645+
};
3646+
},
35643647
/**
35653648
* @summary Retrieves a collection by ID or name.
35663649
* @param {string} tenant <p>Tenant ID</p>
@@ -6631,6 +6714,63 @@ export const ApiApiFp = function (configuration?: Configuration) {
66316714
});
66326715
};
66336716
},
6717+
/**
6718+
* @summary Forks an existing collection.
6719+
* @param {string} tenant <p>Tenant ID</p>
6720+
* @param {string} database <p>Database name</p>
6721+
* @param {string} collectionId <p>UUID of the collection to update</p>
6722+
* @param {Api.ForkCollectionPayload} request
6723+
* @param {RequestInit} [options] Override http request option.
6724+
* @throws {RequiredError}
6725+
*/
6726+
forkCollection(
6727+
tenant: string,
6728+
database: string,
6729+
collectionId: string,
6730+
request: Api.ForkCollectionPayload,
6731+
options?: RequestInit,
6732+
): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Collection> {
6733+
const localVarFetchArgs = ApiApiFetchParamCreator(
6734+
configuration,
6735+
).forkCollection(tenant, database, collectionId, request, options);
6736+
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
6737+
return fetch(
6738+
basePath + localVarFetchArgs.url,
6739+
localVarFetchArgs.options,
6740+
).then((response) => {
6741+
const contentType = response.headers.get("Content-Type");
6742+
const mimeType = contentType
6743+
? contentType.replace(/;.*/, "")
6744+
: undefined;
6745+
6746+
if (response.status === 200) {
6747+
if (mimeType === "application/json") {
6748+
return response.json() as any;
6749+
}
6750+
throw response;
6751+
}
6752+
if (response.status === 401) {
6753+
if (mimeType === "application/json") {
6754+
throw response;
6755+
}
6756+
throw response;
6757+
}
6758+
if (response.status === 404) {
6759+
if (mimeType === "application/json") {
6760+
throw response;
6761+
}
6762+
throw response;
6763+
}
6764+
if (response.status === 500) {
6765+
if (mimeType === "application/json") {
6766+
throw response;
6767+
}
6768+
throw response;
6769+
}
6770+
throw response;
6771+
});
6772+
};
6773+
},
66346774
/**
66356775
* @summary Retrieves a collection by ID or name.
66366776
* @param {string} tenant <p>Tenant ID</p>
@@ -8258,6 +8398,31 @@ export class ApiApi extends BaseAPI {
82588398
)(this.fetch, this.basePath);
82598399
}
82608400

8401+
/**
8402+
* @summary Forks an existing collection.
8403+
* @param {string} tenant <p>Tenant ID</p>
8404+
* @param {string} database <p>Database name</p>
8405+
* @param {string} collectionId <p>UUID of the collection to update</p>
8406+
* @param {Api.ForkCollectionPayload} request
8407+
* @param {RequestInit} [options] Override http request option.
8408+
* @throws {RequiredError}
8409+
*/
8410+
public forkCollection(
8411+
tenant: string,
8412+
database: string,
8413+
collectionId: string,
8414+
request: Api.ForkCollectionPayload,
8415+
options?: RequestInit,
8416+
) {
8417+
return ApiApiFp(this.configuration).forkCollection(
8418+
tenant,
8419+
database,
8420+
collectionId,
8421+
request,
8422+
options,
8423+
)(this.fetch, this.basePath);
8424+
}
8425+
82618426
/**
82628427
* @summary Retrieves a collection by ID or name.
82638428
* @param {string} tenant <p>Tenant ID</p>

rust/frontend/src/server.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -916,14 +916,7 @@ async fn create_collection(
916916
c,
917917
server.config.frontend.default_knn_index,
918918
)?),
919-
None => Some(InternalCollectionConfiguration::try_from_config(
920-
CollectionConfiguration {
921-
hnsw: None,
922-
spann: None,
923-
embedding_function: None,
924-
},
925-
server.config.frontend.default_knn_index,
926-
)?),
919+
None => None,
927920
};
928921

929922
let request = CreateCollectionRequest::try_new(

0 commit comments

Comments
 (0)