mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-09-17 18:20:11 +02:00
8929d96ed0
* Move OpenAI api calls into its own interface/Class move curate sources to be specific for each vectorDBs response for chat/query * remove comment
29 lines
735 B
JavaScript
29 lines
735 B
JavaScript
function getVectorDbClass() {
|
|
const { Pinecone } = require("../vectorDbProviders/pinecone");
|
|
const { Chroma } = require("../vectorDbProviders/chroma");
|
|
const { LanceDb } = require("../vectorDbProviders/lance");
|
|
|
|
const vectorSelection = process.env.VECTOR_DB || "pinecone";
|
|
switch (vectorSelection) {
|
|
case "pinecone":
|
|
return Pinecone;
|
|
case "chroma":
|
|
return Chroma;
|
|
case "lancedb":
|
|
return LanceDb;
|
|
default:
|
|
throw new Error("ENV: No VECTOR_DB value found in environment!");
|
|
}
|
|
}
|
|
|
|
function toChunks(arr, size) {
|
|
return Array.from({ length: Math.ceil(arr.length / size) }, (_v, i) =>
|
|
arr.slice(i * size, i * size + size)
|
|
);
|
|
}
|
|
|
|
module.exports = {
|
|
getVectorDbClass,
|
|
toChunks,
|
|
};
|