anything-llm/server/utils/helpers/index.js
Timothy Carambat 8929d96ed0
Move OpenAI api calls into its own interface/Class (#162)
* Move OpenAI api calls into its own interface/Class
move curate sources to be specific for each vectorDBs response for chat/query

* remove comment
2023-07-28 12:05:38 -07:00

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,
};