Skip to content

Commit cc93569

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

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
@@ -2648,6 +2648,89 @@ export const ApiApiFetchParamCreator = function (
26482648
options: localVarRequestOptions,
26492649
};
26502650
},
2651+
/**
2652+
* @summary Forks an existing collection.
2653+
* @param {string} tenant <p>Tenant ID</p>
2654+
* @param {string} database <p>Database name</p>
2655+
* @param {string} collectionId <p>UUID of the collection to update</p>
2656+
* @param {Api.ForkCollectionPayload} request
2657+
* @param {RequestInit} [options] Override http request option.
2658+
* @throws {RequiredError}
2659+
*/
2660+
forkCollection(
2661+
tenant: string,
2662+
database: string,
2663+
collectionId: string,
2664+
request: Api.ForkCollectionPayload,
2665+
options: RequestInit = {},
2666+
): FetchArgs {
2667+
// verify required parameter 'tenant' is not null or undefined
2668+
if (tenant === null || tenant === undefined) {
2669+
throw new RequiredError(
2670+
"tenant",
2671+
"Required parameter tenant was null or undefined when calling forkCollection.",
2672+
);
2673+
}
2674+
// verify required parameter 'database' is not null or undefined
2675+
if (database === null || database === undefined) {
2676+
throw new RequiredError(
2677+
"database",
2678+
"Required parameter database was null or undefined when calling forkCollection.",
2679+
);
2680+
}
2681+
// verify required parameter 'collectionId' is not null or undefined
2682+
if (collectionId === null || collectionId === undefined) {
2683+
throw new RequiredError(
2684+
"collectionId",
2685+
"Required parameter collectionId was null or undefined when calling forkCollection.",
2686+
);
2687+
}
2688+
// verify required parameter 'request' is not null or undefined
2689+
if (request === null || request === undefined) {
2690+
throw new RequiredError(
2691+
"request",
2692+
"Required parameter request was null or undefined when calling forkCollection.",
2693+
);
2694+
}
2695+
let localVarPath =
2696+
`/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`
2697+
.replace("{tenant}", encodeURIComponent(String(tenant)))
2698+
.replace("{database}", encodeURIComponent(String(database)))
2699+
.replace("{collection_id}", encodeURIComponent(String(collectionId)));
2700+
const localVarPathQueryStart = localVarPath.indexOf("?");
2701+
const localVarRequestOptions: RequestInit = Object.assign(
2702+
{ method: "POST" },
2703+
options,
2704+
);
2705+
const localVarHeaderParameter: Headers = options.headers
2706+
? new Headers(options.headers)
2707+
: new Headers();
2708+
const localVarQueryParameter = new URLSearchParams(
2709+
localVarPathQueryStart !== -1
2710+
? localVarPath.substring(localVarPathQueryStart + 1)
2711+
: "",
2712+
);
2713+
if (localVarPathQueryStart !== -1) {
2714+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
2715+
}
2716+
2717+
localVarHeaderParameter.set("Content-Type", "application/json");
2718+
2719+
localVarRequestOptions.headers = localVarHeaderParameter;
2720+
2721+
if (request !== undefined) {
2722+
localVarRequestOptions.body = JSON.stringify(request || {});
2723+
}
2724+
2725+
const localVarQueryParameterString = localVarQueryParameter.toString();
2726+
if (localVarQueryParameterString) {
2727+
localVarPath += "?" + localVarQueryParameterString;
2728+
}
2729+
return {
2730+
url: localVarPath,
2731+
options: localVarRequestOptions,
2732+
};
2733+
},
26512734
/**
26522735
* @summary Retrieves a collection by ID or name.
26532736
* @param {string} tenant <p>Tenant ID</p>
@@ -5091,6 +5174,63 @@ export const ApiApiFp = function (configuration?: Configuration) {
50915174
});
50925175
};
50935176
},
5177+
/**
5178+
* @summary Forks an existing collection.
5179+
* @param {string} tenant <p>Tenant ID</p>
5180+
* @param {string} database <p>Database name</p>
5181+
* @param {string} collectionId <p>UUID of the collection to update</p>
5182+
* @param {Api.ForkCollectionPayload} request
5183+
* @param {RequestInit} [options] Override http request option.
5184+
* @throws {RequiredError}
5185+
*/
5186+
forkCollection(
5187+
tenant: string,
5188+
database: string,
5189+
collectionId: string,
5190+
request: Api.ForkCollectionPayload,
5191+
options?: RequestInit,
5192+
): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Collection> {
5193+
const localVarFetchArgs = ApiApiFetchParamCreator(
5194+
configuration,
5195+
).forkCollection(tenant, database, collectionId, request, options);
5196+
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
5197+
return fetch(
5198+
basePath + localVarFetchArgs.url,
5199+
localVarFetchArgs.options,
5200+
).then((response) => {
5201+
const contentType = response.headers.get("Content-Type");
5202+
const mimeType = contentType
5203+
? contentType.replace(/;.*/, "")
5204+
: undefined;
5205+
5206+
if (response.status === 200) {
5207+
if (mimeType === "application/json") {
5208+
return response.json() as any;
5209+
}
5210+
throw response;
5211+
}
5212+
if (response.status === 401) {
5213+
if (mimeType === "application/json") {
5214+
throw response;
5215+
}
5216+
throw response;
5217+
}
5218+
if (response.status === 404) {
5219+
if (mimeType === "application/json") {
5220+
throw response;
5221+
}
5222+
throw response;
5223+
}
5224+
if (response.status === 500) {
5225+
if (mimeType === "application/json") {
5226+
throw response;
5227+
}
5228+
throw response;
5229+
}
5230+
throw response;
5231+
});
5232+
};
5233+
},
50945234
/**
50955235
* @summary Retrieves a collection by ID or name.
50965236
* @param {string} tenant <p>Tenant ID</p>
@@ -6443,6 +6583,31 @@ export class ApiApi extends BaseAPI {
64436583
)(this.fetch, this.basePath);
64446584
}
64456585

6586+
/**
6587+
* @summary Forks an existing collection.
6588+
* @param {string} tenant <p>Tenant ID</p>
6589+
* @param {string} database <p>Database name</p>
6590+
* @param {string} collectionId <p>UUID of the collection to update</p>
6591+
* @param {Api.ForkCollectionPayload} request
6592+
* @param {RequestInit} [options] Override http request option.
6593+
* @throws {RequiredError}
6594+
*/
6595+
public forkCollection(
6596+
tenant: string,
6597+
database: string,
6598+
collectionId: string,
6599+
request: Api.ForkCollectionPayload,
6600+
options?: RequestInit,
6601+
) {
6602+
return ApiApiFp(this.configuration).forkCollection(
6603+
tenant,
6604+
database,
6605+
collectionId,
6606+
request,
6607+
options,
6608+
)(this.fetch, this.basePath);
6609+
}
6610+
64466611
/**
64476612
* @summary Retrieves a collection by ID or name.
64486613
* @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)