Skip to content

Commit 2ffdbf1

Browse files
[ENH] add collection forking to js client (chroma-core#4372)
1 parent 8a85dc1 commit 2ffdbf1

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
@@ -2980,6 +2980,89 @@ export const ApiApiFetchParamCreator = function (
29802980
options: localVarRequestOptions,
29812981
};
29822982
},
2983+
/**
2984+
* @summary Forks an existing collection.
2985+
* @param {string} tenant <p>Tenant ID</p>
2986+
* @param {string} database <p>Database name</p>
2987+
* @param {string} collectionId <p>UUID of the collection to update</p>
2988+
* @param {Api.ForkCollectionPayload} request
2989+
* @param {RequestInit} [options] Override http request option.
2990+
* @throws {RequiredError}
2991+
*/
2992+
forkCollection(
2993+
tenant: string,
2994+
database: string,
2995+
collectionId: string,
2996+
request: Api.ForkCollectionPayload,
2997+
options: RequestInit = {},
2998+
): FetchArgs {
2999+
// verify required parameter 'tenant' is not null or undefined
3000+
if (tenant === null || tenant === undefined) {
3001+
throw new RequiredError(
3002+
"tenant",
3003+
"Required parameter tenant was null or undefined when calling forkCollection.",
3004+
);
3005+
}
3006+
// verify required parameter 'database' is not null or undefined
3007+
if (database === null || database === undefined) {
3008+
throw new RequiredError(
3009+
"database",
3010+
"Required parameter database was null or undefined when calling forkCollection.",
3011+
);
3012+
}
3013+
// verify required parameter 'collectionId' is not null or undefined
3014+
if (collectionId === null || collectionId === undefined) {
3015+
throw new RequiredError(
3016+
"collectionId",
3017+
"Required parameter collectionId was null or undefined when calling forkCollection.",
3018+
);
3019+
}
3020+
// verify required parameter 'request' is not null or undefined
3021+
if (request === null || request === undefined) {
3022+
throw new RequiredError(
3023+
"request",
3024+
"Required parameter request was null or undefined when calling forkCollection.",
3025+
);
3026+
}
3027+
let localVarPath =
3028+
`/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`
3029+
.replace("{tenant}", encodeURIComponent(String(tenant)))
3030+
.replace("{database}", encodeURIComponent(String(database)))
3031+
.replace("{collection_id}", encodeURIComponent(String(collectionId)));
3032+
const localVarPathQueryStart = localVarPath.indexOf("?");
3033+
const localVarRequestOptions: RequestInit = Object.assign(
3034+
{ method: "POST" },
3035+
options,
3036+
);
3037+
const localVarHeaderParameter: Headers = options.headers
3038+
? new Headers(options.headers)
3039+
: new Headers();
3040+
const localVarQueryParameter = new URLSearchParams(
3041+
localVarPathQueryStart !== -1
3042+
? localVarPath.substring(localVarPathQueryStart + 1)
3043+
: "",
3044+
);
3045+
if (localVarPathQueryStart !== -1) {
3046+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
3047+
}
3048+
3049+
localVarHeaderParameter.set("Content-Type", "application/json");
3050+
3051+
localVarRequestOptions.headers = localVarHeaderParameter;
3052+
3053+
if (request !== undefined) {
3054+
localVarRequestOptions.body = JSON.stringify(request || {});
3055+
}
3056+
3057+
const localVarQueryParameterString = localVarQueryParameter.toString();
3058+
if (localVarQueryParameterString) {
3059+
localVarPath += "?" + localVarQueryParameterString;
3060+
}
3061+
return {
3062+
url: localVarPath,
3063+
options: localVarRequestOptions,
3064+
};
3065+
},
29833066
/**
29843067
* @summary Retrieves a collection by ID or name.
29853068
* @param {string} tenant <p>Tenant ID</p>
@@ -5651,6 +5734,63 @@ export const ApiApiFp = function (configuration?: Configuration) {
56515734
});
56525735
};
56535736
},
5737+
/**
5738+
* @summary Forks an existing collection.
5739+
* @param {string} tenant <p>Tenant ID</p>
5740+
* @param {string} database <p>Database name</p>
5741+
* @param {string} collectionId <p>UUID of the collection to update</p>
5742+
* @param {Api.ForkCollectionPayload} request
5743+
* @param {RequestInit} [options] Override http request option.
5744+
* @throws {RequiredError}
5745+
*/
5746+
forkCollection(
5747+
tenant: string,
5748+
database: string,
5749+
collectionId: string,
5750+
request: Api.ForkCollectionPayload,
5751+
options?: RequestInit,
5752+
): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Collection> {
5753+
const localVarFetchArgs = ApiApiFetchParamCreator(
5754+
configuration,
5755+
).forkCollection(tenant, database, collectionId, request, options);
5756+
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
5757+
return fetch(
5758+
basePath + localVarFetchArgs.url,
5759+
localVarFetchArgs.options,
5760+
).then((response) => {
5761+
const contentType = response.headers.get("Content-Type");
5762+
const mimeType = contentType
5763+
? contentType.replace(/;.*/, "")
5764+
: undefined;
5765+
5766+
if (response.status === 200) {
5767+
if (mimeType === "application/json") {
5768+
return response.json() as any;
5769+
}
5770+
throw response;
5771+
}
5772+
if (response.status === 401) {
5773+
if (mimeType === "application/json") {
5774+
throw response;
5775+
}
5776+
throw response;
5777+
}
5778+
if (response.status === 404) {
5779+
if (mimeType === "application/json") {
5780+
throw response;
5781+
}
5782+
throw response;
5783+
}
5784+
if (response.status === 500) {
5785+
if (mimeType === "application/json") {
5786+
throw response;
5787+
}
5788+
throw response;
5789+
}
5790+
throw response;
5791+
});
5792+
};
5793+
},
56545794
/**
56555795
* @summary Retrieves a collection by ID or name.
56565796
* @param {string} tenant <p>Tenant ID</p>
@@ -7103,6 +7243,31 @@ export class ApiApi extends BaseAPI {
71037243
)(this.fetch, this.basePath);
71047244
}
71057245

7246+
/**
7247+
* @summary Forks an existing collection.
7248+
* @param {string} tenant <p>Tenant ID</p>
7249+
* @param {string} database <p>Database name</p>
7250+
* @param {string} collectionId <p>UUID of the collection to update</p>
7251+
* @param {Api.ForkCollectionPayload} request
7252+
* @param {RequestInit} [options] Override http request option.
7253+
* @throws {RequiredError}
7254+
*/
7255+
public forkCollection(
7256+
tenant: string,
7257+
database: string,
7258+
collectionId: string,
7259+
request: Api.ForkCollectionPayload,
7260+
options?: RequestInit,
7261+
) {
7262+
return ApiApiFp(this.configuration).forkCollection(
7263+
tenant,
7264+
database,
7265+
collectionId,
7266+
request,
7267+
options,
7268+
)(this.fetch, this.basePath);
7269+
}
7270+
71067271
/**
71077272
* @summary Retrieves a collection by ID or name.
71087273
* @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)