UNPKG

@langchain/community

Version:
1 lines • 5.64 kB
{"version":3,"file":"typesense.d.ts","names":["Client","MultiSearchRequestSchema","EmbeddingsInterface","VectorStore","Document","AsyncCallerParams","TypesenseConfig","T","Record","Promise","Typesense","Partial"],"sources":["../../src/vectorstores/typesense.d.ts"],"sourcesContent":["import type { Client } from \"typesense\";\nimport type { MultiSearchRequestSchema } from \"typesense/lib/Typesense/MultiSearch.js\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { VectorStore } from \"@langchain/core/vectorstores\";\nimport { Document } from \"@langchain/core/documents\";\nimport { AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\n/**\n * Typesense vector store configuration.\n */\nexport interface TypesenseConfig extends AsyncCallerParams {\n /**\n * Typesense client.\n */\n typesenseClient: Client;\n /**\n * Typesense schema name in which documents will be stored and searched.\n */\n schemaName: string;\n /**\n * Typesense search parameters.\n * @default { q: '*', per_page: 5, query_by: '' }\n */\n searchParams?: MultiSearchRequestSchema;\n /**\n * Column names.\n */\n columnNames?: {\n /**\n * Vector column name.\n * @default 'vec'\n */\n vector?: string;\n /**\n * Page content column name.\n * @default 'text'\n */\n pageContent?: string;\n /**\n * Metadata column names.\n * @default []\n */\n metadataColumnNames?: string[];\n };\n /**\n * Replace default import function.\n * Default import function will update documents if there is a document with the same id.\n * @param data\n * @param collectionName\n */\n import?<T extends Record<string, unknown> = Record<string, unknown>>(data: T[], collectionName: string): Promise<void>;\n}\n/**\n * Typesense vector store.\n */\nexport declare class Typesense extends VectorStore {\n FilterType: Partial<MultiSearchRequestSchema>;\n private client;\n private schemaName;\n private searchParams;\n private vectorColumnName;\n private pageContentColumnName;\n private metadataColumnNames;\n private caller;\n private import;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, config: TypesenseConfig);\n private importToTypesense;\n /**\n * Transform documents to Typesense records.\n * @param documents\n * @returns Typesense records.\n */\n _documentsToTypesenseRecords(documents: Document[], vectors: number[][]): Record<string, unknown>[];\n /**\n * Transform the Typesense records to documents.\n * @param typesenseRecords\n * @returns documents\n */\n _typesenseRecordsToDocuments(typesenseRecords: {\n document?: Record<string, unknown>;\n vector_distance: number;\n }[] | undefined): [Document, number][];\n /**\n * Add documents to the vector store.\n * Will be updated if in the metadata there is a document with the same id if is using the default import function.\n * Metadata will be added in the columns of the schema based on metadataColumnNames.\n * @param documents Documents to add.\n */\n addDocuments(documents: Document[]): Promise<void>;\n /**\n * Adds vectors to the vector store.\n * @param vectors Vectors to add.\n * @param documents Documents associated with the vectors.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n /**\n * Search for similar documents with their similarity score.\n * @param vectorPrompt vector to search for\n * @param k amount of results to return\n * @returns similar documents with their similarity score\n */\n similaritySearchVectorWithScore(vectorPrompt: number[], k?: number, filter?: this[\"FilterType\"]): Promise<[Document<Record<string, any>>, number][]>;\n /**\n * Delete documents from the vector store.\n * @param documentIds ids of the documents to delete\n */\n deleteDocuments(documentIds: string[]): Promise<void>;\n /**\n * Create a vector store from documents.\n * @param docs documents\n * @param embeddings embeddings\n * @param config Typesense configuration\n * @returns Typesense vector store\n * @warning You can omit this method, and only use the constructor and addDocuments.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, config: TypesenseConfig): Promise<Typesense>;\n /**\n * Create a vector store from texts.\n * @param texts\n * @param metadatas\n * @param embeddings\n * @param config\n * @returns Typesense vector store\n */\n static fromTexts(texts: string[], metadatas: object[], embeddings: EmbeddingsInterface, config: TypesenseConfig): Promise<Typesense>;\n}\n//# sourceMappingURL=typesense.d.ts.map"],"mappings":";;;;;;;;;;;AASA;AAIqBA,UAJJM,eAAAA,SAAwBD,iBAIpBL,CAAAA;EASFC;;;EA2B4DM,eAAAA,EApC1DP,MAoC0DO;EAA8BE;;AAxCnD;EA6CrCC,UAAAA,EAAS,MAAA;EACNT;;;;EAiBoBG,YAAAA,CAAAA,EAlDzBH,wBAkDyBG;EAAkCI;;;EAgBlDJ,WAAAA,CAAAA,EAAAA;IAAaK;;;;IAasEL,MAAAA,CAAAA,EAAAA,MAAAA;IAATK;;;;IAclBH,WAAAA,CAAAA,EAAAA,MAAAA;IAA0BI;;;;IASgBA,mBAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAARD,CAAAA;EAtE/EN;AAAW;;;;;oBAL5BK,0BAA0BA,+BAA+BD,8BAA8BE;;;;;cAKxFC,SAAAA,SAAkBP,WAAAA;cACvBQ,QAAQV;;;;;;;;;;0BAUIC,6BAA6BI;;;;;;;0CAObF,kCAAkCI;;;;;;;eAO3DA;;qBAEIJ;;;;;;;0BAOKA,aAAaK;;;;;;6CAMML,aAAaK;;;;;;;oGAO0CA,SAASL,SAASI;;;;;0CAK5EC;;;;;;;;;6BASbL,wBAAwBF,6BAA6BI,kBAAkBG,QAAQC;;;;;;;;;qEASvCR,6BAA6BI,kBAAkBG,QAAQC"}