Skip to content

Commit fcc4206

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

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
@@ -2731,6 +2731,89 @@ export const ApiApiFetchParamCreator = function (
27312731
options: localVarRequestOptions,
27322732
};
27332733
},
2734+
/**
2735+
* @summary Forks an existing collection.
2736+
* @param {string} tenant <p>Tenant ID</p>
2737+
* @param {string} database <p>Database name</p>
2738+
* @param {string} collectionId <p>UUID of the collection to update</p>
2739+
* @param {Api.ForkCollectionPayload} request
2740+
* @param {RequestInit} [options] Override http request option.
2741+
* @throws {RequiredError}
2742+
*/
2743+
forkCollection(
2744+
tenant: string,
2745+
database: string,
2746+
collectionId: string,
2747+
request: Api.ForkCollectionPayload,
2748+
options: RequestInit = {},
2749+
): FetchArgs {
2750+
// verify required parameter 'tenant' is not null or undefined
2751+
if (tenant === null || tenant === undefined) {
2752+
throw new RequiredError(
2753+
"tenant",
2754+
"Required parameter tenant was null or undefined when calling forkCollection.",
2755+
);
2756+
}
2757+
// verify required parameter 'database' is not null or undefined
2758+
if (database === null || database === undefined) {
2759+
throw new RequiredError(
2760+
"database",
2761+
"Required parameter database was null or undefined when calling forkCollection.",
2762+
);
2763+
}
2764+
// verify required parameter 'collectionId' is not null or undefined
2765+
if (collectionId === null || collectionId === undefined) {
2766+
throw new RequiredError(
2767+
"collectionId",
2768+
"Required parameter collectionId was null or undefined when calling forkCollection.",
2769+
);
2770+
}
2771+
// verify required parameter 'request' is not null or undefined
2772+
if (request === null || request === undefined) {
2773+
throw new RequiredError(
2774+
"request",
2775+
"Required parameter request was null or undefined when calling forkCollection.",
2776+
);
2777+
}
2778+
let localVarPath =
2779+
`/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`
2780+
.replace("{tenant}", encodeURIComponent(String(tenant)))
2781+
.replace("{database}", encodeURIComponent(String(database)))
2782+
.replace("{collection_id}", encodeURIComponent(String(collectionId)));
2783+
const localVarPathQueryStart = localVarPath.indexOf("?");
2784+
const localVarRequestOptions: RequestInit = Object.assign(
2785+
{ method: "POST" },
2786+
options,
2787+
);
2788+
const localVarHeaderParameter: Headers = options.headers
2789+
? new Headers(options.headers)
2790+
: new Headers();
2791+
const localVarQueryParameter = new URLSearchParams(
2792+
localVarPathQueryStart !== -1
2793+
? localVarPath.substring(localVarPathQueryStart + 1)
2794+
: "",
2795+
);
2796+
if (localVarPathQueryStart !== -1) {
2797+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
2798+
}
2799+
2800+
localVarHeaderParameter.set("Content-Type", "application/json");
2801+
2802+
localVarRequestOptions.headers = localVarHeaderParameter;
2803+
2804+
if (request !== undefined) {
2805+
localVarRequestOptions.body = JSON.stringify(request || {});
2806+
}
2807+
2808+
const localVarQueryParameterString = localVarQueryParameter.toString();
2809+
if (localVarQueryParameterString) {
2810+
localVarPath += "?" + localVarQueryParameterString;
2811+
}
2812+
return {
2813+
url: localVarPath,
2814+
options: localVarRequestOptions,
2815+
};
2816+
},
27342817
/**
27352818
* @summary Retrieves a collection by ID or name.
27362819
* @param {string} tenant <p>Tenant ID</p>
@@ -5231,6 +5314,63 @@ export const ApiApiFp = function (configuration?: Configuration) {
52315314
});
52325315
};
52335316
},
5317+
/**
5318+
* @summary Forks an existing collection.
5319+
* @param {string} tenant <p>Tenant ID</p>
5320+
* @param {string} database <p>Database name</p>
5321+
* @param {string} collectionId <p>UUID of the collection to update</p>
5322+
* @param {Api.ForkCollectionPayload} request
5323+
* @param {RequestInit} [options] Override http request option.
5324+
* @throws {RequiredError}
5325+
*/
5326+
forkCollection(
5327+
tenant: string,
5328+
database: string,
5329+
collectionId: string,
5330+
request: Api.ForkCollectionPayload,
5331+
options?: RequestInit,
5332+
): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Collection> {
5333+
const localVarFetchArgs = ApiApiFetchParamCreator(
5334+
configuration,
5335+
).forkCollection(tenant, database, collectionId, request, options);
5336+
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
5337+
return fetch(
5338+
basePath + localVarFetchArgs.url,
5339+
localVarFetchArgs.options,
5340+
).then((response) => {
5341+
const contentType = response.headers.get("Content-Type");
5342+
const mimeType = contentType
5343+
? contentType.replace(/;.*/, "")
5344+
: undefined;
5345+
5346+
if (response.status === 200) {
5347+
if (mimeType === "application/json") {
5348+
return response.json() as any;
5349+
}
5350+
throw response;
5351+
}
5352+
if (response.status === 401) {
5353+
if (mimeType === "application/json") {
5354+
throw response;
5355+
}
5356+
throw response;
5357+
}
5358+
if (response.status === 404) {
5359+
if (mimeType === "application/json") {
5360+
throw response;
5361+
}
5362+
throw response;
5363+
}
5364+
if (response.status === 500) {
5365+
if (mimeType === "application/json") {
5366+
throw response;
5367+
}
5368+
throw response;
5369+
}
5370+
throw response;
5371+
});
5372+
};
5373+
},
52345374
/**
52355375
* @summary Retrieves a collection by ID or name.
52365376
* @param {string} tenant <p>Tenant ID</p>
@@ -6608,6 +6748,31 @@ export class ApiApi extends BaseAPI {
66086748
)(this.fetch, this.basePath);
66096749
}
66106750

6751+
/**
6752+
* @summary Forks an existing collection.
6753+
* @param {string} tenant <p>Tenant ID</p>
6754+
* @param {string} database <p>Database name</p>
6755+
* @param {string} collectionId <p>UUID of the collection to update</p>
6756+
* @param {Api.ForkCollectionPayload} request
6757+
* @param {RequestInit} [options] Override http request option.
6758+
* @throws {RequiredError}
6759+
*/
6760+
public forkCollection(
6761+
tenant: string,
6762+
database: string,
6763+
collectionId: string,
6764+
request: Api.ForkCollectionPayload,
6765+
options?: RequestInit,
6766+
) {
6767+
return ApiApiFp(this.configuration).forkCollection(
6768+
tenant,
6769+
database,
6770+
collectionId,
6771+
request,
6772+
options,
6773+
)(this.fetch, this.basePath);
6774+
}
6775+
66116776
/**
66126777
* @summary Retrieves a collection by ID or name.
66136778
* @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)