Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chromadb

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chromadb - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

dist/main/generated/models.d.ts

440

dist/main/generated/api.d.ts
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export * from './api/default-api';
import { Configuration } from "./configuration";
import { FetchAPI, FetchArgs, BaseAPI } from "./runtime";
import { Api } from "./models";
export type FactoryFunction<T> = (configuration?: Configuration, basePath?: string, fetch?: FetchAPI) => T;
/**
* ApiApi - fetch parameter creator
* @export
*/
export declare const ApiApiFetchParamCreator: (configuration?: Configuration) => {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options?: RequestInit): FetchArgs;
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options?: RequestInit): FetchArgs;
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options?: RequestInit): FetchArgs;
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options?: RequestInit): FetchArgs;
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options?: RequestInit): FetchArgs;
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: RequestInit): FetchArgs;
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options?: RequestInit): FetchArgs;
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options?: RequestInit): FetchArgs;
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options?: RequestInit): FetchArgs;
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options?: RequestInit): FetchArgs;
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options?: RequestInit): FetchArgs;
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit): FetchArgs;
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: RequestInit): FetchArgs;
};
/**
* ApiApi - functional programming interface
* @export
*/
export declare const ApiApiFp: (configuration?: Configuration) => {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Add201Response>;
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.ADelete200Response>;
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.AGet200Response>;
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Count200Response>;
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.CreateCollection200Response>;
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.CreateIndex200Response>;
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.DeleteCollection200Response>;
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.GetCollection200Response>;
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.GetNearestNeighbors200Response>;
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Heartbeat200Response>;
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.ListCollections200Response>;
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Persist200Response>;
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.RawSql200Response>;
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Reset200Response>;
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Root200Response>;
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Update200Response>;
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.UpdateCollection200Response>;
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Upsert200Response>;
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Version200Response>;
};
/**
* ApiApi - factory interface
* @export
*/
export declare const ApiApiFactory: FactoryFunction<ApiApi>;
/**
* ApiApi - object-oriented interface
* @export
* @class ApiApi
* @extends {BaseAPI}
*/
export declare class ApiApi extends BaseAPI {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): Promise<Api.Add201Response>;
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit): Promise<Api.ADelete200Response>;
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit): Promise<Api.AGet200Response>;
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options?: RequestInit): Promise<Api.Count200Response>;
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options?: RequestInit): Promise<Api.CreateCollection200Response>;
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options?: RequestInit): Promise<Api.CreateIndex200Response>;
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options?: RequestInit): Promise<Api.DeleteCollection200Response>;
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options?: RequestInit): Promise<Api.GetCollection200Response>;
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit): Promise<Api.GetNearestNeighbors200Response>;
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: RequestInit): Promise<Api.Heartbeat200Response>;
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options?: RequestInit): Promise<Api.ListCollections200Response>;
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options?: RequestInit): Promise<Api.Persist200Response>;
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options?: RequestInit): Promise<Api.RawSql200Response>;
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options?: RequestInit): Promise<Api.Reset200Response>;
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options?: RequestInit): Promise<Api.Root200Response>;
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit): Promise<Api.Update200Response>;
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit): Promise<Api.UpdateCollection200Response>;
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): Promise<Api.Upsert200Response>;
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: RequestInit): Promise<Api.Version200Response>;
}
//# sourceMappingURL=api.d.ts.map

48

dist/main/generated/configuration.d.ts
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
apiKey?: string | ((name: string) => string | null);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
authorization?: string | ((name: string, scopes?: string[]) => string | null);
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
}

@@ -27,3 +25,3 @@ export declare class Configuration {

*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
apiKey?: string | ((name: string) => string | null);
/**

@@ -44,8 +42,8 @@ * parameter for basic security

/**
* parameter for oauth2 security
* parameter for oauth2, openIdConnect or http security
* @param name security name
* @param scopes oauth2 scope
* @param scopes oauth2 scopes
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
authorization?: string | ((name: string, scopes?: string[]) => string | null);
/**

@@ -58,30 +56,4 @@ * override base path

basePath?: string;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
constructor(param?: ConfigurationParameters);
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime: string): boolean;
}
//# sourceMappingURL=configuration.d.ts.map
"use strict";
/* tslint:disable */
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.

@@ -22,23 +22,7 @@ */

this.password = param.password;
this.accessToken = param.accessToken;
this.authorization = param.authorization;
this.basePath = param.basePath;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}
exports.Configuration = Configuration;
//# sourceMappingURL=configuration.js.map
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export * from "./api";
export * from "./models";
export * from "./configuration";
export * from "./models";
export { RequiredError } from "./runtime";
export type { FetchAPI, FetchArgs } from "./runtime";
//# sourceMappingURL=index.d.ts.map
"use strict";
/* tslint:disable */
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.

@@ -30,5 +30,8 @@ */

Object.defineProperty(exports, "__esModule", { value: true });
exports.RequiredError = void 0;
__exportStar(require("./api"), exports);
__exportStar(require("./models"), exports);
__exportStar(require("./configuration"), exports);
__exportStar(require("./models"), exports);
var runtime_1 = require("./runtime");
Object.defineProperty(exports, "RequiredError", { enumerable: true, get: function () { return runtime_1.RequiredError; } });
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import { GetEmbeddingIncludeEnum, QueryEmbeddingIncludeEnum } from "./generated";
import { DefaultApi } from "./generated/api";
import { IncludeEnum, Metadata, Metadatas, Embedding, Embeddings, Document, Documents, Where, WhereDocument, ID, IDs, PositiveInteger, CollectionType, GetResponse, QueryResponse } from "./types";
import { ApiApi as DefaultApi, Api } from "./generated";
export declare class OpenAIEmbeddingFunction {

@@ -7,3 +7,7 @@ private api_key;

private model;
constructor(openai_api_key: string, openai_model?: string, openai_organization_id?: string);
constructor({ openai_api_key, openai_model, openai_organization_id, }: {
openai_api_key: string;
openai_model?: string;
openai_organization_id?: string;
});
generate(texts: string[]): Promise<number[][]>;

@@ -13,3 +17,5 @@ }

private api_key;
constructor(cohere_api_key: string);
constructor({ cohere_api_key }: {
cohere_api_key: string;
});
generate(texts: string[]): Promise<any>;

@@ -22,28 +28,404 @@ }

name: string;
id: string;
metadata: Metadata | undefined;
/**
* @ignore
*/
private api;
/**
* @ignore
*/
embeddingFunction: CallableFunction | undefined;
constructor(name: string, api: DefaultApi, embeddingFunction?: CallableFunction);
add(ids: string | string[], embeddings: number[] | number[][] | undefined, metadatas?: object | object[], documents?: string | string[], increment_index?: boolean): Promise<any>;
count(): 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>;
createIndex(): Promise<import("axios").AxiosResponse<any, any>>;
delete(ids?: string[], where?: object): Promise<any>;
/**
* @ignore
*/
constructor(name: string, id: string, api: DefaultApi, metadata?: Metadata, embeddingFunction?: CallableFunction);
/**
* @ignore
*/
private setName;
/**
* @ignore
*/
private setMetadata;
/**
* @ignore
*/
private validate;
/**
* Add items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.add({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"]
* });
* ```
*/
add({ ids, embeddings, metadatas, documents, }: {
ids: ID | IDs;
embeddings?: Embedding | Embeddings;
metadatas?: Metadata | Metadatas;
documents?: Document | Documents;
}): Promise<boolean>;
/**
* Upsert items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.upsert({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"],
* });
* ```
*/
upsert({ ids, embeddings, metadatas, documents, }: {
ids: ID | IDs;
embeddings?: Embedding | Embeddings;
metadatas?: Metadata | Metadatas;
documents?: Document | Documents;
}): Promise<boolean>;
/**
* Count the number of items in the collection
* @returns {Promise<number>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.count();
* ```
*/
count(): Promise<number>;
/**
* Modify the collection name or metadata
* @param {Object} params - The parameters for the query.
* @param {string} [params.name] - Optional new name for the collection.
* @param {Metadata} [params.metadata] - Optional new metadata for the collection.
* @returns {Promise<void>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.modify({
* name: "new name",
* metadata: { "key": "value" },
* });
* ```
*/
modify({ name, metadata }?: {
name?: string;
metadata?: Metadata;
}): Promise<void>;
/**
* Get items from the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - Optional IDs of the items to get.
* @param {Where} [params.where] - Optional where clause to filter items by.
* @param {PositiveInteger} [params.limit] - Optional limit on the number of items to get.
* @param {PositiveInteger} [params.offset] - Optional offset on the items to get.
* @param {IncludeEnum[]} [params.include] - Optional list of items to include in the response.
* @param {WhereDocument} [params.where_document] - Optional where clause to filter items by.
* @returns {Promise<GetResponse>} - The response from the server.
*
* @example
* ```typescript
* const response = await collection.get({
* ids: ["id1", "id2"],
* where: { "key": "value" },
* limit: 10,
* offset: 0,
* include: ["embeddings", "metadatas", "documents"],
* where_document: { $contains: "value" },
* });
* ```
*/
get({ ids, where, limit, offset, include, where_document, }?: {
ids?: ID | IDs;
where?: Where;
limit?: PositiveInteger;
offset?: PositiveInteger;
include?: IncludeEnum[];
where_document?: WhereDocument;
}): Promise<GetResponse>;
/**
* Update the embeddings, documents, and/or metadatas of existing items
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - The IDs of the items to update.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings to update.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadatas to update.
* @param {Document | Documents} [params.documents] - Optional documents to update.
* @returns {Promise<APIResponse>} - The API Response.
*
* @example
* ```typescript
* const response = await collection.update({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["new document 1", "new document 2"],
* });
* ```
*/
update({ ids, embeddings, metadatas, documents, }: {
ids: ID | IDs;
embeddings?: Embedding | Embeddings;
metadatas?: Metadata | Metadatas;
documents?: Document | Documents;
}): Promise<any>;
/**
* Performs a query on the collection using the specified parameters.
*
* @param {Object} params - The parameters for the query.
* @param {Embedding | Embeddings} [params.query_embeddings] - Optional query embeddings to use for the search.
* @param {PositiveInteger} [params.n_results] - Optional number of results to return (default is 10).
* @param {Where} [params.where] - Optional query condition to filter results based on metadata values.
* @param {string | string[]} [params.query_text] - Optional query text(s) to search for in the collection (renamed to 'query_texts' in the future).
* @param {WhereDocument} [params.where_document] - Optional query condition to filter results based on document content.
* @param {IncludeEnum[]} [params.include] - Optional array of fields to include in the result, such as "metadata" and "document".
*
* @returns {Promise<QueryResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
* @example
* // Query the collection using embeddings
* const results = await collection.query({
* query_embeddings: [[0.1, 0.2, ...], ...],
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* @example
* ```js
* // Query the collection using query text
* const results = await collection.query({
* query_text: "some text",
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* ```
*
*/
query({ query_embeddings, n_results, where, query_text, where_document, include, }: {
query_embeddings?: Embedding | Embeddings;
n_results?: PositiveInteger;
where?: Where;
query_text?: string | string[];
where_document?: WhereDocument;
include?: IncludeEnum[];
}): Promise<QueryResponse>;
/**
* Peek inside the collection
* @param {Object} params - The parameters for the query.
* @param {PositiveInteger} [params.limit] - Optional number of results to return (default is 10).
* @returns {Promise<GetResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
*
* @example
* ```typescript
* const results = await collection.peek({
* limit: 10
* });
* ```
*/
peek({ limit }?: {
limit?: PositiveInteger;
}): Promise<GetResponse>;
/**
* Deletes items from the collection.
* @param {Object} params - The parameters for deleting items from the collection.
* @param {ID | IDs} [params.ids] - Optional ID or array of IDs of items to delete.
* @param {Where} [params.where] - Optional query condition to filter items to delete based on metadata values.
* @param {WhereDocument} [params.where_document] - Optional query condition to filter items to delete based on document content.
* @returns {Promise<string[]>} A promise that resolves to the IDs of the deleted items.
* @throws {Error} If there is an issue deleting items from the collection.
*
* @example
* ```typescript
* const results = await collection.delete({
* ids: "some_id",
* where: {"name": {"$eq": "John Doe"}},
* where_document: {"$contains":"search_string"}
* });
* ```
*/
delete({ ids, where, where_document }?: {
ids?: ID | IDs;
where?: Where;
where_document?: WhereDocument;
}): Promise<string[]>;
}
export declare class ChromaClient {
/**
* @ignore
*/
private api;
constructor(basePath?: string);
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>;
getCollection(name: string, embeddingFunction?: CallableFunction): Promise<Collection>;
deleteCollection(name: string): Promise<any>;
/**
* Creates a new ChromaClient instance.
* @param {Object} params - The parameters for creating a new client
* @param {string} [params.path] - The base path for the Chroma API.
* @returns {ChromaClient} A new ChromaClient instance.
*
* @example
* ```typescript
* const client = new ChromaClient({
* path: "http://localhost:8000"
* });
* ```
*/
constructor({ path }?: {
path?: string;
});
/**
* Resets the state of the object by making an API call to the reset endpoint.
*
* @returns {Promise<void>} A promise that resolves when the reset operation is complete.
* @throws {Error} If there is an issue resetting the state.
*
* @example
* ```typescript
* await client.reset();
* ```
*/
reset(): Promise<Api.Reset200Response>;
/**
* Returns the version of the Chroma API.
* @returns {Promise<string>} A promise that resolves to the version of the Chroma API.
*
* @example
* ```typescript
* const version = await client.version();
* ```
*/
version(): Promise<string>;
/**
* Returns a heartbeat from the Chroma API.
* @returns {Promise<number>} A promise that resolves to the heartbeat from the Chroma API.
*
* @example
* ```typescript
* const heartbeat = await client.heartbeat();
* ```
*/
heartbeat(): Promise<number>;
/**
* @ignore
*/
persist(): Promise<never>;
/**
* Creates a new collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the created collection.
* @throws {Error} If there is an issue creating the collection.
*
* @example
* ```typescript
* const collection = await client.createCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
createCollection({ name, metadata, embeddingFunction }: {
name: string;
metadata?: Metadata;
embeddingFunction?: CallableFunction;
}): Promise<Collection>;
/**
* Gets or creates a collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the got or created collection.
* @throws {Error} If there is an issue getting or creating the collection.
*
* @example
* ```typescript
* const collection = await client.getOrCreateCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
getOrCreateCollection({ name, metadata, embeddingFunction }: {
name: string;
metadata?: Metadata;
embeddingFunction?: CallableFunction;
}): Promise<Collection>;
/**
* Lists all collections.
*
* @returns {Promise<CollectionType[]>} A promise that resolves to a list of collection names.
* @throws {Error} If there is an issue listing the collections.
*
* @example
* ```typescript
* const collections = await client.listCollections();
* ```
*/
listCollections(): Promise<CollectionType[]>;
/**
* Gets a collection with the specified name.
* @param {Object} params - The parameters for getting a collection.
* @param {string} params.name - The name of the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
* @returns {Promise<Collection>} A promise that resolves to the collection.
* @throws {Error} If there is an issue getting the collection.
*
* @example
* ```typescript
* const collection = await client.getCollection({
* name: "my_collection"
* });
* ```
*/
getCollection({ name, embeddingFunction }: {
name: string;
embeddingFunction?: CallableFunction;
}): Promise<Collection>;
/**
* Deletes a collection with the specified name.
* @param {Object} params - The parameters for deleting a collection.
* @param {string} params.name - The name of the collection.
* @returns {Promise<void>} A promise that resolves when the collection is deleted.
* @throws {Error} If there is an issue deleting the collection.
*
* @example
* ```typescript
* await client.deleteCollection({
* name: "my_collection"
* });
* ```
*/
deleteCollection({ name }: {
name: string;
}): Promise<void>;
}
export {};
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChromaClient = exports.Collection = exports.CohereEmbeddingFunction = exports.OpenAIEmbeddingFunction = void 0;
const api_1 = require("./generated/api");
const configuration_1 = require("./generated/configuration");
const generated_1 = require("./generated");
// a function to convert a non-Array object to an Array

