askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
49 lines (48 loc) • 2.24 kB
TypeScript
import { RagDB, RagResult, RagDocument } from "./interfaces.js";
/**
* Implementation of RagDB using ChromaDB.
*/
export declare class ChromaRagDB implements RagDB {
private client;
private collections;
/**
* Creates a new instance of ChromaRagDB.
*/
constructor(host?: string, port?: number, database?: string);
/**
* Gets or creates a collection in ChromaDB.
* @param collectionName The name of the collection
* @returns The collection object
*/
private getCollection;
/**
* Stores a vector embedding with associated metadata in the specified collection.
* @param collectionName The name of the collection to store the vector in
* @param id Unique identifier for the vector
* @param vector The embedding vector (array of numbers)
* @param metadata Additional metadata to store with the vector
*/
store(collectionName: string, id: string, vector: number[], metadata: any): Promise<void>;
/**
* Stores multiple vector embeddings with associated metadata in the specified collection.
* @param collectionName The name of the collection to store the vectors in
* @param documents Array of documents to store
*/
storeBatch(collectionName: string, documents: RagDocument[]): Promise<void>;
/**
* Searches for similar vectors in the specified collection.
* @param collectionName The name of the collection to search in
* @param vector The query vector to search for
* @param limit Maximum number of results to return
* @returns Promise resolving to an array of matching records
*/
search(collectionName: string, vector: number[], limit: number): Promise<RagResult[]>;
/**
* Searches for similar vectors in the specified collection using multiple query vectors.
* @param collectionName The name of the collection to search in
* @param vectors Array of query vectors to search for
* @param limit Maximum number of results to return per query vector
* @returns Promise resolving to an array of arrays of RagResult objects, one array per query vector
*/
searchBatch(collectionName: string, vectors: number[][], limit: number): Promise<RagResult[][]>;
}