Skip to content

Commit ab90fcf

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

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
@@ -3478,6 +3478,89 @@ export const ApiApiFetchParamCreator = function (
34783478
options: localVarRequestOptions,
34793479
};
34803480
},
3481+
/**
3482+
* @summary Forks an existing collection.
3483+
* @param {string} tenant <p>Tenant ID</p>
3484+
* @param {string} database <p>Database name</p>
3485+
* @param {string} collectionId <p>UUID of the collection to update</p>
3486+
* @param {Api.ForkCollectionPayload} request
3487+
* @param {RequestInit} [options] Override http request option.
3488+
* @throws {RequiredError}
3489+
*/
3490+
forkCollection(
3491+
tenant: string,
3492+
database: string,
3493+
collectionId: string,
3494+
request: Api.ForkCollectionPayload,
3495+
options: RequestInit = {},
3496+
): FetchArgs {
3497+
// verify required parameter 'tenant' is not null or undefined
3498+
if (tenant === null || tenant === undefined) {
3499+
throw new RequiredError(
3500+
"tenant",
3501+
"Required parameter tenant was null or undefined when calling forkCollection.",
3502+
);
3503+
}
3504+
// verify required parameter 'database' is not null or undefined
3505+
if (database === null || database === undefined) {
3506+
throw new RequiredError(
3507+
"database",
3508+
"Required parameter database was null or undefined when calling forkCollection.",
3509+
);
3510+
}
3511+
// verify required parameter 'collectionId' is not null or undefined
3512+
if (collectionId === null || collectionId === undefined) {
3513+
throw new RequiredError(
3514+
"collectionId",
3515+
"Required parameter collectionId was null or undefined when calling forkCollection.",
3516+
);
3517+
}
3518+
// verify required parameter 'request' is not null or undefined
3519+
if (request === null || request === undefined) {
3520+
throw new RequiredError(
3521+
"request",
3522+
"Required parameter request was null or undefined when calling forkCollection.",
3523+
);
3524+
}
3525+
let localVarPath =
3526+
`/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`
3527+
.replace("{tenant}", encodeURIComponent(String(tenant)))
3528+
.replace("{database}", encodeURIComponent(String(database)))
3529+
.replace("{collection_id}", encodeURIComponent(String(collectionId)));
3530+
const localVarPathQueryStart = localVarPath.indexOf("?");
3531+
const localVarRequestOptions: RequestInit = Object.assign(
3532+
{ method: "POST" },
3533+
options,
3534+
);
3535+
const localVarHeaderParameter: Headers = options.headers
3536+
? new Headers(options.headers)
3537+
: new Headers();
3538+
const localVarQueryParameter = new URLSearchParams(
3539+
localVarPathQueryStart !== -1
3540+
? localVarPath.substring(localVarPathQueryStart + 1)
3541+
: "",
3542+
);
3543+
if (localVarPathQueryStart !== -1) {
3544+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
3545+
}
3546+
3547+
localVarHeaderParameter.set("Content-Type", "application/json");
3548+
3549+
localVarRequestOptions.headers = localVarHeaderParameter;
3550+
3551+
if (request !== undefined) {
3552+
localVarRequestOptions.body = JSON.stringify(request || {});
3553+
}
3554+
3555+
const localVarQueryParameterString = localVarQueryParameter.toString();
3556+
if (localVarQueryParameterString) {
3557+
localVarPath += "?" + localVarQueryParameterString;
3558+
}
3559+
return {
3560+
url: localVarPath,
3561+
options: localVarRequestOptions,
3562+
};
3563+
},
34813564
/**
34823565
* @summary Retrieves a collection by ID or name.
34833566
* @param {string} tenant <p>Tenant ID</p>
@@ -6491,6 +6574,63 @@ export const ApiApiFp = function (configuration?: Configuration) {
64916574
});
64926575
};
64936576
},
6577+
/**
6578+
* @summary Forks an existing collection.
6579+
* @param {string} tenant <p>Tenant ID</p>
6580+
* @param {string} database <p>Database name</p>
6581+
* @param {string} collectionId <p>UUID of the collection to update</p>
6582+
* @param {Api.ForkCollectionPayload} request
6583+
* @param {RequestInit} [options] Override http request option.
6584+
* @throws {RequiredError}
6585+
*/
6586+
forkCollection(
6587+
tenant: string,
6588+
database: string,
6589+
collectionId: string,
6590+
request: Api.ForkCollectionPayload,
6591+
options?: RequestInit,
6592+
): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Collection> {
6593+
const localVarFetchArgs = ApiApiFetchParamCreator(
6594+
configuration,
6595+
).forkCollection(tenant, database, collectionId, request, options);
6596+
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
6597+
return fetch(
6598+
basePath + localVarFetchArgs.url,
6599+
localVarFetchArgs.options,
6600+
).then((response) => {
6601+
const contentType = response.headers.get("Content-Type");
6602+
const mimeType = contentType
6603+
? contentType.replace(/;.*/, "")
6604+
: undefined;
6605+
6606+
if (response.status === 200) {
6607+
if (mimeType === "application/json") {
6608+
return response.json() as any;
6609+
}
6610+
throw response;
6611+
}
6612+
if (response.status === 401) {
6613+
if (mimeType === "application/json") {
6614+
throw response;
6615+
}
6616+
throw response;
6617+
}
6618+
if (response.status === 404) {
6619+
if (mimeType === "application/json") {
6620+
throw response;
6621+
}
6622+
throw response;
6623+
}
6624+
if (response.status === 500) {
6625+
if (mimeType === "application/json") {
6626+
throw response;
6627+
}
6628+
throw response;
6629+
}
6630+
throw response;
6631+
});
6632+
};
6633+
},
64946634
/**
64956635
* @summary Retrieves a collection by ID or name.
64966636
* @param {string} tenant <p>Tenant ID</p>
@@ -8093,6 +8233,31 @@ export class ApiApi extends BaseAPI {
80938233
)(this.fetch, this.basePath);
80948234
}
80958235

8236+
/**
8237+
* @summary Forks an existing collection.
8238+
* @param {string} tenant <p>Tenant ID</p>
8239+
* @param {string} database <p>Database name</p>
8240+
* @param {string} collectionId <p>UUID of the collection to update</p>
8241+
* @param {Api.ForkCollectionPayload} request
8242+
* @param {RequestInit} [options] Override http request option.
8243+
* @throws {RequiredError}
8244+
*/
8245+
public forkCollection(
8246+
tenant: string,
8247+
database: string,
8248+
collectionId: string,
8249+
request: Api.ForkCollectionPayload,
8250+
options?: RequestInit,
8251+
) {
8252+
return ApiApiFp(this.configuration).forkCollection(
8253+
tenant,
8254+
database,
8255+
collectionId,
8256+
request,
8257+
options,
8258+
)(this.fetch, this.basePath);
8259+
}
8260+
80968261
/**
80978262
* @summary Retrieves a collection by ID or name.
80988263
* @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)