Skip to content

Commit c0b3f84

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

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
@@ -3727,6 +3727,89 @@ export const ApiApiFetchParamCreator = function (
37273727
options: localVarRequestOptions,
37283728
};
37293729
},
3730+
/**
3731+
* @summary Forks an existing collection.
3732+
* @param {string} tenant <p>Tenant ID</p>
3733+
* @param {string} database <p>Database name</p>
3734+
* @param {string} collectionId <p>UUID of the collection to update</p>
3735+
* @param {Api.ForkCollectionPayload} request
3736+
* @param {RequestInit} [options] Override http request option.
3737+
* @throws {RequiredError}
3738+
*/
3739+
forkCollection(
3740+
tenant: string,
3741+
database: string,
3742+
collectionId: string,
3743+
request: Api.ForkCollectionPayload,
3744+
options: RequestInit = {},
3745+
): FetchArgs {
3746+
// verify required parameter 'tenant' is not null or undefined
3747+
if (tenant === null || tenant === undefined) {
3748+
throw new RequiredError(
3749+
"tenant",
3750+
"Required parameter tenant was null or undefined when calling forkCollection.",
3751+
);
3752+
}
3753+
// verify required parameter 'database' is not null or undefined
3754+
if (database === null || database === undefined) {
3755+
throw new RequiredError(
3756+
"database",
3757+
"Required parameter database was null or undefined when calling forkCollection.",
3758+
);
3759+
}
3760+
// verify required parameter 'collectionId' is not null or undefined
3761+
if (collectionId === null || collectionId === undefined) {
3762+
throw new RequiredError(
3763+
"collectionId",
3764+
"Required parameter collectionId was null or undefined when calling forkCollection.",
3765+
);
3766+
}
3767+
// verify required parameter 'request' is not null or undefined
3768+
if (request === null || request === undefined) {
3769+
throw new RequiredError(
3770+
"request",
3771+
"Required parameter request was null or undefined when calling forkCollection.",
3772+
);
3773+
}
3774+
let localVarPath =
3775+
`/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`
3776+
.replace("{tenant}", encodeURIComponent(String(tenant)))
3777+
.replace("{database}", encodeURIComponent(String(database)))
3778+
.replace("{collection_id}", encodeURIComponent(String(collectionId)));
3779+
const localVarPathQueryStart = localVarPath.indexOf("?");
3780+
const localVarRequestOptions: RequestInit = Object.assign(
3781+
{ method: "POST" },
3782+
options,
3783+
);
3784+
const localVarHeaderParameter: Headers = options.headers
3785+
? new Headers(options.headers)
3786+
: new Headers();
3787+
const localVarQueryParameter = new URLSearchParams(
3788+
localVarPathQueryStart !== -1
3789+
? localVarPath.substring(localVarPathQueryStart + 1)
3790+
: "",
3791+
);
3792+
if (localVarPathQueryStart !== -1) {
3793+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
3794+
}
3795+
3796+
localVarHeaderParameter.set("Content-Type", "application/json");
3797+
3798+
localVarRequestOptions.headers = localVarHeaderParameter;
3799+
3800+
if (request !== undefined) {
3801+
localVarRequestOptions.body = JSON.stringify(request || {});
3802+
}
3803+
3804+
const localVarQueryParameterString = localVarQueryParameter.toString();
3805+
if (localVarQueryParameterString) {
3806+
localVarPath += "?" + localVarQueryParameterString;
3807+
}
3808+
return {
3809+
url: localVarPath,
3810+
options: localVarRequestOptions,
3811+
};
3812+
},
37303813
/**
37313814
* @summary Retrieves a collection by ID or name.
37323815
* @param {string} tenant <p>Tenant ID</p>
@@ -6911,6 +6994,63 @@ export const ApiApiFp = function (configuration?: Configuration) {
69116994
});
69126995
};
69136996
},
6997+
/**
6998+
* @summary Forks an existing collection.
6999+
* @param {string} tenant <p>Tenant ID</p>
7000+
* @param {string} database <p>Database name</p>
7001+
* @param {string} collectionId <p>UUID of the collection to update</p>
7002+
* @param {Api.ForkCollectionPayload} request
7003+
* @param {RequestInit} [options] Override http request option.
7004+
* @throws {RequiredError}
7005+
*/
7006+
forkCollection(
7007+
tenant: string,
7008+
database: string,
7009+
collectionId: string,
7010+
request: Api.ForkCollectionPayload,
7011+
options?: RequestInit,
7012+
): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Collection> {
7013+
const localVarFetchArgs = ApiApiFetchParamCreator(
7014+
configuration,
7015+
).forkCollection(tenant, database, collectionId, request, options);
7016+
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
7017+
return fetch(
7018+
basePath + localVarFetchArgs.url,
7019+
localVarFetchArgs.options,
7020+
).then((response) => {
7021+
const contentType = response.headers.get("Content-Type");
7022+
const mimeType = contentType
7023+
? contentType.replace(/;.*/, "")
7024+
: undefined;
7025+
7026+
if (response.status === 200) {
7027+
if (mimeType === "application/json") {
7028+
return response.json() as any;
7029+
}
7030+
throw response;
7031+
}
7032+
if (response.status === 401) {
7033+
if (mimeType === "application/json") {
7034+
throw response;
7035+
}
7036+
throw response;
7037+
}
7038+
if (response.status === 404) {
7039+
if (mimeType === "application/json") {
7040+
throw response;
7041+
}
7042+
throw response;
7043+
}
7044+
if (response.status === 500) {
7045+
if (mimeType === "application/json") {
7046+
throw response;
7047+
}
7048+
throw response;
7049+
}
7050+
throw response;
7051+
});
7052+
};
7053+
},
69147054
/**
69157055
* @summary Retrieves a collection by ID or name.
69167056
* @param {string} tenant <p>Tenant ID</p>
@@ -8588,6 +8728,31 @@ export class ApiApi extends BaseAPI {
85888728
)(this.fetch, this.basePath);
85898729
}
85908730

8731+
/**
8732+
* @summary Forks an existing collection.
8733+
* @param {string} tenant <p>Tenant ID</p>
8734+
* @param {string} database <p>Database name</p>
8735+
* @param {string} collectionId <p>UUID of the collection to update</p>
8736+
* @param {Api.ForkCollectionPayload} request
8737+
* @param {RequestInit} [options] Override http request option.
8738+
* @throws {RequiredError}
8739+
*/
8740+
public forkCollection(
8741+
tenant: string,
8742+
database: string,
8743+
collectionId: string,
8744+
request: Api.ForkCollectionPayload,
8745+
options?: RequestInit,
8746+
) {
8747+
return ApiApiFp(this.configuration).forkCollection(
8748+
tenant,
8749+
database,
8750+
collectionId,
8751+
request,
8752+
options,
8753+
)(this.fetch, this.basePath);
8754+
}
8755+
85918756
/**
85928757
* @summary Retrieves a collection by ID or name.
85938758
* @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)