patch milvus/zilliz auto-generated collection name

resolves #1027
This commit is contained in:
timothycarambat 2024-04-03 12:34:23 -07:00
parent 78b0a91073
commit 718062d033
2 changed files with 10 additions and 2 deletions

View File

@ -18,8 +18,12 @@ const Milvus = {
// Milvus/Zilliz only allows letters, numbers, and underscores in collection names
// so we need to enforce that by re-normalizing the names when communicating with
// the DB.
// If the first char of the collection is not an underscore or letter the collection name will be invalid.
normalize: function (inputString) {
return inputString.replace(/[^a-zA-Z0-9_]/g, "_");
let normalized = inputString.replace(/[^a-zA-Z0-9_]/g, "_");
if (new RegExp(/^[a-zA-Z_]/).test(normalized.slice(0, 1)))
normalized = `anythingllm_${normalized}`;
return normalized;
},
connect: async function () {
if (process.env.VECTOR_DB !== "milvus")

View File

@ -20,8 +20,12 @@ const Zilliz = {
// Milvus/Zilliz only allows letters, numbers, and underscores in collection names
// so we need to enforce that by re-normalizing the names when communicating with
// the DB.
// If the first char of the collection is not an underscore or letter the collection name will be invalid.
normalize: function (inputString) {
return inputString.replace(/[^a-zA-Z0-9_]/g, "_");
let normalized = inputString.replace(/[^a-zA-Z0-9_]/g, "_");
if (new RegExp(/^[a-zA-Z_]/).test(normalized.slice(0, 1)))
normalized = `anythingllm_${normalized}`;
return normalized;
},
connect: async function () {
if (process.env.VECTOR_DB !== "zilliz")