Skip to content

Commit 15ef03a

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

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
@@ -4308,6 +4308,89 @@ export const ApiApiFetchParamCreator = function (
43084308
options: localVarRequestOptions,
43094309
};
43104310
},
4311+
/**
4312+
* @summary Forks an existing collection.
4313+
* @param {string} tenant <p>Tenant ID</p>
4314+
* @param {string} database <p>Database name</p>
4315+
* @param {string} collectionId <p>UUID of the collection to update</p>
4316+
* @param {Api.ForkCollectionPayload} request
4317+
* @param {RequestInit} [options] Override http request option.
4318+
* @throws {RequiredError}
4319+
*/
4320+
forkCollection(
4321+
tenant: string,
4322+
database: string,
4323+
collectionId: string,
4324+
request: Api.ForkCollectionPayload,
4325+
options: RequestInit = {},
4326+
): FetchArgs {
4327+
// verify required parameter 'tenant' is not null or undefined
4328+
if (tenant === null || tenant === undefined) {
4329+
throw new RequiredError(
4330+
"tenant",
4331+
"Required parameter tenant was null or undefined when calling forkCollection.",
4332+
);
4333+
}
4334+
// verify required parameter 'database' is not null or undefined
4335+
if (database === null || database === undefined) {
4336+
throw new RequiredError(
4337+
"database",
4338+
"Required parameter database was null or undefined when calling forkCollection.",
4339+
);
4340+
}
4341+
// verify required parameter 'collectionId' is not null or undefined
4342+
if (collectionId === null || collectionId === undefined) {
4343+
throw new RequiredError(
4344+
"collectionId",
4345+
"Required parameter collectionId was null or undefined when calling forkCollection.",
4346+
);
4347+
}
4348+
// verify required parameter 'request' is not null or undefined
4349+
if (request === null || request === undefined) {
4350+
throw new RequiredError(
4351+
"request",
4352+
"Required parameter request was null or undefined when calling forkCollection.",
4353+
);
4354+
}
4355+
let localVarPath =
4356+
`/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`
4357+
.replace("{tenant}", encodeURIComponent(String(tenant)))
4358+
.replace("{database}", encodeURIComponent(String(database)))
4359+
.replace("{collection_id}", encodeURIComponent(String(collectionId)));
4360+
const localVarPathQueryStart = localVarPath.indexOf("?");
4361+
const localVarRequestOptions: RequestInit = Object.assign(
4362+
{ method: "POST" },
4363+
options,
4364+
);
4365+
const localVarHeaderParameter: Headers = options.headers
4366+
? new Headers(options.headers)
4367+
: new Headers();
4368+
const localVarQueryParameter = new URLSearchParams(
4369+
localVarPathQueryStart !== -1
4370+
? localVarPath.substring(localVarPathQueryStart + 1)
4371+
: "",
4372+
);
4373+
if (localVarPathQueryStart !== -1) {
4374+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
4375+
}
4376+
4377+
localVarHeaderParameter.set("Content-Type", "application/json");
4378+
4379+
localVarRequestOptions.headers = localVarHeaderParameter;
4380+
4381+
if (request !== undefined) {
4382+
localVarRequestOptions.body = JSON.stringify(request || {});
4383+
}
4384+
4385+
const localVarQueryParameterString = localVarQueryParameter.toString();
4386+
if (localVarQueryParameterString) {
4387+
localVarPath += "?" + localVarQueryParameterString;
4388+
}
4389+
return {
4390+
url: localVarPath,
4391+
options: localVarRequestOptions,
4392+
};
4393+
},
43114394
/**
43124395
* @summary Retrieves a collection by ID or name.
43134396
* @param {string} tenant <p>Tenant ID</p>
@@ -7891,6 +7974,63 @@ export const ApiApiFp = function (configuration?: Configuration) {
78917974
});
78927975
};
78937976
},
7977+
/**
7978+
* @summary Forks an existing collection.
7979+
* @param {string} tenant <p>Tenant ID</p>
7980+
* @param {string} database <p>Database name</p>
7981+
* @param {string} collectionId <p>UUID of the collection to update</p>
7982+
* @param {Api.ForkCollectionPayload} request
7983+
* @param {RequestInit} [options] Override http request option.
7984+
* @throws {RequiredError}
7985+
*/
7986+
forkCollection(
7987+
tenant: string,
7988+
database: string,
7989+
collectionId: string,
7990+
request: Api.ForkCollectionPayload,
7991+
options?: RequestInit,
7992+
): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Collection> {
7993+
const localVarFetchArgs = ApiApiFetchParamCreator(
7994+
configuration,
7995+
).forkCollection(tenant, database, collectionId, request, options);
7996+
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
7997+
return fetch(
7998+
basePath + localVarFetchArgs.url,
7999+
localVarFetchArgs.options,
8000+
).then((response) => {
8001+
const contentType = response.headers.get("Content-Type");
8002+
const mimeType = contentType
8003+
? contentType.replace(/;.*/, "")
8004+
: undefined;
8005+
8006+
if (response.status === 200) {
8007+
if (mimeType === "application/json") {
8008+
return response.json() as any;
8009+
}
8010+
throw response;
8011+
}
8012+
if (response.status === 401) {
8013+
if (mimeType === "application/json") {
8014+
throw response;
8015+
}
8016+
throw response;
8017+
}
8018+
if (response.status === 404) {
8019+
if (mimeType === "application/json") {
8020+
throw response;
8021+
}
8022+
throw response;
8023+
}
8024+
if (response.status === 500) {
8025+
if (mimeType === "application/json") {
8026+
throw response;
8027+
}
8028+
throw response;
8029+
}
8030+
throw response;
8031+
});
8032+
};
8033+
},
78948034
/**
78958035
* @summary Retrieves a collection by ID or name.
78968036
* @param {string} tenant <p>Tenant ID</p>
@@ -9743,6 +9883,31 @@ export class ApiApi extends BaseAPI {
97439883
)(this.fetch, this.basePath);
97449884
}
97459885

9886+
/**
9887+
* @summary Forks an existing collection.
9888+
* @param {string} tenant <p>Tenant ID</p>
9889+
* @param {string} database <p>Database name</p>
9890+
* @param {string} collectionId <p>UUID of the collection to update</p>
9891+
* @param {Api.ForkCollectionPayload} request
9892+
* @param {RequestInit} [options] Override http request option.
9893+
* @throws {RequiredError}
9894+
*/
9895+
public forkCollection(
9896+
tenant: string,
9897+
database: string,
9898+
collectionId: string,
9899+
request: Api.ForkCollectionPayload,
9900+
options?: RequestInit,
9901+
) {
9902+
return ApiApiFp(this.configuration).forkCollection(
9903+
tenant,
9904+
database,
9905+
collectionId,
9906+
request,
9907+
options,
9908+
)(this.fetch, this.basePath);
9909+
}
9910+
97469911
/**
97479912
* @summary Retrieves a collection by ID or name.
97489913
* @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)