@@ -24,2 +23,46 @@ function toArray(obj) {

}
// we need to override constructors to make it work with jest
// https://stackoverflow.com/questions/76007003/jest-tobeinstanceof-expected-constructor-array-received-constructor-array
function repack(value) {
if (Boolean(value) && typeof value === "object") {
if (Array.isArray(value)) {
return new Array(...value);
}
else {
return Object.assign({}, value);
}
}
else {
return value;
}
}
async function handleError(error) {
if (error instanceof Response) {
try {
const res = await error.json();
if ("error" in res) {
return { error: res.error };
}
}
catch (e) {
return {
//@ts-ignore
error: e && typeof e === "object" && "message" in e
? e.message
: "unknown error",
};
}
}
return { error };
}
async function handleSuccess(response) {
switch (true) {
case response instanceof Response:
return repack(await response.json());
case typeof response === "string":
return repack(response); // currently version is the only thing that return non-JSON
default:
return repack(response);
}
}
class EmbeddingFunction {

@@ -29,3 +72,3 @@ }

class OpenAIEmbeddingFunction {
constructor(openai_api_key, openai_model, openai_organization_id) {
constructor({ openai_api_key, openai_model, openai_organization_id, }) {
try {

@@ -50,8 +93,8 @@ // eslint-disable-next-line global-require,import/no-extraneous-dependencies

const response = await openai.createEmbedding({
model: "text-embedding-ada-002",
model: this.model,
input: texts,
});
const data = response.data['data'];
const data = response.data["data"];
for (let i = 0; i < data.length; i += 1) {
embeddings.push(data[i]['embedding']);
embeddings.push(data[i]["embedding"]);
}

@@ -64,3 +107,3 @@ return embeddings;

class CohereEmbeddingFunction {
constructor(cohere_api_key) {
constructor({ cohere_api_key }) {
try {

@@ -86,4 +129,9 @@ // eslint-disable-next-line global-require,import/no-extraneous-dependencies

class Collection {
constructor(name, api, embeddingFunction) {
/**
* @ignore
*/
constructor(name, id, api, metadata, embeddingFunction) {
this.name = name;
this.id = id;
this.metadata = metadata;
this.api = api;

@@ -93,7 +141,25 @@ if (embeddingFunction !== undefined)

}
async add(ids, embeddings, metadatas, documents, increment_index = true) {
if ((embeddings === undefined) && (documents === undefined)) {
throw new Error("embeddings and documents cannot both be undefined");
/**
* @ignore
*/
setName(name) {
this.name = name;
}
/**
* @ignore
*/
setMetadata(metadata) {
this.metadata = metadata;
}
/**
* @ignore
*/
async validate(require_embeddings_or_documents, // set to false in the case of Update
ids, embeddings, metadatas, documents) {
if (require_embeddings_or_documents) {
if ((embeddings === undefined) && (documents === undefined)) {
throw new Error("embeddings and documents cannot both be undefined");
}
}
else if ((embeddings === undefined) && (documents !== undefined)) {
if ((embeddings === undefined) && (documents !== undefined)) {
const documentsArray = toArray(documents);

@@ -125,53 +191,194 @@ if (this.embeddingFunction !== undefined) {

}
if (((embeddingsArray !== undefined) && idsArray.length !== embeddingsArray.length) ||
((metadatasArray !== undefined) && idsArray.length !== metadatasArray.length) ||
((documentsArray !== undefined) && idsArray.length !== documentsArray.length)) {
// validate all ids are strings
for (let i = 0; i < idsArray.length; i += 1) {
if (typeof idsArray[i] !== "string") {
throw new Error(`Expected ids to be strings, found ${typeof idsArray[i]} at index ${i}`);
}
}
if ((embeddingsArray !== undefined &&
idsArray.length !== embeddingsArray.length) ||
(metadatasArray !== undefined &&
idsArray.length !== metadatasArray.length) ||
(documentsArray !== undefined &&
idsArray.length !== documentsArray.length)) {
throw new Error("ids, embeddings, metadatas, and documents must all be the same length");
}
const response = await this.api.add({
collectionName: this.name,
addEmbedding: {
ids: idsArray,
embeddings: embeddingsArray,
documents: documentsArray,
metadatas: metadatasArray,
increment_index: increment_index,
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
const uniqueIds = new Set(idsArray);
if (uniqueIds.size !== idsArray.length) {
const duplicateIds = idsArray.filter((item, index) => idsArray.indexOf(item) !== index);
throw new Error(`Expected IDs to be unique, found duplicates for: ${duplicateIds}`);
}
return [idsArray, embeddingsArray, metadatasArray, documentsArray];
}
/**
* Add items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.add({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"]
* });
* ```
*/
async add({ ids, embeddings, metadatas, documents, }) {
const [idsArray, embeddingsArray, metadatasArray, documentsArray] = await this.validate(true, ids, embeddings, metadatas, documents);
const response = await this.api.add(this.id, {
// @ts-ignore
ids: idsArray,
embeddings: embeddingsArray,
// @ts-ignore
documents: documentsArray,
metadatas: metadatasArray,
})
.then(handleSuccess)
.catch(handleError);
return response;
}
/**
* Upsert items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.upsert({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"],
* });
* ```
*/
async upsert({ ids, embeddings, metadatas, documents, }) {
const [idsArray, embeddingsArray, metadatasArray, documentsArray] = await this.validate(true, ids, embeddings, metadatas, documents);
const response = await this.api.upsert(this.id, {
//@ts-ignore
ids: idsArray,
embeddings: embeddingsArray,
//@ts-ignore
documents: documentsArray,
metadatas: metadatasArray,
})
.then(handleSuccess)
.catch(handleError);
return response;
}
/**
* Count the number of items in the collection
* @returns {Promise<number>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.count();
* ```
*/
async count() {
const response = await this.api.count({ collectionName: this.name });
return response.data;
const response = await this.api.count(this.id);
return handleSuccess(response);
}
async get(ids, where, limit, offset, include, where_document) {
/**
* Modify the collection name or metadata
* @param {Object} params - The parameters for the query.
* @param {string} [params.name] - Optional new name for the collection.
* @param {Metadata} [params.metadata] - Optional new metadata for the collection.
* @returns {Promise<void>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.modify({
* name: "new name",
* metadata: { "key": "value" },
* });
* ```
*/
async modify({ name, metadata } = {}) {
const response = await this.api
.updateCollection(this.id, {
new_name: name,
new_metadata: metadata,
})
.then(handleSuccess)
.catch(handleError);
this.setName(name || this.name);
this.setMetadata(metadata || this.metadata);
return response;
}
/**
* Get items from the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - Optional IDs of the items to get.
* @param {Where} [params.where] - Optional where clause to filter items by.
* @param {PositiveInteger} [params.limit] - Optional limit on the number of items to get.
* @param {PositiveInteger} [params.offset] - Optional offset on the items to get.
* @param {IncludeEnum[]} [params.include] - Optional list of items to include in the response.
* @param {WhereDocument} [params.where_document] - Optional where clause to filter items by.
* @returns {Promise<GetResponse>} - The response from the server.
*
* @example
* ```typescript
* const response = await collection.get({
* ids: ["id1", "id2"],
* where: { "key": "value" },
* limit: 10,
* offset: 0,
* include: ["embeddings", "metadatas", "documents"],
* where_document: { $contains: "value" },
* });
* ```
*/
async get({ ids, where, limit, offset, include, where_document, } = {}) {
let idsArray = undefined;
if (ids !== undefined)
idsArray = toArray(ids);
var resp = await this.api.get({
collectionName: this.name,
getEmbedding: {
ids: idsArray,
where,
limit,
offset,
include,
where_document,
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return resp;
return await this.api
.aGet(this.id, {
ids: idsArray,
where,
limit,
offset,
include,
where_document,
})
.then(handleSuccess)
.catch(handleError);
}
async update(ids, embeddings, metadatas, documents) {
if ((embeddings === undefined) && (documents === undefined) && (metadatas === undefined)) {
/**
* Update the embeddings, documents, and/or metadatas of existing items
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - The IDs of the items to update.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings to update.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadatas to update.
* @param {Document | Documents} [params.documents] - Optional documents to update.
* @returns {Promise<APIResponse>} - The API Response.
*
* @example
* ```typescript
* const response = await collection.update({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["new document 1", "new document 2"],
* });
* ```
*/
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)) {
else if (embeddings === undefined && documents !== undefined) {
const documentsArray = toArray(documents);

@@ -185,23 +392,55 @@ if (this.embeddingFunction !== undefined) {

}
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;
});
if (metadatas !== undefined)
metadatas = toArray(metadatas);
var resp = await this.api
.update(this.id, {
ids: toArray(ids),
embeddings: embeddings ? toArrayOfArrays(embeddings) : undefined,
documents: documents,
metadatas: metadatas
})
.then(handleSuccess)
.catch(handleError);
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)) {
/**
* Performs a query on the collection using the specified parameters.
*
* @param {Object} params - The parameters for the query.
* @param {Embedding | Embeddings} [params.query_embeddings] - Optional query embeddings to use for the search.
* @param {PositiveInteger} [params.n_results] - Optional number of results to return (default is 10).
* @param {Where} [params.where] - Optional query condition to filter results based on metadata values.
* @param {string | string[]} [params.query_text] - Optional query text(s) to search for in the collection (renamed to 'query_texts' in the future).
* @param {WhereDocument} [params.where_document] - Optional query condition to filter results based on document content.
* @param {IncludeEnum[]} [params.include] - Optional array of fields to include in the result, such as "metadata" and "document".
*
* @returns {Promise<QueryResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
* @example
* // Query the collection using embeddings
* const results = await collection.query({
* query_embeddings: [[0.1, 0.2, ...], ...],
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* @example
* ```js
* // Query the collection using query text
* const results = await collection.query({
* query_text: "some text",
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* ```
*
*/
async query({ query_embeddings, n_results, where, query_text, where_document, include, }) {
if (n_results === undefined)
n_results = 10;
if (query_embeddings === undefined && query_text === undefined) {
throw new Error("query_embeddings and query_text cannot both be undefined");
}
else if ((query_embeddings === undefined) && (query_text !== undefined)) {
else if (query_embeddings === undefined && query_text !== undefined) {
const query_texts = toArray(query_text);

@@ -218,104 +457,258 @@ if (this.embeddingFunction !== undefined) {

const query_embeddingsArray = toArrayOfArrays(query_embeddings);
const response = await this.api.getNearestNeighbors({
collectionName: this.name,
queryEmbedding: {
query_embeddings: query_embeddingsArray,
where,
n_results,
where_document: where_document,
include: include
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response;
return await this.api
.getNearestNeighbors(this.id, {
query_embeddings: query_embeddingsArray,
where,
n_results: n_results,
where_document: where_document,
include: include,
})
.then(handleSuccess)
.catch(handleError);
}
async peek(limit = 10) {
const response = await this.api.get({
collectionName: this.name,
getEmbedding: { limit: limit },
/**
* Peek inside the collection
* @param {Object} params - The parameters for the query.
* @param {PositiveInteger} [params.limit] - Optional number of results to return (default is 10).
* @returns {Promise<GetResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
*
* @example
* ```typescript
* const results = await collection.peek({
* limit: 10
* });
* ```
*/
async peek({ limit } = {}) {
if (limit === undefined)
limit = 10;
const response = await this.api.aGet(this.id, {
limit: limit,
});
return response.data;
return handleSuccess(response);
}
async createIndex() {
return await this.api.createIndex({ collectionName: this.name });
/**
* Deletes items from the collection.
* @param {Object} params - The parameters for deleting items from the collection.
* @param {ID | IDs} [params.ids] - Optional ID or array of IDs of items to delete.
* @param {Where} [params.where] - Optional query condition to filter items to delete based on metadata values.
* @param {WhereDocument} [params.where_document] - Optional query condition to filter items to delete based on document content.
* @returns {Promise<string[]>} A promise that resolves to the IDs of the deleted items.
* @throws {Error} If there is an issue deleting items from the collection.
*
* @example
* ```typescript
* const results = await collection.delete({
* ids: "some_id",
* where: {"name": {"$eq": "John Doe"}},
* where_document: {"$contains":"search_string"}
* });
* ```
*/
async delete({ ids, where, where_document } = {}) {
let idsArray = undefined;
if (ids !== undefined)
idsArray = toArray(ids);
return await this.api
.aDelete(this.id, { ids: idsArray, where: where, where_document: where_document })
.then(handleSuccess)
.catch(handleError);
}
async delete(ids, where) {
var response = await this.api._delete({
collectionName: this.name,
deleteEmbedding: { ids: ids, where: where },
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response;
}
}
exports.Collection = Collection;
class ChromaClient {
constructor(basePath) {
if (basePath === undefined)
basePath = "http://localhost:8000";
const apiConfig = new configuration_1.Configuration({
basePath,
/**
* Creates a new ChromaClient instance.
* @param {Object} params - The parameters for creating a new client
* @param {string} [params.path] - The base path for the Chroma API.
* @returns {ChromaClient} A new ChromaClient instance.
*
* @example
* ```typescript
* const client = new ChromaClient({
* path: "http://localhost:8000"
* });
* ```
*/
constructor({ path } = {}) {
if (path === undefined)
path = "http://localhost:8000";
const apiConfig = new generated_1.Configuration({
basePath: path,
});
this.api = new api_1.DefaultApi(apiConfig);
this.api = new generated_1.ApiApi(apiConfig);
}
/**
* Resets the state of the object by making an API call to the reset endpoint.
*
* @returns {Promise<void>} A promise that resolves when the reset operation is complete.
* @throws {Error} If there is an issue resetting the state.
*
* @example
* ```typescript
* await client.reset();
* ```
*/
async reset() {
return await this.api.reset();
}
// version
/**
* Returns the version of the Chroma API.
* @returns {Promise<string>} A promise that resolves to the version of the Chroma API.
*
* @example
* ```typescript
* const version = await client.version();
* ```
*/
async version() {
const response = await this.api.version();
return response.data;
return await handleSuccess(response);
}
// heartbeat
/**
* Returns a heartbeat from the Chroma API.
* @returns {Promise<number>} A promise that resolves to the heartbeat from the Chroma API.
*
* @example
* ```typescript
* const heartbeat = await client.heartbeat();
* ```
*/
async heartbeat() {
const response = await this.api.heartbeat();
return response.data["nanosecond heartbeat"];
let ret = await handleSuccess(response);
return ret["nanosecond heartbeat"];
}
async createCollection(name, metadata, embeddingFunction) {
const newCollection = await this.api.createCollection({
createCollection: { name, metadata },
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
/**
* @ignore
*/
async persist() {
throw new Error("Not implemented in JS client");
}
/**
* Creates a new collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the created collection.
* @throws {Error} If there is an issue creating the collection.
*
* @example
* ```typescript
* const collection = await client.createCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
async createCollection({ name, metadata, embeddingFunction }) {
const newCollection = await this.api
.createCollection({
name,
metadata,
})
.then(handleSuccess)
.catch(handleError);
if (newCollection.error) {
throw new Error(newCollection.error);
}
return new Collection(name, this.api, embeddingFunction);
return new Collection(name, newCollection.id, this.api, metadata, embeddingFunction);
}
// 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;
});
/**
* Gets or creates a collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the got or created collection.
* @throws {Error} If there is an issue getting or creating the collection.
*
* @example
* ```typescript
* const collection = await client.getOrCreateCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
async getOrCreateCollection({ name, metadata, embeddingFunction }) {
const newCollection = await this.api
.createCollection({
name,
metadata,
'get_or_create': true
})
.then(handleSuccess)
.catch(handleError);
if (newCollection.error) {
throw new Error(newCollection.error);
}
return new Collection(name, this.api, embeddingFunction);
return new Collection(name, newCollection.id, this.api, newCollection.metadata, embeddingFunction);
}
/**
* Lists all collections.
*
* @returns {Promise<CollectionType[]>} A promise that resolves to a list of collection names.
* @throws {Error} If there is an issue listing the collections.
*
* @example
* ```typescript
* const collections = await client.listCollections();
* ```
*/
async listCollections() {
const response = await this.api.listCollections();
return response.data;
return handleSuccess(response);
}
async getCollection(name, embeddingFunction) {
return new Collection(name, this.api, embeddingFunction);
/**
* Gets a collection with the specified name.
* @param {Object} params - The parameters for getting a collection.
* @param {string} params.name - The name of the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
* @returns {Promise<Collection>} A promise that resolves to the collection.
* @throws {Error} If there is an issue getting the collection.
*
* @example
* ```typescript
* const collection = await client.getCollection({
* name: "my_collection"
* });
* ```
*/
async getCollection({ name, embeddingFunction }) {
const response = await this.api
.getCollection(name)
.then(handleSuccess)
.catch(handleError);
return new Collection(response.name, response.id, this.api, response.metadata, embeddingFunction);
}
async deleteCollection(name) {
const response = await this.api.deleteCollection({ collectionName: name }).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response;
/**
* Deletes a collection with the specified name.
* @param {Object} params - The parameters for deleting a collection.
* @param {string} params.name - The name of the collection.
* @returns {Promise<void>} A promise that resolves when the collection is deleted.
* @throws {Error} If there is an issue deleting the collection.
*
* @example
* ```typescript
* await client.deleteCollection({
* name: "my_collection"
* });
* ```
*/
async deleteCollection({ name }) {
return await this.api
.deleteCollection(name)
.then(handleSuccess)
.catch(handleError);
}

@@ -322,0 +715,0 @@ }

/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export * from './api/default-api';
import { Configuration } from "./configuration";
import { FetchAPI, FetchArgs, BaseAPI } from "./runtime";
import { Api } from "./models";
export type FactoryFunction<T> = (configuration?: Configuration, basePath?: string, fetch?: FetchAPI) => T;
/**
* ApiApi - fetch parameter creator
* @export
*/
export declare const ApiApiFetchParamCreator: (configuration?: Configuration) => {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options?: RequestInit): FetchArgs;
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options?: RequestInit): FetchArgs;
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options?: RequestInit): FetchArgs;
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options?: RequestInit): FetchArgs;
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options?: RequestInit): FetchArgs;
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: RequestInit): FetchArgs;
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options?: RequestInit): FetchArgs;
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options?: RequestInit): FetchArgs;
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options?: RequestInit): FetchArgs;
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options?: RequestInit): FetchArgs;
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options?: RequestInit): FetchArgs;
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit): FetchArgs;
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): FetchArgs;
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: RequestInit): FetchArgs;
};
/**
* ApiApi - functional programming interface
* @export
*/
export declare const ApiApiFp: (configuration?: Configuration) => {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Add201Response>;
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.ADelete200Response>;
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.AGet200Response>;
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Count200Response>;
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.CreateCollection200Response>;
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.CreateIndex200Response>;
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.DeleteCollection200Response>;
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.GetCollection200Response>;
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.GetNearestNeighbors200Response>;
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Heartbeat200Response>;
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.ListCollections200Response>;
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Persist200Response>;
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.RawSql200Response>;
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Reset200Response>;
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Root200Response>;
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Update200Response>;
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.UpdateCollection200Response>;
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Upsert200Response>;
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Version200Response>;
};
/**
* ApiApi - factory interface
* @export
*/
export declare const ApiApiFactory: FactoryFunction<ApiApi>;
/**
* ApiApi - object-oriented interface
* @export
* @class ApiApi
* @extends {BaseAPI}
*/
export declare class ApiApi extends BaseAPI {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): Promise<Api.Add201Response>;
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit): Promise<Api.ADelete200Response>;
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit): Promise<Api.AGet200Response>;
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options?: RequestInit): Promise<Api.Count200Response>;
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options?: RequestInit): Promise<Api.CreateCollection200Response>;
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options?: RequestInit): Promise<Api.CreateIndex200Response>;
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options?: RequestInit): Promise<Api.DeleteCollection200Response>;
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options?: RequestInit): Promise<Api.GetCollection200Response>;
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit): Promise<Api.GetNearestNeighbors200Response>;
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: RequestInit): Promise<Api.Heartbeat200Response>;
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options?: RequestInit): Promise<Api.ListCollections200Response>;
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options?: RequestInit): Promise<Api.Persist200Response>;
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options?: RequestInit): Promise<Api.RawSql200Response>;
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options?: RequestInit): Promise<Api.Reset200Response>;
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options?: RequestInit): Promise<Api.Root200Response>;
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit): Promise<Api.Update200Response>;
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit): Promise<Api.UpdateCollection200Response>;
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): Promise<Api.Upsert200Response>;
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: RequestInit): Promise<Api.Version200Response>;
}
//# sourceMappingURL=api.d.ts.map
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
apiKey?: string | ((name: string) => string | null);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
authorization?: string | ((name: string, scopes?: string[]) => string | null);
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
}

@@ -27,3 +25,3 @@ export declare class Configuration {

*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
apiKey?: string | ((name: string) => string | null);
/**

@@ -44,8 +42,8 @@ * parameter for basic security

/**
* parameter for oauth2 security
* parameter for oauth2, openIdConnect or http security
* @param name security name
* @param scopes oauth2 scope
* @param scopes oauth2 scopes
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
authorization?: string | ((name: string, scopes?: string[]) => string | null);
/**

@@ -58,30 +56,4 @@ * override base path

basePath?: string;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
constructor(param?: ConfigurationParameters);
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime: string): boolean;
}
//# sourceMappingURL=configuration.d.ts.map

@@ -1,12 +0,12 @@

/* tslint:disable */
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.

@@ -19,22 +19,6 @@ */

this.password = param.password;
this.accessToken = param.accessToken;
this.authorization = param.authorization;
this.basePath = param.basePath;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}
//# sourceMappingURL=configuration.js.map
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export * from "./api";
export * from "./models";
export * from "./configuration";
export * from "./models";
export { RequiredError } from "./runtime";
export type { FetchAPI, FetchArgs } from "./runtime";
//# sourceMappingURL=index.d.ts.map

@@ -1,17 +0,18 @@

/* tslint:disable */
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
* OpenAPI spec version: 0.1.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export * from "./api";
export * from "./models";
export * from "./configuration";
export * from "./models";
export { RequiredError } from "./runtime";
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import { GetEmbeddingIncludeEnum, QueryEmbeddingIncludeEnum } from "./generated";
import { DefaultApi } from "./generated/api";
import { IncludeEnum, Metadata, Metadatas, Embedding, Embeddings, Document, Documents, Where, WhereDocument, ID, IDs, PositiveInteger, CollectionType, GetResponse, QueryResponse } from "./types";
import { ApiApi as DefaultApi, Api } from "./generated";
export declare class OpenAIEmbeddingFunction {

@@ -7,3 +7,7 @@ private api_key;

private model;
constructor(openai_api_key: string, openai_model?: string, openai_organization_id?: string);
constructor({ openai_api_key, openai_model, openai_organization_id, }: {
openai_api_key: string;
openai_model?: string;
openai_organization_id?: string;
});
generate(texts: string[]): Promise<number[][]>;

@@ -13,3 +17,5 @@ }

private api_key;
constructor(cohere_api_key: string);
constructor({ cohere_api_key }: {
cohere_api_key: string;
});
generate(texts: string[]): Promise<any>;

@@ -22,28 +28,404 @@ }

name: string;
id: string;
metadata: Metadata | undefined;
/**
* @ignore
*/
private api;
/**
* @ignore
*/
embeddingFunction: CallableFunction | undefined;
constructor(name: string, api: DefaultApi, embeddingFunction?: CallableFunction);
add(ids: string | string[], embeddings: number[] | number[][] | undefined, metadatas?: object | object[], documents?: string | string[], increment_index?: boolean): Promise<any>;
count(): 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>;
createIndex(): Promise<import("axios").AxiosResponse<any, any>>;
delete(ids?: string[], where?: object): Promise<any>;
/**
* @ignore
*/
constructor(name: string, id: string, api: DefaultApi, metadata?: Metadata, embeddingFunction?: CallableFunction);
/**
* @ignore
*/
private setName;
/**
* @ignore
*/
private setMetadata;
/**
* @ignore
*/
private validate;
/**
* Add items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.add({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"]
* });
* ```
*/
add({ ids, embeddings, metadatas, documents, }: {
ids: ID | IDs;
embeddings?: Embedding | Embeddings;
metadatas?: Metadata | Metadatas;
documents?: Document | Documents;
}): Promise<boolean>;
/**
* Upsert items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.upsert({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"],
* });
* ```
*/
upsert({ ids, embeddings, metadatas, documents, }: {
ids: ID | IDs;
embeddings?: Embedding | Embeddings;
metadatas?: Metadata | Metadatas;
documents?: Document | Documents;
}): Promise<boolean>;
/**
* Count the number of items in the collection
* @returns {Promise<number>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.count();
* ```
*/
count(): Promise<number>;
/**
* Modify the collection name or metadata
* @param {Object} params - The parameters for the query.
* @param {string} [params.name] - Optional new name for the collection.
* @param {Metadata} [params.metadata] - Optional new metadata for the collection.
* @returns {Promise<void>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.modify({
* name: "new name",
* metadata: { "key": "value" },
* });
* ```
*/
modify({ name, metadata }?: {
name?: string;
metadata?: Metadata;
}): Promise<void>;
/**
* Get items from the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - Optional IDs of the items to get.
* @param {Where} [params.where] - Optional where clause to filter items by.
* @param {PositiveInteger} [params.limit] - Optional limit on the number of items to get.
* @param {PositiveInteger} [params.offset] - Optional offset on the items to get.
* @param {IncludeEnum[]} [params.include] - Optional list of items to include in the response.
* @param {WhereDocument} [params.where_document] - Optional where clause to filter items by.
* @returns {Promise<GetResponse>} - The response from the server.
*
* @example
* ```typescript
* const response = await collection.get({
* ids: ["id1", "id2"],
* where: { "key": "value" },
* limit: 10,
* offset: 0,
* include: ["embeddings", "metadatas", "documents"],
* where_document: { $contains: "value" },
* });
* ```
*/
get({ ids, where, limit, offset, include, where_document, }?: {
ids?: ID | IDs;
where?: Where;
limit?: PositiveInteger;
offset?: PositiveInteger;
include?: IncludeEnum[];
where_document?: WhereDocument;
}): Promise<GetResponse>;
/**
* Update the embeddings, documents, and/or metadatas of existing items
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - The IDs of the items to update.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings to update.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadatas to update.
* @param {Document | Documents} [params.documents] - Optional documents to update.
* @returns {Promise<APIResponse>} - The API Response.
*
* @example
* ```typescript
* const response = await collection.update({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["new document 1", "new document 2"],
* });
* ```
*/
update({ ids, embeddings, metadatas, documents, }: {
ids: ID | IDs;
embeddings?: Embedding | Embeddings;
metadatas?: Metadata | Metadatas;
documents?: Document | Documents;
}): Promise<any>;
/**
* Performs a query on the collection using the specified parameters.
*
* @param {Object} params - The parameters for the query.
* @param {Embedding | Embeddings} [params.query_embeddings] - Optional query embeddings to use for the search.
* @param {PositiveInteger} [params.n_results] - Optional number of results to return (default is 10).
* @param {Where} [params.where] - Optional query condition to filter results based on metadata values.
* @param {string | string[]} [params.query_text] - Optional query text(s) to search for in the collection (renamed to 'query_texts' in the future).
* @param {WhereDocument} [params.where_document] - Optional query condition to filter results based on document content.
* @param {IncludeEnum[]} [params.include] - Optional array of fields to include in the result, such as "metadata" and "document".
*
* @returns {Promise<QueryResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
* @example
* // Query the collection using embeddings
* const results = await collection.query({
* query_embeddings: [[0.1, 0.2, ...], ...],
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* @example
* ```js
* // Query the collection using query text
* const results = await collection.query({
* query_text: "some text",
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* ```
*
*/
query({ query_embeddings, n_results, where, query_text, where_document, include, }: {
query_embeddings?: Embedding | Embeddings;
n_results?: PositiveInteger;
where?: Where;
query_text?: string | string[];
where_document?: WhereDocument;
include?: IncludeEnum[];
}): Promise<QueryResponse>;
/**
* Peek inside the collection
* @param {Object} params - The parameters for the query.
* @param {PositiveInteger} [params.limit] - Optional number of results to return (default is 10).
* @returns {Promise<GetResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
*
* @example
* ```typescript
* const results = await collection.peek({
* limit: 10
* });
* ```
*/
peek({ limit }?: {
limit?: PositiveInteger;
}): Promise<GetResponse>;
/**
* Deletes items from the collection.
* @param {Object} params - The parameters for deleting items from the collection.
* @param {ID | IDs} [params.ids] - Optional ID or array of IDs of items to delete.
* @param {Where} [params.where] - Optional query condition to filter items to delete based on metadata values.
* @param {WhereDocument} [params.where_document] - Optional query condition to filter items to delete based on document content.
* @returns {Promise<string[]>} A promise that resolves to the IDs of the deleted items.
* @throws {Error} If there is an issue deleting items from the collection.
*
* @example
* ```typescript
* const results = await collection.delete({
* ids: "some_id",
* where: {"name": {"$eq": "John Doe"}},
* where_document: {"$contains":"search_string"}
* });
* ```
*/
delete({ ids, where, where_document }?: {
ids?: ID | IDs;
where?: Where;
where_document?: WhereDocument;
}): Promise<string[]>;
}
export declare class ChromaClient {
/**
* @ignore
*/
private api;
constructor(basePath?: string);
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>;
getCollection(name: string, embeddingFunction?: CallableFunction): Promise<Collection>;
deleteCollection(name: string): Promise<any>;
/**
* Creates a new ChromaClient instance.
* @param {Object} params - The parameters for creating a new client
* @param {string} [params.path] - The base path for the Chroma API.
* @returns {ChromaClient} A new ChromaClient instance.
*
* @example
* ```typescript
* const client = new ChromaClient({
* path: "http://localhost:8000"
* });
* ```
*/
constructor({ path }?: {
path?: string;
});
/**
* Resets the state of the object by making an API call to the reset endpoint.
*
* @returns {Promise<void>} A promise that resolves when the reset operation is complete.
* @throws {Error} If there is an issue resetting the state.
*
* @example
* ```typescript
* await client.reset();
* ```
*/
reset(): Promise<Api.Reset200Response>;
/**
* Returns the version of the Chroma API.
* @returns {Promise<string>} A promise that resolves to the version of the Chroma API.
*
* @example
* ```typescript
* const version = await client.version();
* ```
*/
version(): Promise<string>;
/**
* Returns a heartbeat from the Chroma API.
* @returns {Promise<number>} A promise that resolves to the heartbeat from the Chroma API.
*
* @example
* ```typescript
* const heartbeat = await client.heartbeat();
* ```
*/
heartbeat(): Promise<number>;
/**
* @ignore
*/
persist(): Promise<never>;
/**
* Creates a new collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the created collection.
* @throws {Error} If there is an issue creating the collection.
*
* @example
* ```typescript
* const collection = await client.createCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
createCollection({ name, metadata, embeddingFunction }: {
name: string;
metadata?: Metadata;
embeddingFunction?: CallableFunction;
}): Promise<Collection>;
/**
* Gets or creates a collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the got or created collection.
* @throws {Error} If there is an issue getting or creating the collection.
*
* @example
* ```typescript
* const collection = await client.getOrCreateCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
getOrCreateCollection({ name, metadata, embeddingFunction }: {
name: string;
metadata?: Metadata;
embeddingFunction?: CallableFunction;
}): Promise<Collection>;
/**
* Lists all collections.
*
* @returns {Promise<CollectionType[]>} A promise that resolves to a list of collection names.
* @throws {Error} If there is an issue listing the collections.
*
* @example
* ```typescript
* const collections = await client.listCollections();
* ```
*/
listCollections(): Promise<CollectionType[]>;
/**
* Gets a collection with the specified name.
* @param {Object} params - The parameters for getting a collection.
* @param {string} params.name - The name of the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
* @returns {Promise<Collection>} A promise that resolves to the collection.
* @throws {Error} If there is an issue getting the collection.
*
* @example
* ```typescript
* const collection = await client.getCollection({
* name: "my_collection"
* });
* ```
*/
getCollection({ name, embeddingFunction }: {
name: string;
embeddingFunction?: CallableFunction;
}): Promise<Collection>;
/**
* Deletes a collection with the specified name.
* @param {Object} params - The parameters for deleting a collection.
* @param {string} params.name - The name of the collection.
* @returns {Promise<void>} A promise that resolves when the collection is deleted.
* @throws {Error} If there is an issue deleting the collection.
*
* @example
* ```typescript
* await client.deleteCollection({
* name: "my_collection"
* });
* ```
*/
deleteCollection({ name }: {
name: string;
}): Promise<void>;
}
export {};
//# sourceMappingURL=index.d.ts.map

@@ -1,3 +0,2 @@

import { DefaultApi } from "./generated/api";
import { Configuration } from "./generated/configuration";
import { Configuration, ApiApi as DefaultApi } from "./generated";
// a function to convert a non-Array object to an Array

@@ -21,2 +20,46 @@ function toArray(obj) {

}
// we need to override constructors to make it work with jest
// https://stackoverflow.com/questions/76007003/jest-tobeinstanceof-expected-constructor-array-received-constructor-array
function repack(value) {
if (Boolean(value) && typeof value === "object") {
if (Array.isArray(value)) {
return new Array(...value);
}
else {
return Object.assign({}, value);
}
}
else {
return value;
}
}
async function handleError(error) {
if (error instanceof Response) {
try {
const res = await error.json();
if ("error" in res) {
return { error: res.error };
}
}
catch (e) {
return {
//@ts-ignore
error: e && typeof e === "object" && "message" in e
? e.message
: "unknown error",
};
}
}
return { error };
}
async function handleSuccess(response) {
switch (true) {
case response instanceof Response:
return repack(await response.json());
case typeof response === "string":
return repack(response); // currently version is the only thing that return non-JSON
default:
return repack(response);
}
}
class EmbeddingFunction {

@@ -26,3 +69,3 @@ }

export class OpenAIEmbeddingFunction {
constructor(openai_api_key, openai_model, openai_organization_id) {
constructor({ openai_api_key, openai_model, openai_organization_id, }) {
try {

@@ -47,8 +90,8 @@ // eslint-disable-next-line global-require,import/no-extraneous-dependencies

const response = await openai.createEmbedding({
model: "text-embedding-ada-002",
model: this.model,
input: texts,
});
const data = response.data['data'];
const data = response.data["data"];
for (let i = 0; i < data.length; i += 1) {
embeddings.push(data[i]['embedding']);
embeddings.push(data[i]["embedding"]);
}

@@ -60,3 +103,3 @@ return embeddings;

export class CohereEmbeddingFunction {
constructor(cohere_api_key) {
constructor({ cohere_api_key }) {
try {

@@ -81,4 +124,9 @@ // eslint-disable-next-line global-require,import/no-extraneous-dependencies

export class Collection {
constructor(name, api, embeddingFunction) {
/**
* @ignore
*/
constructor(name, id, api, metadata, embeddingFunction) {
this.name = name;
this.id = id;
this.metadata = metadata;
this.api = api;

@@ -88,7 +136,25 @@ if (embeddingFunction !== undefined)

}
async add(ids, embeddings, metadatas, documents, increment_index = true) {
if ((embeddings === undefined) && (documents === undefined)) {
throw new Error("embeddings and documents cannot both be undefined");
/**
* @ignore
*/
setName(name) {
this.name = name;
}
/**
* @ignore
*/
setMetadata(metadata) {
this.metadata = metadata;
}
/**
* @ignore
*/
async validate(require_embeddings_or_documents, // set to false in the case of Update
ids, embeddings, metadatas, documents) {
if (require_embeddings_or_documents) {
if ((embeddings === undefined) && (documents === undefined)) {
throw new Error("embeddings and documents cannot both be undefined");
}
}
else if ((embeddings === undefined) && (documents !== undefined)) {
if ((embeddings === undefined) && (documents !== undefined)) {
const documentsArray = toArray(documents);

@@ -120,53 +186,194 @@ if (this.embeddingFunction !== undefined) {

}
if (((embeddingsArray !== undefined) && idsArray.length !== embeddingsArray.length) ||
((metadatasArray !== undefined) && idsArray.length !== metadatasArray.length) ||
((documentsArray !== undefined) && idsArray.length !== documentsArray.length)) {
// validate all ids are strings
for (let i = 0; i < idsArray.length; i += 1) {
if (typeof idsArray[i] !== "string") {
throw new Error(`Expected ids to be strings, found ${typeof idsArray[i]} at index ${i}`);
}
}
if ((embeddingsArray !== undefined &&
idsArray.length !== embeddingsArray.length) ||
(metadatasArray !== undefined &&
idsArray.length !== metadatasArray.length) ||
(documentsArray !== undefined &&
idsArray.length !== documentsArray.length)) {
throw new Error("ids, embeddings, metadatas, and documents must all be the same length");
}
const response = await this.api.add({
collectionName: this.name,
addEmbedding: {
ids: idsArray,
embeddings: embeddingsArray,
documents: documentsArray,
metadatas: metadatasArray,
increment_index: increment_index,
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
const uniqueIds = new Set(idsArray);
if (uniqueIds.size !== idsArray.length) {
const duplicateIds = idsArray.filter((item, index) => idsArray.indexOf(item) !== index);
throw new Error(`Expected IDs to be unique, found duplicates for: ${duplicateIds}`);
}
return [idsArray, embeddingsArray, metadatasArray, documentsArray];
}
/**
* Add items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.add({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"]
* });
* ```
*/
async add({ ids, embeddings, metadatas, documents, }) {
const [idsArray, embeddingsArray, metadatasArray, documentsArray] = await this.validate(true, ids, embeddings, metadatas, documents);
const response = await this.api.add(this.id, {
// @ts-ignore
ids: idsArray,
embeddings: embeddingsArray,
// @ts-ignore
documents: documentsArray,
metadatas: metadatasArray,
})
.then(handleSuccess)
.catch(handleError);
return response;
}
/**
* Upsert items to the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - IDs of the items to add.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings of the items to add.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadata of the items to add.
* @param {Document | Documents} [params.documents] - Optional documents of the items to add.
* @returns {Promise<boolean>} - The response from the API. True if successful.
*
* @example
* ```typescript
* const response = await collection.upsert({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["document1", "document2"],
* });
* ```
*/
async upsert({ ids, embeddings, metadatas, documents, }) {
const [idsArray, embeddingsArray, metadatasArray, documentsArray] = await this.validate(true, ids, embeddings, metadatas, documents);
const response = await this.api.upsert(this.id, {
//@ts-ignore
ids: idsArray,
embeddings: embeddingsArray,
//@ts-ignore
documents: documentsArray,
metadatas: metadatasArray,
})
.then(handleSuccess)
.catch(handleError);
return response;
}
/**
* Count the number of items in the collection
* @returns {Promise<number>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.count();
* ```
*/
async count() {
const response = await this.api.count({ collectionName: this.name });
return response.data;
const response = await this.api.count(this.id);
return handleSuccess(response);
}
async get(ids, where, limit, offset, include, where_document) {
/**
* Modify the collection name or metadata
* @param {Object} params - The parameters for the query.
* @param {string} [params.name] - Optional new name for the collection.
* @param {Metadata} [params.metadata] - Optional new metadata for the collection.
* @returns {Promise<void>} - The response from the API.
*
* @example
* ```typescript
* const response = await collection.modify({
* name: "new name",
* metadata: { "key": "value" },
* });
* ```
*/
async modify({ name, metadata } = {}) {
const response = await this.api
.updateCollection(this.id, {
new_name: name,
new_metadata: metadata,
})
.then(handleSuccess)
.catch(handleError);
this.setName(name || this.name);
this.setMetadata(metadata || this.metadata);
return response;
}
/**
* Get items from the collection
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - Optional IDs of the items to get.
* @param {Where} [params.where] - Optional where clause to filter items by.
* @param {PositiveInteger} [params.limit] - Optional limit on the number of items to get.
* @param {PositiveInteger} [params.offset] - Optional offset on the items to get.
* @param {IncludeEnum[]} [params.include] - Optional list of items to include in the response.
* @param {WhereDocument} [params.where_document] - Optional where clause to filter items by.
* @returns {Promise<GetResponse>} - The response from the server.
*
* @example
* ```typescript
* const response = await collection.get({
* ids: ["id1", "id2"],
* where: { "key": "value" },
* limit: 10,
* offset: 0,
* include: ["embeddings", "metadatas", "documents"],
* where_document: { $contains: "value" },
* });
* ```
*/
async get({ ids, where, limit, offset, include, where_document, } = {}) {
let idsArray = undefined;
if (ids !== undefined)
idsArray = toArray(ids);
var resp = await this.api.get({
collectionName: this.name,
getEmbedding: {
ids: idsArray,
where,
limit,
offset,
include,
where_document,
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return resp;
return await this.api
.aGet(this.id, {
ids: idsArray,
where,
limit,
offset,
include,
where_document,
})
.then(handleSuccess)
.catch(handleError);
}
async update(ids, embeddings, metadatas, documents) {
if ((embeddings === undefined) && (documents === undefined) && (metadatas === undefined)) {
/**
* Update the embeddings, documents, and/or metadatas of existing items
* @param {Object} params - The parameters for the query.
* @param {ID | IDs} [params.ids] - The IDs of the items to update.
* @param {Embedding | Embeddings} [params.embeddings] - Optional embeddings to update.
* @param {Metadata | Metadatas} [params.metadatas] - Optional metadatas to update.
* @param {Document | Documents} [params.documents] - Optional documents to update.
* @returns {Promise<APIResponse>} - The API Response.
*
* @example
* ```typescript
* const response = await collection.update({
* ids: ["id1", "id2"],
* embeddings: [[1, 2, 3], [4, 5, 6]],
* metadatas: [{ "key": "value" }, { "key": "value" }],
* documents: ["new document 1", "new document 2"],
* });
* ```
*/
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)) {
else if (embeddings === undefined && documents !== undefined) {
const documentsArray = toArray(documents);

@@ -180,23 +387,55 @@ if (this.embeddingFunction !== undefined) {

}
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;
});
if (metadatas !== undefined)
metadatas = toArray(metadatas);
var resp = await this.api
.update(this.id, {
ids: toArray(ids),
embeddings: embeddings ? toArrayOfArrays(embeddings) : undefined,
documents: documents,
metadatas: metadatas
})
.then(handleSuccess)
.catch(handleError);
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)) {
/**
* Performs a query on the collection using the specified parameters.
*
* @param {Object} params - The parameters for the query.
* @param {Embedding | Embeddings} [params.query_embeddings] - Optional query embeddings to use for the search.
* @param {PositiveInteger} [params.n_results] - Optional number of results to return (default is 10).
* @param {Where} [params.where] - Optional query condition to filter results based on metadata values.
* @param {string | string[]} [params.query_text] - Optional query text(s) to search for in the collection (renamed to 'query_texts' in the future).
* @param {WhereDocument} [params.where_document] - Optional query condition to filter results based on document content.
* @param {IncludeEnum[]} [params.include] - Optional array of fields to include in the result, such as "metadata" and "document".
*
* @returns {Promise<QueryResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
* @example
* // Query the collection using embeddings
* const results = await collection.query({
* query_embeddings: [[0.1, 0.2, ...], ...],
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* @example
* ```js
* // Query the collection using query text
* const results = await collection.query({
* query_text: "some text",
* n_results: 10,
* where: {"name": {"$eq": "John Doe"}},
* include: ["metadata", "document"]
* });
* ```
*
*/
async query({ query_embeddings, n_results, where, query_text, where_document, include, }) {
if (n_results === undefined)
n_results = 10;
if (query_embeddings === undefined && query_text === undefined) {
throw new Error("query_embeddings and query_text cannot both be undefined");
}
else if ((query_embeddings === undefined) && (query_text !== undefined)) {
else if (query_embeddings === undefined && query_text !== undefined) {
const query_texts = toArray(query_text);

@@ -213,105 +452,259 @@ if (this.embeddingFunction !== undefined) {

const query_embeddingsArray = toArrayOfArrays(query_embeddings);
const response = await this.api.getNearestNeighbors({
collectionName: this.name,
queryEmbedding: {
query_embeddings: query_embeddingsArray,
where,
n_results,
where_document: where_document,
include: include
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response;
return await this.api
.getNearestNeighbors(this.id, {
query_embeddings: query_embeddingsArray,
where,
n_results: n_results,
where_document: where_document,
include: include,
})
.then(handleSuccess)
.catch(handleError);
}
async peek(limit = 10) {
const response = await this.api.get({
collectionName: this.name,
getEmbedding: { limit: limit },
/**
* Peek inside the collection
* @param {Object} params - The parameters for the query.
* @param {PositiveInteger} [params.limit] - Optional number of results to return (default is 10).
* @returns {Promise<GetResponse>} A promise that resolves to the query results.
* @throws {Error} If there is an issue executing the query.
*
* @example
* ```typescript
* const results = await collection.peek({
* limit: 10
* });
* ```
*/
async peek({ limit } = {}) {
if (limit === undefined)
limit = 10;
const response = await this.api.aGet(this.id, {
limit: limit,
});
return response.data;
return handleSuccess(response);
}
async createIndex() {
return await this.api.createIndex({ collectionName: this.name });
/**
* Deletes items from the collection.
* @param {Object} params - The parameters for deleting items from the collection.
* @param {ID | IDs} [params.ids] - Optional ID or array of IDs of items to delete.
* @param {Where} [params.where] - Optional query condition to filter items to delete based on metadata values.
* @param {WhereDocument} [params.where_document] - Optional query condition to filter items to delete based on document content.
* @returns {Promise<string[]>} A promise that resolves to the IDs of the deleted items.
* @throws {Error} If there is an issue deleting items from the collection.
*
* @example
* ```typescript
* const results = await collection.delete({
* ids: "some_id",
* where: {"name": {"$eq": "John Doe"}},
* where_document: {"$contains":"search_string"}
* });
* ```
*/
async delete({ ids, where, where_document } = {}) {
let idsArray = undefined;
if (ids !== undefined)
idsArray = toArray(ids);
return await this.api
.aDelete(this.id, { ids: idsArray, where: where, where_document: where_document })
.then(handleSuccess)
.catch(handleError);
}
async delete(ids, where) {
var response = await this.api._delete({
collectionName: this.name,
deleteEmbedding: { ids: ids, where: where },
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response;
}
}
export class ChromaClient {
constructor(basePath) {
if (basePath === undefined)
basePath = "http://localhost:8000";
/**
* Creates a new ChromaClient instance.
* @param {Object} params - The parameters for creating a new client
* @param {string} [params.path] - The base path for the Chroma API.
* @returns {ChromaClient} A new ChromaClient instance.
*
* @example
* ```typescript
* const client = new ChromaClient({
* path: "http://localhost:8000"
* });
* ```
*/
constructor({ path } = {}) {
if (path === undefined)
path = "http://localhost:8000";
const apiConfig = new Configuration({
basePath,
basePath: path,
});
this.api = new DefaultApi(apiConfig);
}
/**
* Resets the state of the object by making an API call to the reset endpoint.
*
* @returns {Promise<void>} A promise that resolves when the reset operation is complete.
* @throws {Error} If there is an issue resetting the state.
*
* @example
* ```typescript
* await client.reset();
* ```
*/
async reset() {
return await this.api.reset();
}
// version
/**
* Returns the version of the Chroma API.
* @returns {Promise<string>} A promise that resolves to the version of the Chroma API.
*
* @example
* ```typescript
* const version = await client.version();
* ```
*/
async version() {
const response = await this.api.version();
return response.data;
return await handleSuccess(response);
}
// heartbeat
/**
* Returns a heartbeat from the Chroma API.
* @returns {Promise<number>} A promise that resolves to the heartbeat from the Chroma API.
*
* @example
* ```typescript
* const heartbeat = await client.heartbeat();
* ```
*/
async heartbeat() {
const response = await this.api.heartbeat();
return response.data["nanosecond heartbeat"];
let ret = await handleSuccess(response);
return ret["nanosecond heartbeat"];
}
async createCollection(name, metadata, embeddingFunction) {
const newCollection = await this.api.createCollection({
createCollection: { name, metadata },
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
/**
* @ignore
*/
async persist() {
throw new Error("Not implemented in JS client");
}
/**
* Creates a new collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the created collection.
* @throws {Error} If there is an issue creating the collection.
*
* @example
* ```typescript
* const collection = await client.createCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
async createCollection({ name, metadata, embeddingFunction }) {
const newCollection = await this.api
.createCollection({
name,
metadata,
})
.then(handleSuccess)
.catch(handleError);
if (newCollection.error) {
throw new Error(newCollection.error);
}
return new Collection(name, this.api, embeddingFunction);
return new Collection(name, newCollection.id, this.api, metadata, embeddingFunction);
}
// 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;
});
/**
* Gets or creates a collection with the specified properties.
*
* @param {Object} params - The parameters for creating a new collection.
* @param {string} params.name - The name of the collection.
* @param {Metadata} [params.metadata] - Optional metadata associated with the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
*
* @returns {Promise<Collection>} A promise that resolves to the got or created collection.
* @throws {Error} If there is an issue getting or creating the collection.
*
* @example
* ```typescript
* const collection = await client.getOrCreateCollection({
* name: "my_collection",
* metadata: {
* "description": "My first collection"
* }
* });
* ```
*/
async getOrCreateCollection({ name, metadata, embeddingFunction }) {
const newCollection = await this.api
.createCollection({
name,
metadata,
'get_or_create': true
})
.then(handleSuccess)
.catch(handleError);
if (newCollection.error) {
throw new Error(newCollection.error);
}
return new Collection(name, this.api, embeddingFunction);
return new Collection(name, newCollection.id, this.api, newCollection.metadata, embeddingFunction);
}
/**
* Lists all collections.
*
* @returns {Promise<CollectionType[]>} A promise that resolves to a list of collection names.
* @throws {Error} If there is an issue listing the collections.
*
* @example
* ```typescript
* const collections = await client.listCollections();
* ```
*/
async listCollections() {
const response = await this.api.listCollections();
return response.data;
return handleSuccess(response);
}
async getCollection(name, embeddingFunction) {
return new Collection(name, this.api, embeddingFunction);
/**
* Gets a collection with the specified name.
* @param {Object} params - The parameters for getting a collection.
* @param {string} params.name - The name of the collection.
* @param {CallableFunction} [params.embeddingFunction] - Optional custom embedding function for the collection.
* @returns {Promise<Collection>} A promise that resolves to the collection.
* @throws {Error} If there is an issue getting the collection.
*
* @example
* ```typescript
* const collection = await client.getCollection({
* name: "my_collection"
* });
* ```
*/
async getCollection({ name, embeddingFunction }) {
const response = await this.api
.getCollection(name)
.then(handleSuccess)
.catch(handleError);
return new Collection(response.name, response.id, this.api, response.metadata, embeddingFunction);
}
async deleteCollection(name) {
const response = await this.api.deleteCollection({ collectionName: name }).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response;
/**
* Deletes a collection with the specified name.
* @param {Object} params - The parameters for deleting a collection.
* @param {string} params.name - The name of the collection.
* @returns {Promise<void>} A promise that resolves when the collection is deleted.
* @throws {Error} If there is an issue deleting the collection.
*
* @example
* ```typescript
* await client.deleteCollection({
* name: "my_collection"
* });
* ```
*/
async deleteCollection({ name }) {
return await this.api
.deleteCollection(name)
.then(handleSuccess)
.catch(handleError);
}
}
//# sourceMappingURL=index.js.map
{
"name": "chromadb",
"version": "1.4.1",
"version": "1.4.2",
"description": "A JavaScript interface for chroma",

@@ -9,15 +9,14 @@ "keywords": [],

"devDependencies": {
"@openapitools/openapi-generator-cli": "^2.5.2",
"@types/jest": "^29.4.0",
"jest": "^29.4.3",
"@types/jest": "^29.5.0",
"jest": "^29.5.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"ts-jest": "^29.0.5",
"openapi-generator-plus": "^2.6.0",
"@openapi-generator-plus/typescript-fetch-client-generator": "^1.5.0",
"prettier": "2.8.7",
"rimraf": "^5.0.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsd": "^0.24.1",
"typescript": "^4.5.5"
"tsd": "^0.28.1",
"typescript": "^5.0.4"
},
"dependencies": {
"axios": "^0.26.0"
},
"main": "dist/main/index.js",

@@ -35,4 +34,4 @@ "module": "dist/module/index.js",

"test:update": "run-s db:clean db:run && jest --runInBand --updateSnapshot && run-s db:clean",
"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",
"db:clean": "cd ../.. && CHROMA_PORT=8001 docker-compose -f docker-compose.test.yml down --volumes",
"db:run": "cd ../.. && CHROMA_PORT=8001 docker-compose -f docker-compose.test.yml up --detach && sleep 5",
"clean": "rimraf dist",

@@ -42,5 +41,5 @@ "build": "run-s clean build:*",

"build:module": "tsc -p tsconfig.module.json",
"genapi-bash": "openapi-generator-cli generate -i <(curl -s 'http://localhost:8000/openapi.json') -g typescript-axios -o src/generated -p withSeparateModelsAndApi=true,apiPackage=api,modelPackage=models,useSingleRequestParameter=true",
"genapi-zsh": "mkfifo openapi.json; (curl -s 'http://localhost:8000/openapi.json' > openapi.json &) && openapi-generator-cli generate -i openapi.json -g typescript-axios -o src/generated --additional-properties 'withSeparateModelsAndApi=true,apiPackage=api,modelPackage=models,useSingleRequestParameter=true,withNodeImports=true,npmName=chromadb'; rm openapi.json"
"genapi": "./genapi.sh",
"prettier": "prettier --write ."
}
}
}

@@ -5,3 +5,3 @@ ## chromadb

This package gives you a JS/TS interface to talk to a backend Chroma DB over REST.
This package gives you a JS/TS interface to talk to a backend Chroma DB over REST.

@@ -17,19 +17,16 @@ [Learn more about Chroma](https://github.com/chroma-core/chroma)

Chroma needs to be running in order for this client to talk to it. Please see the [🧪 Usage Guide](https://docs.trychroma.com/usage-guide) to learn how to quickly stand this up.
Chroma needs to be running in order for this client to talk to it. Please see the [🧪 Usage Guide](https://docs.trychroma.com/usage-guide) to learn how to quickly stand this up.
## Small example
```js
import { ChromaClient } from "chromadb"
import { ChromaClient } from "chromadb";
const chroma = new ChromaClient("http://localhost:8000");
const collection = await chroma.createCollection("test-from-js");
for (let i = 0; i < 20; i++) {
await collection.add(
"test-id-" + i.toString(),
[1, 2, 3, 4, 5],
{ "test": "test" }
)
await collection.add("test-id-" + i.toString(), [1, 2, 3, 4, 5], {
test: "test",
});
}
const queryData = await collection.query([1, 2, 3, 4, 5], 5, { "test": "test" });
const queryData = await collection.query([1, 2, 3, 4, 5], 5, { test: "test" });
```

@@ -43,2 +40,2 @@

Apache 2.0
Apache 2.0

@@ -1,18 +0,1434 @@

/* tslint:disable */
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* OpenAPI spec version: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
import { Configuration } from "./configuration";
import { BASE_PATH, COLLECTION_FORMATS, FetchAPI, FetchArgs, BaseAPI, RequiredError, defaultFetch } from "./runtime";
import { Api } from "./models";
export type FactoryFunction<T> = (configuration?: Configuration, basePath?: string, fetch?: FetchAPI) => T;
export * from './api/default-api';
/**
* ApiApi - fetch parameter creator
* @export
*/
export const ApiApiFetchParamCreator = function (configuration?: Configuration) {
return {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling add.');
}
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling add.');
}
let localVarPath = `/api/v1/collections/{collection_id}/add`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling aDelete.');
}
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling aDelete.');
}
let localVarPath = `/api/v1/collections/{collection_id}/delete`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling aGet.');
}
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling aGet.');
}
let localVarPath = `/api/v1/collections/{collection_id}/get`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling count.');
}
let localVarPath = `/api/v1/collections/{collection_id}/count`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'GET' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options: RequestInit = {}): FetchArgs {
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling createCollection.');
}
let localVarPath = `/api/v1/collections`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionName' is not null or undefined
if (collectionName === null || collectionName === undefined) {
throw new RequiredError('collectionName', 'Required parameter collectionName was null or undefined when calling createIndex.');
}
let localVarPath = `/api/v1/collections/{collection_name}/create_index`
.replace('{collection_name}', encodeURIComponent(String(collectionName)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionName' is not null or undefined
if (collectionName === null || collectionName === undefined) {
throw new RequiredError('collectionName', 'Required parameter collectionName was null or undefined when calling deleteCollection.');
}
let localVarPath = `/api/v1/collections/{collection_name}`
.replace('{collection_name}', encodeURIComponent(String(collectionName)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'DELETE' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionName' is not null or undefined
if (collectionName === null || collectionName === undefined) {
throw new RequiredError('collectionName', 'Required parameter collectionName was null or undefined when calling getCollection.');
}
let localVarPath = `/api/v1/collections/{collection_name}`
.replace('{collection_name}', encodeURIComponent(String(collectionName)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'GET' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling getNearestNeighbors.');
}
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling getNearestNeighbors.');
}
let localVarPath = `/api/v1/collections/{collection_id}/query`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options: RequestInit = {}): FetchArgs {
let localVarPath = `/api/v1/heartbeat`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'GET' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options: RequestInit = {}): FetchArgs {
let localVarPath = `/api/v1/collections`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'GET' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options: RequestInit = {}): FetchArgs {
let localVarPath = `/api/v1/persist`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options: RequestInit = {}): FetchArgs {
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling rawSql.');
}
let localVarPath = `/api/v1/raw_sql`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options: RequestInit = {}): FetchArgs {
let localVarPath = `/api/v1/reset`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options: RequestInit = {}): FetchArgs {
let localVarPath = `/api/v1`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'GET' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling update.');
}
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling update.');
}
let localVarPath = `/api/v1/collections/{collection_id}/update`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling updateCollection.');
}
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling updateCollection.');
}
let localVarPath = `/api/v1/collections/{collection_id}`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'PUT' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options: RequestInit = {}): FetchArgs {
// verify required parameter 'collectionId' is not null or undefined
if (collectionId === null || collectionId === undefined) {
throw new RequiredError('collectionId', 'Required parameter collectionId was null or undefined when calling upsert.');
}
// verify required parameter 'request' is not null or undefined
if (request === null || request === undefined) {
throw new RequiredError('request', 'Required parameter request was null or undefined when calling upsert.');
}
let localVarPath = `/api/v1/collections/{collection_id}/upsert`
.replace('{collection_id}', encodeURIComponent(String(collectionId)));
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'POST' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options: RequestInit = {}): FetchArgs {
let localVarPath = `/api/v1/version`;
const localVarPathQueryStart = localVarPath.indexOf("?");
const localVarRequestOptions: RequestInit = Object.assign({ method: 'GET' }, options);
const localVarHeaderParameter: Headers = options.headers ? new Headers(options.headers) : new Headers();
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
if (localVarPathQueryStart !== -1) {
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
}
localVarRequestOptions.headers = localVarHeaderParameter;
const localVarQueryParameterString = localVarQueryParameter.toString();
if (localVarQueryParameterString) {
localVarPath += "?" + localVarQueryParameterString;
}
return {
url: localVarPath,
options: localVarRequestOptions,
};
},
}
};
/**
* ApiApi - functional programming interface
* @export
*/
export const ApiApiFp = function(configuration?: Configuration) {
return {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Add201Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).add(collectionId, request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 201) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.ADelete200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).aDelete(collectionId, request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.AGet200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).aGet(collectionId, request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
count(collectionId: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Count200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).count(collectionId, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createCollection(request: Api.CreateCollection, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.CreateCollection200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createCollection(request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
createIndex(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.CreateIndex200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createIndex(collectionName, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
deleteCollection(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.DeleteCollection200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getCollection(collectionName: string, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.GetCollection200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getCollection(collectionName, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.GetNearestNeighbors200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getNearestNeighbors(collectionId, request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Heartbeat200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).heartbeat(options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
throw response;
});
};
},
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
listCollections(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.ListCollections200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).listCollections(options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
persist(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Persist200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).persist(options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
rawSql(request: Api.RawSql, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.RawSql200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).rawSql(request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
reset(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Reset200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).reset(options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
root(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Root200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).root(options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Update200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).update(collectionId, request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.UpdateCollection200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).updateCollection(collectionId, request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Upsert200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).upsert(collectionId, request, options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
if (response.status === 422) {
if (mimeType === 'application/json') {
throw response;
}
throw response;
}
throw response;
});
};
},
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: RequestInit): (fetch?: FetchAPI, basePath?: string) => Promise<Api.Version200Response> {
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).version(options);
return (fetch: FetchAPI = defaultFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
}
throw response;
}
throw response;
});
};
},
}
};
/**
* ApiApi - factory interface
* @export
*/
export const ApiApiFactory: FactoryFunction<ApiApi> = function (configuration?: Configuration, basePath?: string, fetch?: FetchAPI) {
return new ApiApi(configuration, basePath, fetch);
};
/**
* ApiApi - object-oriented interface
* @export
* @class ApiApi
* @extends {BaseAPI}
*/
export class ApiApi extends BaseAPI {
/**
* @summary Add
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public add(collectionId: string, request: Api.AddEmbedding, options?: RequestInit) {
return ApiApiFp(this.configuration).add(collectionId, request, options)(this.fetch, this.basePath);
}
/**
* @summary Delete
* @param {string} collectionId
* @param {Api.DeleteEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public aDelete(collectionId: string, request: Api.DeleteEmbedding, options?: RequestInit) {
return ApiApiFp(this.configuration).aDelete(collectionId, request, options)(this.fetch, this.basePath);
}
/**
* @summary Get
* @param {string} collectionId
* @param {Api.GetEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public aGet(collectionId: string, request: Api.GetEmbedding, options?: RequestInit) {
return ApiApiFp(this.configuration).aGet(collectionId, request, options)(this.fetch, this.basePath);
}
/**
* @summary Count
* @param {string} collectionId
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public count(collectionId: string, options?: RequestInit) {
return ApiApiFp(this.configuration).count(collectionId, options)(this.fetch, this.basePath);
}
/**
* @summary Create Collection
* @param {Api.CreateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public createCollection(request: Api.CreateCollection, options?: RequestInit) {
return ApiApiFp(this.configuration).createCollection(request, options)(this.fetch, this.basePath);
}
/**
* @summary Create Index
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public createIndex(collectionName: string, options?: RequestInit) {
return ApiApiFp(this.configuration).createIndex(collectionName, options)(this.fetch, this.basePath);
}
/**
* @summary Delete Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public deleteCollection(collectionName: string, options?: RequestInit) {
return ApiApiFp(this.configuration).deleteCollection(collectionName, options)(this.fetch, this.basePath);
}
/**
* @summary Get Collection
* @param {string} collectionName
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public getCollection(collectionName: string, options?: RequestInit) {
return ApiApiFp(this.configuration).getCollection(collectionName, options)(this.fetch, this.basePath);
}
/**
* @summary Get Nearest Neighbors
* @param {string} collectionId
* @param {Api.QueryEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public getNearestNeighbors(collectionId: string, request: Api.QueryEmbedding, options?: RequestInit) {
return ApiApiFp(this.configuration).getNearestNeighbors(collectionId, request, options)(this.fetch, this.basePath);
}
/**
* @summary Heartbeat
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public heartbeat(options?: RequestInit) {
return ApiApiFp(this.configuration).heartbeat(options)(this.fetch, this.basePath);
}
/**
* @summary List Collections
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public listCollections(options?: RequestInit) {
return ApiApiFp(this.configuration).listCollections(options)(this.fetch, this.basePath);
}
/**
* @summary Persist
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public persist(options?: RequestInit) {
return ApiApiFp(this.configuration).persist(options)(this.fetch, this.basePath);
}
/**
* @summary Raw Sql
* @param {Api.RawSql} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public rawSql(request: Api.RawSql, options?: RequestInit) {
return ApiApiFp(this.configuration).rawSql(request, options)(this.fetch, this.basePath);
}
/**
* @summary Reset
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public reset(options?: RequestInit) {
return ApiApiFp(this.configuration).reset(options)(this.fetch, this.basePath);
}
/**
* @summary Root
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public root(options?: RequestInit) {
return ApiApiFp(this.configuration).root(options)(this.fetch, this.basePath);
}
/**
* @summary Update
* @param {string} collectionId
* @param {Api.UpdateEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public update(collectionId: string, request: Api.UpdateEmbedding, options?: RequestInit) {
return ApiApiFp(this.configuration).update(collectionId, request, options)(this.fetch, this.basePath);
}
/**
* @summary Update Collection
* @param {string} collectionId
* @param {Api.UpdateCollection} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public updateCollection(collectionId: string, request: Api.UpdateCollection, options?: RequestInit) {
return ApiApiFp(this.configuration).updateCollection(collectionId, request, options)(this.fetch, this.basePath);
}
/**
* @summary Upsert
* @param {string} collectionId
* @param {Api.AddEmbedding} request
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public upsert(collectionId: string, request: Api.AddEmbedding, options?: RequestInit) {
return ApiApiFp(this.configuration).upsert(collectionId, request, options)(this.fetch, this.basePath);
}
/**
* @summary Version
* @param {RequestInit} [options] Override http request option.
* @throws {RequiredError}
*/
public version(options?: RequestInit) {
return ApiApiFp(this.configuration).version(options)(this.fetch, this.basePath);
}
}
/**
* We sometimes represent dates as strings (in models) and as Dates (in parameters) so this
* function converts them both to a string.
*/
function dateToString(value: Date | string | undefined): string | undefined {
if (value instanceof Date) {
return value.toISOString();
} else if (typeof value === 'string') {
return value;
} else {
return undefined;
}
}

@@ -1,101 +0,66 @@

/* tslint:disable */
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* OpenAPI spec version: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
apiKey?: string | ((name: string) => string | null);
username?: string;
password?: string;
authorization?: string | ((name: string, scopes?: string[]) => string | null);
basePath?: string;
}
export class Configuration {
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: string | ((name: string) => string | null);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2, openIdConnect or http security
* @param name security name
* @param scopes oauth2 scopes
* @memberof Configuration
*/
authorization?: string | ((name: string, scopes?: string[]) => string | null);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.authorization = param.authorization;
this.basePath = param.basePath;
}
}

@@ -1,18 +0,19 @@

/* tslint:disable */
/* eslint-disable */
// tslint:disable
/**
* FastAPI
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* OpenAPI spec version: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
* Do not edit the class manually.
*/
export * from "./api";
export * from "./models";
export * from "./configuration";
export * from "./models";
export { RequiredError } from "./runtime";
export type { FetchAPI, FetchArgs } from "./runtime";

@@ -1,4 +0,4 @@

## chromadb@0.1.0
## API
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:

@@ -22,3 +22,3 @@ Environment

To build and compile the typescript sources to javascript use:
To build an compile the typescript sources to javascript use:
```

@@ -35,13 +35,6 @@ npm install

navigate to the folder of your consuming project and run one of the following commands.
Navigate to the folder of your consuming project and run one of the following commands:
_published:_
```shell
npm install PATH_TO_GENERATED_PACKAGE --save
```
npm install chromadb@0.1.0 --save
```
_unPublished (not recommended):_
```
npm install PATH_TO_GENERATED_PACKAGE --save

@@ -1,5 +0,6 @@

import { GetEmbeddingIncludeEnum, QueryEmbeddingIncludeEnum } from "./generated";
import { DefaultApi } from "./generated/api";
import { Configuration } from "./generated/configuration";
import axios from "axios"
import {
IncludeEnum,
} from "./types";
import { Configuration, ApiApi as DefaultApi, Api } from "./generated";
import Count200Response = Api.Count200Response;

@@ -24,2 +25,47 @@ // a function to convert a non-Array object to an Array

// we need to override constructors to make it work with jest
// https://stackoverflow.com/questions/76007003/jest-tobeinstanceof-expected-constructor-array-received-constructor-array
function repack(value: unknown): any {
if (Boolean(value) && typeof value === "object") {
if (Array.isArray(value)) {
return new Array(...value);
} else {
return { ...value };
}
} else {
return value;
}
}
async function handleError(error: unknown) {
if (error instanceof Response) {
try {
const res = await error.json();
if ("error" in res) {
return { error: res.error };
}
} catch (e: unknown) {
return {
//@ts-ignore
error:
e && typeof e === "object" && "message" in e
? e.message
: "unknown error",
};
}
}
return { error };
}
async function handleSuccess(response: Response | string | Count200Response) {
switch (true) {
case response instanceof Response:
return repack(await (response as Response).json());
case typeof response === "string":
return repack((response as string)); // currently version is the only thing that return non-JSON
default:
return repack(response);
}
}
class EmbeddingFunction { }

@@ -34,3 +80,7 @@

constructor(openai_api_key: string, openai_model?: string, openai_organization_id?: string) {
constructor(
openai_api_key: string,
openai_model?: string,
openai_organization_id?: string
) {
try {

@@ -41,3 +91,3 @@ // eslint-disable-next-line global-require,import/no-extraneous-dependencies

throw new Error(
"Please install the openai package to use the OpenAIEmbeddingFunction, `npm install -S openai`",
"Please install the openai package to use the OpenAIEmbeddingFunction, `npm install -S openai`"
);

@@ -58,8 +108,8 @@ }

const response = await openai.createEmbedding({
model: "text-embedding-ada-002",
model: this.model,
input: texts,
});
const data = response.data['data'];
const data = response.data["data"];
for (let i = 0; i < data.length; i += 1) {
embeddings.push(data[i]['embedding']);
embeddings.push(data[i]["embedding"]);
}

@@ -74,4 +124,5 @@ return embeddings;

private api_key: string;
private model: string;
constructor(cohere_api_key: string) {
constructor(cohere_api_key: string, model?: string) {
try {

@@ -82,6 +133,7 @@ // eslint-disable-next-line global-require,import/no-extraneous-dependencies

throw new Error(
"Please install the cohere-ai package to use the CohereEmbeddingFunction, `npm install -S cohere-ai`",
"Please install the cohere-ai package to use the CohereEmbeddingFunction, `npm install -S cohere-ai`"
);
}
this.api_key = cohere_api_key;
this.model = model || "large";
}

@@ -94,2 +146,3 @@

texts: texts,
model: this.model,
});

@@ -106,2 +159,3 @@ return response.body.embeddings;

public name: string;
public id: string;
public metadata: object | undefined;

@@ -111,4 +165,11 @@ private api: DefaultApi;

constructor(name: string, api: DefaultApi, metadata?: object, embeddingFunction?: CallableFunction) {
constructor(
name: string,
id: string,
api: DefaultApi,
metadata?: object,
embeddingFunction?: CallableFunction
) {
this.name = name;
this.id = id;
this.metadata = metadata;

@@ -127,3 +188,4 @@ this.api = api;

public async add(
private async validate(
require_embeddings_or_documents: boolean, // set to false in the case of Update
ids: string | string[],

@@ -133,19 +195,24 @@ embeddings: number[] | number[][] | undefined,

documents?: string | string[],
increment_index: boolean = true,
) {
if ((embeddings === undefined) && (documents === undefined)) {
throw new Error(
"embeddings and documents cannot both be undefined",
);
} else if ((embeddings === undefined) && (documents !== undefined)) {
if (require_embeddings_or_documents) {
if ((embeddings === undefined) && (documents === undefined)) {
throw new Error(
"embeddings and documents cannot both be undefined",
);
}
}
if ((embeddings === undefined) && (documents !== undefined)) {
const documentsArray = toArray(documents);
if (this.embeddingFunction !== undefined) {
embeddings = await this.embeddingFunction.generate(documentsArray)
embeddings = await this.embeddingFunction.generate(documentsArray);
} else {
throw new Error(
"embeddingFunction is undefined. Please configure an embedding function",
"embeddingFunction is undefined. Please configure an embedding function"
);
}
}
if (embeddings === undefined) throw new Error("embeddings is undefined but shouldnt be")
if (embeddings === undefined)
throw new Error("embeddings is undefined but shouldnt be");

@@ -157,3 +224,3 @@ const idsArray = toArray(ids);

if (metadatas === undefined) {
metadatasArray = undefined
metadatasArray = undefined;
} else {

@@ -165,3 +232,3 @@ metadatasArray = toArray(metadatas);

if (documents === undefined) {
documentsArray = undefined
documentsArray = undefined;
} else {

@@ -172,54 +239,114 @@ documentsArray = toArray(documents);

if (
((embeddingsArray !== undefined) && idsArray.length !== embeddingsArray.length) ||
((metadatasArray !== undefined) && idsArray.length !== metadatasArray.length) ||
((documentsArray !== undefined) && idsArray.length !== documentsArray.length)
(embeddingsArray !== undefined &&
idsArray.length !== embeddingsArray.length) ||
(metadatasArray !== undefined &&
idsArray.length !== metadatasArray.length) ||
(documentsArray !== undefined &&
idsArray.length !== documentsArray.length)
) {
throw new Error(
"ids, embeddings, metadatas, and documents must all be the same length",
"ids, embeddings, metadatas, and documents must all be the same length"
);
}
const response = await this.api.add({
collectionName: this.name,
addEmbedding: {
const uniqueIds = new Set(idsArray);
if (uniqueIds.size !== idsArray.length) {
const duplicateIds = idsArray.filter((item, index) => idsArray.indexOf(item) !== index);
throw new Error(
`Expected IDs to be unique, found duplicates for: ${duplicateIds}`,
);
}
return [idsArray, embeddingsArray, metadatasArray, documentsArray]
}
public async add(
ids: string | string[],
embeddings: number[] | number[][] | undefined,
metadatas?: object | object[],
documents?: string | string[],
increment_index: boolean = true,
) {
const [idsArray, embeddingsArray, metadatasArray, documentsArray] = await this.validate(
true,
ids,
embeddings,
metadatas,
documents
)
const response = await this.api.add(this.id,
{
// @ts-ignore
ids: idsArray,
embeddings: embeddingsArray,
embeddings: embeddingsArray as number[][], // We know this is defined because of the validate function
// @ts-ignore
documents: documentsArray,
metadatas: metadatasArray,
incrementIndex: increment_index,
})
.then(handleSuccess)
.catch(handleError);
return response
}
public async upsert(
ids: string | string[],
embeddings: number[] | number[][] | undefined,
metadatas?: object | object[],
documents?: string | string[],
increment_index: boolean = true,
) {
const [idsArray, embeddingsArray, metadatasArray, documentsArray] = await this.validate(
true,
ids,
embeddings,
metadatas,
documents
)
const response = await this.api.upsert(this.id,
{
//@ts-ignore
ids: idsArray,
embeddings: embeddingsArray as number[][], // We know this is defined because of the validate function
//@ts-ignore
documents: documentsArray,
metadatas: metadatasArray,
increment_index: increment_index,
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
)
.then(handleSuccess)
.catch(handleError);
return response
}
public async count() {
const response = await this.api.count({ collectionName: this.name });
return response.data;
const response = await this.api.count(this.id);
return handleSuccess(response);
}
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;
});
public async modify(name?: string, metadata?: object) {
const response = await this.api
.updateCollection(
this.id,
{
new_name: name,
new_metadata: metadata,
},
)
.then(handleSuccess)
.catch(handleError);
this.setName(name || this.name)
this.setMetadata(metadata || this.metadata)
this.setName(name || this.name);
this.setMetadata(metadata || this.metadata);
return response
return response;
}

@@ -232,11 +359,10 @@

offset?: number,
include?: GetEmbeddingIncludeEnum[],
where_document?: object,
include?: IncludeEnum[],
where_document?: object
) {
let idsArray = undefined
let idsArray = undefined;
if (ids !== undefined) idsArray = toArray(ids);
var resp = await this.api.get({
collectionName: this.name,
getEmbedding: {
return await this.api
.aGet(this.id, {
ids: idsArray,

@@ -247,12 +373,5 @@ where,

include,
where_document,
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return resp
})
.then(handleSuccess)
.catch(handleError);
}

@@ -264,15 +383,19 @@

metadatas?: object | object[],
documents?: string | string[],
documents?: string | string[]
) {
if ((embeddings === undefined) && (documents === undefined) && (metadatas === undefined)) {
if (
embeddings === undefined &&
documents === undefined &&
metadatas === undefined
) {
throw new Error(
"embeddings, documents, and metadatas cannot all be undefined",
"embeddings, documents, and metadatas cannot all be undefined"
);
} else if ((embeddings === undefined) && (documents !== undefined)) {
} else if (embeddings === undefined && documents !== undefined) {
const documentsArray = toArray(documents);
if (this.embeddingFunction !== undefined) {
embeddings = await this.embeddingFunction.generate(documentsArray)
embeddings = await this.embeddingFunction.generate(documentsArray);
} else {
throw new Error(
"embeddingFunction is undefined. Please configure an embedding function",
"embeddingFunction is undefined. Please configure an embedding function"
);

@@ -282,17 +405,16 @@ }

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;
});
var resp = await this.api
.update(
this.id,
{
ids: toArray(ids),
embeddings: embeddings ? toArrayOfArrays(embeddings) : undefined,
documents: documents, //TODO: this was toArray(documents) but that was wrong?
metadatas: toArray(metadatas),
},
)
.then(handleSuccess)
.catch(handleError);
return resp
return resp;
}

@@ -306,65 +428,52 @@

where_document?: object, // {"$contains":"search_string"}
include?: QueryEmbeddingIncludeEnum[], // ["metadata", "document"]
include?: IncludeEnum[] // ["metadata", "document"]
) {
if ((query_embeddings === undefined) && (query_text === undefined)) {
if (query_embeddings === undefined && query_text === undefined) {
throw new Error(
"query_embeddings and query_text cannot both be undefined",
"query_embeddings and query_text cannot both be undefined"
);
} else if ((query_embeddings === undefined) && (query_text !== undefined)) {
} else if (query_embeddings === undefined && query_text !== undefined) {
const query_texts = toArray(query_text);
if (this.embeddingFunction !== undefined) {
query_embeddings = await this.embeddingFunction.generate(query_texts)
query_embeddings = await this.embeddingFunction.generate(query_texts);
} else {
throw new Error(
"embeddingFunction is undefined. Please configure an embedding function",
"embeddingFunction is undefined. Please configure an embedding function"
);
}
}
if (query_embeddings === undefined) throw new Error("embeddings is undefined but shouldnt be")
if (query_embeddings === undefined)
throw new Error("embeddings is undefined but shouldnt be");
const query_embeddingsArray: number[][] = toArrayOfArrays(query_embeddings);
const response = await this.api.getNearestNeighbors({
collectionName: this.name,
queryEmbedding: {
return await this.api
.getNearestNeighbors(this.id, {
query_embeddings: query_embeddingsArray,
where,
n_results,
n_results: n_results,
where_document: where_document,
include: include
},
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response;
include: include,
})
.then(handleSuccess)
.catch(handleError);
}
public async peek(limit: number = 10) {
const response = await this.api.get({
collectionName: this.name,
getEmbedding: { limit: limit },
const response = await this.api.aGet(this.id, {
limit: limit,
});
return response.data;
return handleSuccess(response);
}
public async createIndex() {
return await this.api.createIndex({ collectionName: this.name });
return await this.api.createIndex(this.name);
}
public async delete(ids?: string[], where?: object, where_document?: object) {
var response = await this.api._delete({
collectionName: this.name,
deleteEmbedding: { ids: ids, where: where, where_document: where_document },
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response
return await this.api
.aDelete(this.id, { ids: ids, where: where, where_document: where_document })
.then(handleSuccess)
.catch(handleError);
}
}

@@ -380,9 +489,3 @@

});
const axiosInstance = axios.create({
maxBodyLength: Infinity,
maxContentLength: Infinity
})
this.api = new DefaultApi(apiConfig, basePath, axiosInstance);
this.api = new DefaultApi(apiConfig);
}

@@ -396,3 +499,3 @@

const response = await this.api.version();
return response.data;
return await handleSuccess(response);
}

@@ -402,17 +505,22 @@

const response = await this.api.heartbeat();
return response.data["nanosecond heartbeat"];
let ret = await handleSuccess(response);
return ret["nanosecond heartbeat"]
}
public async persist() {
throw new Error("Not implemented in JS client")
throw new Error("Not implemented in JS client");
}
public async createCollection(name: string, metadata?: object, embeddingFunction?: CallableFunction) {
const newCollection = await this.api.createCollection({
createCollection: { name, metadata },
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
public async createCollection(
name: string,
metadata?: object,
embeddingFunction?: CallableFunction
) {
const newCollection = await this.api
.createCollection({
name,
metadata,
})
.then(handleSuccess)
.catch(handleError);

@@ -423,15 +531,19 @@ if (newCollection.error) {

return new Collection(name, this.api, metadata, embeddingFunction);
return new Collection(name, newCollection.id, 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 },
public async getOrCreateCollection(
name: string,
metadata?: object,
embeddingFunction?: CallableFunction
) {
const newCollection = await this.api
.createCollection({
name,
metadata,
'get_or_create': true
})
.then(handleSuccess)
.catch(handleError);
}).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
if (newCollection.error) {

@@ -441,3 +553,9 @@ throw new Error(newCollection.error);

return new Collection(name, this.api, newCollection.metadata, embeddingFunction);
return new Collection(
name,
newCollection.id,
this.api,
newCollection.metadata,
embeddingFunction
);
}

@@ -447,25 +565,30 @@

const response = await this.api.listCollections();
return response.data;
return handleSuccess(response);
}
public async getCollection(name: string, embeddingFunction?: CallableFunction) {
const response = await this.api.getCollection({ collectionName: name }).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
public async getCollection(
name: string,
embeddingFunction?: CallableFunction
) {
const response = await this.api
.getCollection(name)
.then(handleSuccess)
.catch(handleError);
return new Collection(response.name, this.api, response.metadata, embeddingFunction);
return new Collection(
response.name,
response.id,
this.api,
response.metadata,
embeddingFunction
);
}
public async deleteCollection(name: string) {
const response = await this.api.deleteCollection({ collectionName: name }).then(function (response) {
return response.data;
}).catch(function ({ response }) {
return response.data;
});
return response
return await this.api
.deleteCollection(name)
.then(handleSuccess)
.catch(handleError);
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

Sorry, the diff of this file is too big to display

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc