Comparing version 1.3.1 to 1.4.0
@@ -106,2 +106,9 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat: (options?: AxiosRequestConfig) => Promise<RequestArgs>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -159,2 +166,9 @@ * @param {*} [options] Override http request option. | ||
updateCollection: (collectionName: any, updateCollection: UpdateCollection, options?: AxiosRequestConfig) => Promise<RequestArgs>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version: (options?: AxiosRequestConfig) => Promise<RequestArgs>; | ||
}; | ||
@@ -244,2 +258,9 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -297,2 +318,9 @@ * @param {*} [options] Override http request option. | ||
updateCollection(collectionName: any, updateCollection: UpdateCollection, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>>; | ||
}; | ||
@@ -382,2 +410,9 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat(options?: any): AxiosPromise<any>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -435,2 +470,9 @@ * @param {*} [options] Override http request option. | ||
updateCollection(collectionName: any, updateCollection: UpdateCollection, options?: any): AxiosPromise<any>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version(options?: any): AxiosPromise<any>; | ||
}; | ||
@@ -719,2 +761,10 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
heartbeat(options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -777,3 +827,11 @@ * @param {*} [options] Override http request option. | ||
updateCollection(requestParameters: DefaultApiUpdateCollectionRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
version(options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>; | ||
} | ||
//# sourceMappingURL=default-api.d.ts.map |
@@ -316,2 +316,27 @@ "use strict"; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat: async (options = {}) => { | ||
const localVarPath = `/api/v1/heartbeat`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); | ||
const localVarHeaderParameter = {}; | ||
const localVarQueryParameter = {}; | ||
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); | ||
return { | ||
url: (0, common_1.toPathString)(localVarUrlObj), | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -513,2 +538,27 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version: async (options = {}) => { | ||
const localVarPath = `/api/v1/version`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); | ||
const localVarHeaderParameter = {}; | ||
const localVarQueryParameter = {}; | ||
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); | ||
return { | ||
url: (0, common_1.toPathString)(localVarUrlObj), | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
}; | ||
@@ -629,2 +679,12 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async heartbeat(options) { | ||
const localVarAxiosArgs = await localVarAxiosParamCreator.heartbeat(options); | ||
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -703,2 +763,12 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async version(options) { | ||
const localVarAxiosArgs = await localVarAxiosParamCreator.version(options); | ||
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); | ||
}, | ||
}; | ||
@@ -810,2 +880,11 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat(options) { | ||
return localVarFp.heartbeat(options).then((request) => request(axios, basePath)); | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -877,2 +956,11 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version(options) { | ||
return localVarFp.version(options).then((request) => request(axios, basePath)); | ||
}, | ||
}; | ||
@@ -989,2 +1077,12 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
heartbeat(options) { | ||
return (0, exports.DefaultApiFp)(this.configuration).heartbeat(options).then((request) => request(this.axios, this.basePath)); | ||
} | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -1061,4 +1159,14 @@ * @param {*} [options] Override http request option. | ||
} | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
version(options) { | ||
return (0, exports.DefaultApiFp)(this.configuration).version(options).then((request) => request(this.axios, this.basePath)); | ||
} | ||
} | ||
exports.DefaultApi = DefaultApi; | ||
//# sourceMappingURL=default-api.js.map |
@@ -0,1 +1,2 @@ | ||
import { GetEmbeddingIncludeEnum, QueryEmbeddingIncludeEnum } from "./generated"; | ||
import { DefaultApi } from "./generated/api"; | ||
@@ -24,4 +25,6 @@ export declare class OpenAIEmbeddingFunction { | ||
count(): Promise<any>; | ||
get(ids?: string[], where?: object, limit?: number, offset?: number): Promise<any>; | ||
query(query_embeddings: number[] | number[][] | undefined, n_results?: number, where?: object, query_text?: string | string[]): Promise<any>; | ||
get(ids?: string[], where?: object, limit?: number, offset?: number, include?: GetEmbeddingIncludeEnum[], where_document?: object): Promise<any>; | ||
update(ids: string | string[], embeddings?: number[] | number[][], metadatas?: object | object[], documents?: string | string[]): Promise<any>; | ||
query(query_embeddings: number[] | number[][] | undefined, n_results?: number, where?: object, query_text?: string | string[], where_document?: object, // {"$contains":"search_string"} | ||
include?: QueryEmbeddingIncludeEnum[]): Promise<any>; | ||
peek(limit?: number): Promise<any>; | ||
@@ -35,3 +38,6 @@ createIndex(): Promise<import("axios").AxiosResponse<any, any>>; | ||
reset(): Promise<import("axios").AxiosResponse<any, any>>; | ||
version(): Promise<any>; | ||
heartbeat(): Promise<any>; | ||
createCollection(name: string, metadata?: object, embeddingFunction?: CallableFunction): Promise<Collection>; | ||
getOrCreateCollection(name: string, metadata?: object, embeddingFunction?: CallableFunction): Promise<Collection>; | ||
listCollections(): Promise<any>; | ||
@@ -38,0 +44,0 @@ getCollection(name: string, embeddingFunction?: CallableFunction): Promise<Collection>; |
@@ -144,3 +144,3 @@ "use strict"; | ||
} | ||
async get(ids, where, limit, offset) { | ||
async get(ids, where, limit, offset, include, where_document) { | ||
let idsArray = undefined; | ||
@@ -156,2 +156,4 @@ if (ids !== undefined) | ||
offset, | ||
include, | ||
where_document, | ||
}, | ||
@@ -165,3 +167,32 @@ }).then(function (response) { | ||
} | ||
async query(query_embeddings, n_results = 10, where, query_text) { | ||
async update(ids, embeddings, metadatas, documents) { | ||
if ((embeddings === undefined) && (documents === undefined) && (metadatas === undefined)) { | ||
throw new Error("embeddings, documents, and metadatas cannot all be undefined"); | ||
} | ||
else if ((embeddings === undefined) && (documents !== undefined)) { | ||
const documentsArray = toArray(documents); | ||
if (this.embeddingFunction !== undefined) { | ||
embeddings = await this.embeddingFunction.generate(documentsArray); | ||
} | ||
else { | ||
throw new Error("embeddingFunction is undefined. Please configure an embedding function"); | ||
} | ||
} | ||
var resp = await this.api.update({ | ||
collectionName: this.name, | ||
updateEmbedding: { | ||
ids: toArray(ids), | ||
embeddings: (embeddings ? toArrayOfArrays(embeddings) : undefined), | ||
documents: toArray(documents), | ||
metadatas: toArray(metadatas), | ||
}, | ||
}).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
return resp; | ||
} | ||
async query(query_embeddings, n_results = 10, where, query_text, where_document, // {"$contains":"search_string"} | ||
include) { | ||
if ((query_embeddings === undefined) && (query_text === undefined)) { | ||
@@ -188,2 +219,4 @@ throw new Error("query_embeddings and query_text cannot both be undefined"); | ||
n_results, | ||
where_document: where_document, | ||
include: include | ||
}, | ||
@@ -232,2 +265,12 @@ }).then(function (response) { | ||
} | ||
// version | ||
async version() { | ||
const response = await this.api.version(); | ||
return response.data; | ||
} | ||
// heartbeat | ||
async heartbeat() { | ||
const response = await this.api.heartbeat(); | ||
return response.data["nanosecond heartbeat"]; | ||
} | ||
async createCollection(name, metadata, embeddingFunction) { | ||
@@ -246,2 +289,16 @@ const newCollection = await this.api.createCollection({ | ||
} | ||
// get or create collection | ||
async getOrCreateCollection(name, metadata, embeddingFunction) { | ||
const newCollection = await this.api.createCollection({ | ||
createCollection: { name, metadata, get_or_create: true }, | ||
}).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
if (newCollection.error) { | ||
throw new Error(newCollection.error); | ||
} | ||
return new Collection(name, this.api, embeddingFunction); | ||
} | ||
async listCollections() { | ||
@@ -248,0 +305,0 @@ const response = await this.api.listCollections(); |
@@ -106,2 +106,9 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat: (options?: AxiosRequestConfig) => Promise<RequestArgs>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -159,2 +166,9 @@ * @param {*} [options] Override http request option. | ||
updateCollection: (collectionName: any, updateCollection: UpdateCollection, options?: AxiosRequestConfig) => Promise<RequestArgs>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version: (options?: AxiosRequestConfig) => Promise<RequestArgs>; | ||
}; | ||
@@ -244,2 +258,9 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -297,2 +318,9 @@ * @param {*} [options] Override http request option. | ||
updateCollection(collectionName: any, updateCollection: UpdateCollection, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>>; | ||
}; | ||
@@ -382,2 +410,9 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat(options?: any): AxiosPromise<any>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -435,2 +470,9 @@ * @param {*} [options] Override http request option. | ||
updateCollection(collectionName: any, updateCollection: UpdateCollection, options?: any): AxiosPromise<any>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version(options?: any): AxiosPromise<any>; | ||
}; | ||
@@ -719,2 +761,10 @@ /** | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
heartbeat(options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>; | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -777,3 +827,11 @@ * @param {*} [options] Override http request option. | ||
updateCollection(requestParameters: DefaultApiUpdateCollectionRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>; | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
version(options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>; | ||
} | ||
//# sourceMappingURL=default-api.d.ts.map |
@@ -310,2 +310,27 @@ /* tslint:disable */ | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat: async (options = {}) => { | ||
const localVarPath = `/api/v1/heartbeat`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); | ||
const localVarHeaderParameter = {}; | ||
const localVarQueryParameter = {}; | ||
setSearchParams(localVarUrlObj, localVarQueryParameter); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); | ||
return { | ||
url: toPathString(localVarUrlObj), | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -507,2 +532,27 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version: async (options = {}) => { | ||
const localVarPath = `/api/v1/version`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); | ||
const localVarHeaderParameter = {}; | ||
const localVarQueryParameter = {}; | ||
setSearchParams(localVarUrlObj, localVarQueryParameter); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); | ||
return { | ||
url: toPathString(localVarUrlObj), | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
}; | ||
@@ -622,2 +672,12 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async heartbeat(options) { | ||
const localVarAxiosArgs = await localVarAxiosParamCreator.heartbeat(options); | ||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -696,2 +756,12 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async version(options) { | ||
const localVarAxiosArgs = await localVarAxiosParamCreator.version(options); | ||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); | ||
}, | ||
}; | ||
@@ -802,2 +872,11 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat(options) { | ||
return localVarFp.heartbeat(options).then((request) => request(axios, basePath)); | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -869,2 +948,11 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version(options) { | ||
return localVarFp.version(options).then((request) => request(axios, basePath)); | ||
}, | ||
}; | ||
@@ -980,2 +1068,12 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
heartbeat(options) { | ||
return DefaultApiFp(this.configuration).heartbeat(options).then((request) => request(this.axios, this.basePath)); | ||
} | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -1052,3 +1150,13 @@ * @param {*} [options] Override http request option. | ||
} | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
version(options) { | ||
return DefaultApiFp(this.configuration).version(options).then((request) => request(this.axios, this.basePath)); | ||
} | ||
} | ||
//# sourceMappingURL=default-api.js.map |
@@ -0,1 +1,2 @@ | ||
import { GetEmbeddingIncludeEnum, QueryEmbeddingIncludeEnum } from "./generated"; | ||
import { DefaultApi } from "./generated/api"; | ||
@@ -24,4 +25,6 @@ export declare class OpenAIEmbeddingFunction { | ||
count(): Promise<any>; | ||
get(ids?: string[], where?: object, limit?: number, offset?: number): Promise<any>; | ||
query(query_embeddings: number[] | number[][] | undefined, n_results?: number, where?: object, query_text?: string | string[]): Promise<any>; | ||
get(ids?: string[], where?: object, limit?: number, offset?: number, include?: GetEmbeddingIncludeEnum[], where_document?: object): Promise<any>; | ||
update(ids: string | string[], embeddings?: number[] | number[][], metadatas?: object | object[], documents?: string | string[]): Promise<any>; | ||
query(query_embeddings: number[] | number[][] | undefined, n_results?: number, where?: object, query_text?: string | string[], where_document?: object, // {"$contains":"search_string"} | ||
include?: QueryEmbeddingIncludeEnum[]): Promise<any>; | ||
peek(limit?: number): Promise<any>; | ||
@@ -35,3 +38,6 @@ createIndex(): Promise<import("axios").AxiosResponse<any, any>>; | ||
reset(): Promise<import("axios").AxiosResponse<any, any>>; | ||
version(): Promise<any>; | ||
heartbeat(): Promise<any>; | ||
createCollection(name: string, metadata?: object, embeddingFunction?: CallableFunction): Promise<Collection>; | ||
getOrCreateCollection(name: string, metadata?: object, embeddingFunction?: CallableFunction): Promise<Collection>; | ||
listCollections(): Promise<any>; | ||
@@ -38,0 +44,0 @@ getCollection(name: string, embeddingFunction?: CallableFunction): Promise<Collection>; |
@@ -139,3 +139,3 @@ import { DefaultApi } from "./generated/api"; | ||
} | ||
async get(ids, where, limit, offset) { | ||
async get(ids, where, limit, offset, include, where_document) { | ||
let idsArray = undefined; | ||
@@ -151,2 +151,4 @@ if (ids !== undefined) | ||
offset, | ||
include, | ||
where_document, | ||
}, | ||
@@ -160,3 +162,32 @@ }).then(function (response) { | ||
} | ||
async query(query_embeddings, n_results = 10, where, query_text) { | ||
async update(ids, embeddings, metadatas, documents) { | ||
if ((embeddings === undefined) && (documents === undefined) && (metadatas === undefined)) { | ||
throw new Error("embeddings, documents, and metadatas cannot all be undefined"); | ||
} | ||
else if ((embeddings === undefined) && (documents !== undefined)) { | ||
const documentsArray = toArray(documents); | ||
if (this.embeddingFunction !== undefined) { | ||
embeddings = await this.embeddingFunction.generate(documentsArray); | ||
} | ||
else { | ||
throw new Error("embeddingFunction is undefined. Please configure an embedding function"); | ||
} | ||
} | ||
var resp = await this.api.update({ | ||
collectionName: this.name, | ||
updateEmbedding: { | ||
ids: toArray(ids), | ||
embeddings: (embeddings ? toArrayOfArrays(embeddings) : undefined), | ||
documents: toArray(documents), | ||
metadatas: toArray(metadatas), | ||
}, | ||
}).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
return resp; | ||
} | ||
async query(query_embeddings, n_results = 10, where, query_text, where_document, // {"$contains":"search_string"} | ||
include) { | ||
if ((query_embeddings === undefined) && (query_text === undefined)) { | ||
@@ -183,2 +214,4 @@ throw new Error("query_embeddings and query_text cannot both be undefined"); | ||
n_results, | ||
where_document: where_document, | ||
include: include | ||
}, | ||
@@ -226,2 +259,12 @@ }).then(function (response) { | ||
} | ||
// version | ||
async version() { | ||
const response = await this.api.version(); | ||
return response.data; | ||
} | ||
// heartbeat | ||
async heartbeat() { | ||
const response = await this.api.heartbeat(); | ||
return response.data["nanosecond heartbeat"]; | ||
} | ||
async createCollection(name, metadata, embeddingFunction) { | ||
@@ -240,2 +283,16 @@ const newCollection = await this.api.createCollection({ | ||
} | ||
// get or create collection | ||
async getOrCreateCollection(name, metadata, embeddingFunction) { | ||
const newCollection = await this.api.createCollection({ | ||
createCollection: { name, metadata, get_or_create: true }, | ||
}).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
if (newCollection.error) { | ||
throw new Error(newCollection.error); | ||
} | ||
return new Collection(name, this.api, embeddingFunction); | ||
} | ||
async listCollections() { | ||
@@ -242,0 +299,0 @@ const response = await this.api.listCollections(); |
{ | ||
"name": "chromadb", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "A JavaScript interface for chroma", | ||
@@ -34,4 +34,4 @@ "keywords": [], | ||
"test:update": "run-s db:clean db:run && jest --runInBand --updateSnapshot && run-s db:clean", | ||
"db:clean": "cd ../.. && docker-compose -f docker-compose-js-tests.yml down --volumes", | ||
"db:run": "cd ../.. && docker-compose -f docker-compose-js-tests.yml up --detach && sleep 5", | ||
"db:clean": "cd ../.. && docker-compose -f docker-compose.test.yml down --volumes", | ||
"db:run": "cd ../.. && docker-compose -f docker-compose.test.yml up --detach && sleep 5", | ||
"clean": "rimraf dist", | ||
@@ -38,0 +38,0 @@ "build": "run-s clean build:*", |
@@ -381,2 +381,32 @@ /* tslint:disable */ | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => { | ||
const localVarPath = `/api/v1/heartbeat`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; | ||
const localVarHeaderParameter = {} as any; | ||
const localVarQueryParameter = {} as any; | ||
setSearchParams(localVarUrlObj, localVarQueryParameter); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; | ||
return { | ||
url: toPathString(localVarUrlObj), | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -616,2 +646,32 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => { | ||
const localVarPath = `/api/v1/version`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; | ||
const localVarHeaderParameter = {} as any; | ||
const localVarQueryParameter = {} as any; | ||
setSearchParams(localVarUrlObj, localVarQueryParameter); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; | ||
return { | ||
url: toPathString(localVarUrlObj), | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
} | ||
@@ -732,2 +792,12 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async heartbeat(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>> { | ||
const localVarAxiosArgs = await localVarAxiosParamCreator.heartbeat(options); | ||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -806,2 +876,12 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async version(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>> { | ||
const localVarAxiosArgs = await localVarAxiosParamCreator.version(options); | ||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); | ||
}, | ||
} | ||
@@ -913,2 +993,11 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
heartbeat(options?: any): AxiosPromise<any> { | ||
return localVarFp.heartbeat(options).then((request) => request(axios, basePath)); | ||
}, | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -980,2 +1069,11 @@ * @param {*} [options] Override http request option. | ||
}, | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
version(options?: any): AxiosPromise<any> { | ||
return localVarFp.version(options).then((request) => request(axios, basePath)); | ||
}, | ||
}; | ||
@@ -1311,2 +1409,13 @@ }; | ||
* | ||
* @summary Heartbeat | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
public heartbeat(options?: AxiosRequestConfig) { | ||
return DefaultApiFp(this.configuration).heartbeat(options).then((request) => request(this.axios, this.basePath)); | ||
} | ||
/** | ||
* | ||
* @summary List Collections | ||
@@ -1389,2 +1498,13 @@ * @param {*} [options] Override http request option. | ||
} | ||
/** | ||
* | ||
* @summary Version | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
public version(options?: AxiosRequestConfig) { | ||
return DefaultApiFp(this.configuration).version(options).then((request) => request(this.axios, this.basePath)); | ||
} | ||
} |
127
src/index.ts
@@ -0,1 +1,2 @@ | ||
import { GetEmbeddingIncludeEnum, QueryEmbeddingIncludeEnum } from "./generated"; | ||
import { DefaultApi } from "./generated/api"; | ||
@@ -97,7 +98,9 @@ import { Configuration } from "./generated/configuration"; | ||
public name: string; | ||
public metadata: object | undefined; | ||
private api: DefaultApi; | ||
public embeddingFunction: CallableFunction | undefined; | ||
constructor(name: string, api: DefaultApi, embeddingFunction?: CallableFunction) { | ||
constructor(name: string, api: DefaultApi, metadata?: object, embeddingFunction?: CallableFunction) { | ||
this.name = name; | ||
this.metadata = metadata; | ||
this.api = api; | ||
@@ -108,2 +111,9 @@ if (embeddingFunction !== undefined) | ||
private setName(name: string) { | ||
this.name = name; | ||
} | ||
private setMetadata(metadata: object | undefined) { | ||
this.metadata = metadata; | ||
} | ||
public async add( | ||
@@ -182,2 +192,24 @@ ids: string | string[], | ||
public async modify( | ||
name?: string, | ||
metadata?: object, | ||
) { | ||
const response = await this.api.updateCollection({ | ||
collectionName: this.name, | ||
updateCollection: { | ||
new_name: name, | ||
new_metadata: metadata, | ||
}, | ||
}).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
this.setName(name || this.name) | ||
this.setMetadata(metadata || this.metadata) | ||
return response | ||
} | ||
public async get( | ||
@@ -188,2 +220,4 @@ ids?: string[], | ||
offset?: number, | ||
include?: GetEmbeddingIncludeEnum[], | ||
where_document?: object, | ||
) { | ||
@@ -200,2 +234,4 @@ let idsArray = undefined | ||
offset, | ||
include, | ||
where_document, | ||
}, | ||
@@ -212,2 +248,40 @@ }).then(function (response) { | ||
public async update( | ||
ids: string | string[], | ||
embeddings?: number[] | number[][], | ||
metadatas?: object | object[], | ||
documents?: string | string[], | ||
) { | ||
if ((embeddings === undefined) && (documents === undefined) && (metadatas === undefined)) { | ||
throw new Error( | ||
"embeddings, documents, and metadatas cannot all be undefined", | ||
); | ||
} else if ((embeddings === undefined) && (documents !== undefined)) { | ||
const documentsArray = toArray(documents); | ||
if (this.embeddingFunction !== undefined) { | ||
embeddings = await this.embeddingFunction.generate(documentsArray) | ||
} else { | ||
throw new Error( | ||
"embeddingFunction is undefined. Please configure an embedding function", | ||
); | ||
} | ||
} | ||
var resp = await this.api.update({ | ||
collectionName: this.name, | ||
updateEmbedding: { | ||
ids: toArray(ids), | ||
embeddings: (embeddings ? toArrayOfArrays(embeddings) : undefined), | ||
documents: toArray(documents), | ||
metadatas: toArray(metadatas), | ||
}, | ||
}).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
return resp | ||
} | ||
public async query( | ||
@@ -217,3 +291,5 @@ query_embeddings: number[] | number[][] | undefined, | ||
where?: object, | ||
query_text?: string | string[], | ||
query_text?: string | string[], // TODO: should be named query_texts to match python API | ||
where_document?: object, // {"$contains":"search_string"} | ||
include?: QueryEmbeddingIncludeEnum[], // ["metadata", "document"] | ||
) { | ||
@@ -244,2 +320,4 @@ if ((query_embeddings === undefined) && (query_text === undefined)) { | ||
n_results, | ||
where_document: where_document, | ||
include: include | ||
}, | ||
@@ -267,6 +345,6 @@ }).then(function (response) { | ||
public async delete(ids?: string[], where?: object) { | ||
public async delete(ids?: string[], where?: object, where_document?: object) { | ||
var response = await this.api._delete({ | ||
collectionName: this.name, | ||
deleteEmbedding: { ids: ids, where: where }, | ||
deleteEmbedding: { ids: ids, where: where, where_document: where_document }, | ||
}).then(function (response) { | ||
@@ -298,2 +376,16 @@ return response.data; | ||
public async version() { | ||
const response = await this.api.version(); | ||
return response.data; | ||
} | ||
public async heartbeat() { | ||
const response = await this.api.heartbeat(); | ||
return response.data["nanosecond heartbeat"]; | ||
} | ||
public async persist() { | ||
throw new Error("Not implemented in JS client") | ||
} | ||
public async createCollection(name: string, metadata?: object, embeddingFunction?: CallableFunction) { | ||
@@ -312,5 +404,22 @@ const newCollection = await this.api.createCollection({ | ||
return new Collection(name, this.api, embeddingFunction); | ||
return new Collection(name, this.api, metadata, embeddingFunction); | ||
} | ||
public async getOrCreateCollection(name: string, metadata?: object, embeddingFunction?: CallableFunction) { | ||
const newCollection = await this.api.createCollection({ | ||
createCollection: { name, metadata, get_or_create: true }, | ||
}).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
if (newCollection.error) { | ||
throw new Error(newCollection.error); | ||
} | ||
return new Collection(name, this.api, newCollection.metadata, embeddingFunction); | ||
} | ||
public async listCollections() { | ||
@@ -322,3 +431,9 @@ const response = await this.api.listCollections(); | ||
public async getCollection(name: string, embeddingFunction?: CallableFunction) { | ||
return new Collection(name, this.api, embeddingFunction); | ||
const response = await this.api.getCollection({ collectionName: name }).then(function (response) { | ||
return response.data; | ||
}).catch(function ({ response }) { | ||
return response.data; | ||
}); | ||
return new Collection(response.name, this.api, response.metadata, embeddingFunction); | ||
} | ||
@@ -325,0 +440,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
497505
9426