Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ AnythingLLM divides your documents into objects called `workspaces`. A Workspace

- [LanceDB](https://github.com/lancedb/lancedb) (default)
- [PGVector](https://github.com/pgvector/pgvector)
- [Vastbase](https://www.vastbase.com)
- [Astra DB](https://www.datastax.com/products/datastax-astra)
- [Pinecone](https://pinecone.io)
- [Chroma & ChromaCloud](https://trychroma.com)
Expand Down
5 changes: 5 additions & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ GID='1000'
# PGVECTOR_CONNECTION_STRING="postgresql://dbuser:dbuserpass@localhost:5432/yourdb"
# PGVECTOR_TABLE_NAME="anythingllm_vectors" # optional, but can be defined

# Enable all below if you are using vector database: Vastbase.
# VECTOR_DB="vastbase"
# VASTBASE_CONNECTION_STRING="postgresql://dbuser:dbuserpass@localhost:5432/yourdb"
# VASTBASE_TABLE_NAME="anythingllm_vectors" # optional, but can be defined

# Enable all below if you are using vector database: Chroma.
# VECTOR_DB="chroma"
# CHROMA_ENDPOINT='http://host.docker.internal:8000'
Expand Down
103 changes: 103 additions & 0 deletions frontend/src/components/VectorDBSelection/VastbaseOptions/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { Info } from "@phosphor-icons/react";
import { Tooltip } from "react-tooltip";

export default function VastbaseOptions({ settings }) {
return (
<div className="w-full flex flex-col gap-y-7">
<div className="w-full flex items-center gap-[36px] mt-1.5">
<div className="flex flex-col w-96">
<div className="flex items-center gap-x-1 mb-3">
<label className="text-white text-sm font-semibold block">
Postgres Connection String
</label>
<Info
size={16}
className="text-theme-text-secondary cursor-pointer"
data-tooltip-id="vastbase-connection-string-tooltip"
data-tooltip-place="right"
/>
<Tooltip
delayHide={300}
id="vastbase-connection-string-tooltip"
className="max-w-md z-99"
clickable={true}
>
<p className="text-md whitespace-pre-line break-words">
This is the connection string for the Postgres database in the
format of <br />
<code>postgresql://username:password@host:port/database</code>
<br />
<br />
The user for the database must have the following permissions:
<ul className="list-disc list-inside">
<li>Read access to the database</li>
<li>Read access to the database schema</li>
<li>Create access to the database</li>
</ul>
<br />
<b>
You must have the vastbase extension installed on the
database.
</b>
</p>
</Tooltip>
</div>
<input
type="text"
name="VastbaseConnectionString"
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="postgresql://username:password@host:port/database"
defaultValue={
settings?.VastbaseConnectionString ? "*".repeat(20) : ""
}
required={true}
autoComplete="off"
spellCheck={false}
/>
</div>

<div className="flex flex-col w-60">
<div className="flex items-center gap-x-1 mb-3">
<label className="text-white text-sm font-semibold block">
Vector Table Name
</label>
<Info
size={16}
className="text-theme-text-secondary cursor-pointer"
data-tooltip-id="vastbase-table-name-tooltip"
data-tooltip-place="right"
/>
<Tooltip
delayHide={300}
id="vastbase-table-name-tooltip"
className="max-w-md z-99"
clickable={true}
>
<p className="text-md whitespace-pre-line break-words">
This is the name of the table in the Postgres database that will
store the vectors.
<br />
<br />
By default, the table name is <code>anythingllm_vectors</code>.
<br />
<br />
<b>
This table must not already exist on the database - it will be
created automatically.
</b>
</p>
</Tooltip>
</div>
<input
type="text"
name="VastbaseTableName"
autoComplete="off"
defaultValue={settings?.VastbaseTableName}
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="vector_table"
/>
</div>
</div>
</div>
);
}
Binary file added frontend/src/media/vectordbs/vastbase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import MilvusLogo from "@/media/vectordbs/milvus.png";
import ZillizLogo from "@/media/vectordbs/zilliz.png";
import AstraDBLogo from "@/media/vectordbs/astraDB.png";
import PGVectorLogo from "@/media/vectordbs/pgvector.png";
import VastbaseLogo from "@/media/vectordbs/vastbase.png";

import LanceDBOptions from "@/components/VectorDBSelection/LanceDBOptions";
import ChromaDBOptions from "@/components/VectorDBSelection/ChromaDBOptions";
Expand All @@ -32,6 +33,7 @@ import MilvusDBOptions from "@/components/VectorDBSelection/MilvusDBOptions";
import ZillizCloudOptions from "@/components/VectorDBSelection/ZillizCloudOptions";
import AstraDBOptions from "@/components/VectorDBSelection/AstraDBOptions";
import PGVectorOptions from "@/components/VectorDBSelection/PGVectorOptions";
import VastbaseOptions from "@/components/VectorDBSelection/VastbaseOptions";

export default function GeneralVectorDatabase() {
const [saving, setSaving] = useState(false);
Expand Down Expand Up @@ -126,6 +128,13 @@ export default function GeneralVectorDatabase() {
options: <PGVectorOptions settings={settings} />,
description: "Vector search powered by PostgreSQL.",
},
{
name: "Vastbase",
value: "vastbase",
logo: VastbaseLogo,
options: <VastbaseOptions settings={settings} />,
description: "Vector search powered by Vastbase.",
},
{
name: "Chroma",
value: "chroma",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import MilvusLogo from "@/media/vectordbs/milvus.png";
import VoyageAiLogo from "@/media/embeddingprovider/voyageai.png";
import PPIOLogo from "@/media/llmprovider/ppio.png";
import PGVectorLogo from "@/media/vectordbs/pgvector.png";
import VastbaseLogo from "@/media/vectordbs/vastbase.png";
import DPAISLogo from "@/media/llmprovider/dpais.png";
import MoonshotAiLogo from "@/media/llmprovider/moonshotai.png";
import CometApiLogo from "@/media/llmprovider/cometapi.png";
Expand Down Expand Up @@ -280,6 +281,14 @@ export const VECTOR_DB_PRIVACY = {
],
logo: PGVectorLogo,
},
vastbase: {
name: "Vastbase",
description: [
"Your vectors and document text are stored on your Vastbase instance",
"Access to your instance is managed by you",
],
logo: VastbaseLogo,
},
chroma: {
name: "Chroma",
description: [
Expand Down
1 change: 1 addition & 0 deletions locales/README.fa-IR.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ AnythingLLM اسناد شما را به اشیایی به نام `workspaces` ت

- [LanceDB](https://github.com/lancedb/lancedb) (پیش‌فرض)
- [PGVector](https://github.com/pgvector/pgvector)
- [Vastbase](https://www.vastdata.com.cn)
- [Astra DB](https://www.datastax.com/products/datastax-astra)
- [Pinecone](https://pinecone.io)
- [Chroma](https://trychroma.com)
Expand Down
1 change: 1 addition & 0 deletions locales/README.ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ AnythingLLMは、ドキュメントを`ワークスペース`と呼ばれるオ

- [LanceDB](https://github.com/lancedb/lancedb)(デフォルト)
- [PGVector](https://github.com/pgvector/pgvector)
- [Vastbase](https://www.vastdata.com.cn)
- [Astra DB](https://www.datastax.com/products/datastax-astra)
- [Pinecone](https://pinecone.io)
- [Chroma](https://trychroma.com)
Expand Down
1 change: 1 addition & 0 deletions locales/README.tr-TR.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ AnythingLLM, belgelerinizi **"çalışma alanları" (workspaces)** adı verilen

- [LanceDB](https://github.com/lancedb/lancedb) (default)
- [PGVector](https://github.com/pgvector/pgvector)
- [Vastbase](https://www.vastdata.com.cn)
- [Astra DB](https://www.datastax.com/products/datastax-astra)
- [Pinecone](https://pinecone.io)
- [Chroma](https://trychroma.com)
Expand Down
1 change: 1 addition & 0 deletions locales/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ AnythingLLM将您的文档划分为称为`workspaces` (工作区)的对象。工

- [LanceDB](https://github.com/lancedb/lancedb) (默认)
- [PGVector](https://github.com/pgvector/pgvector)
- [Vastbase](https://www.vastdata.com.cn)
- [Astra DB](https://www.datastax.com/products/datastax-astra)
- [Pinecone](https://pinecone.io)
- [Chroma](https://trychroma.com)
Expand Down
5 changes: 5 additions & 0 deletions server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ VECTOR_DB="lancedb"
# PGVECTOR_CONNECTION_STRING="postgresql://dbuser:dbuserpass@localhost:5432/yourdb"
# PGVECTOR_TABLE_NAME="anythingllm_vectors" # optional, but can be defined

# Enable all below if you are using vector database: Vastbase.
# VECTOR_DB="vastbase"
# VASTBASE_CONNECTION_STRING="postgresql://dbuser:dbuserpass@localhost:5432/yourdb"
# VASTBASE_TABLE_NAME="anythingllm_vectors" # optional, but can be defined

# Enable all below if you are using vector database: Weaviate.
# VECTOR_DB="weaviate"
# WEAVIATE_ENDPOINT="http://localhost:8080"
Expand Down
76 changes: 76 additions & 0 deletions server/__tests__/utils/vectorDbProviders/vastbase/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const { Vastbase } = require("../../../../utils/vectorDbProviders/vastbase");

describe("Vastbase.sanitizeForJsonb", () => {
it("returns null/undefined as-is", () => {
expect(Vastbase.sanitizeForJsonb(null)).toBeNull();
expect(Vastbase.sanitizeForJsonb(undefined)).toBeUndefined();
});

it("keeps safe whitespace (tab, LF, CR) and removes disallowed C0 controls", () => {
const input = "a\u0000\u0001\u0002\tline\ncarriage\rreturn\u001Fend";
const result = Vastbase.sanitizeForJsonb(input);
// Expect all < 0x20 except 9,10,13 removed; keep letters and allowed whitespace
expect(result).toBe("a\tline\ncarriage\rreturnend");
});

it("removes only disallowed control chars; keeps normal printable chars", () => {
const input = "Hello\u0000, World! \u0007\u0008\u000B\u000C\u001F";
const result = Vastbase.sanitizeForJsonb(input);
expect(result).toBe("Hello, World! ");
});

it("deeply sanitizes objects", () => {
const input = {
plain: "ok",
bad: "has\u0000nul",
nested: {
arr: ["fine", "bad\u0001", { deep: "\u0002oops" }],
},
};
const result = Vastbase.sanitizeForJsonb(input);
expect(result).toEqual({
plain: "ok",
bad: "hasnul",
nested: { arr: ["fine", "bad", { deep: "oops" }] },
});
});

it("deeply sanitizes arrays", () => {
const input = ["\u0000", 1, true, { s: "bad\u0003" }, ["ok", "\u0004bad"]];
const result = Vastbase.sanitizeForJsonb(input);
expect(result).toEqual(["", 1, true, { s: "bad" }, ["ok", "bad"]]);
});

it("converts Date to ISO string", () => {
const d = new Date("2020-01-02T03:04:05.000Z");
expect(Vastbase.sanitizeForJsonb(d)).toBe(d.toISOString());
});

it("returns primitives unchanged (number, boolean, bigint)", () => {
expect(Vastbase.sanitizeForJsonb(42)).toBe(42);
expect(Vastbase.sanitizeForJsonb(3.14)).toBe(3.14);
expect(Vastbase.sanitizeForJsonb(true)).toBe(true);
expect(Vastbase.sanitizeForJsonb(false)).toBe(false);
expect(Vastbase.sanitizeForJsonb(BigInt(1))).toBe(BigInt(1));
});

it("returns symbol unchanged", () => {
const sym = Symbol("x");
expect(Vastbase.sanitizeForJsonb(sym)).toBe(sym);
});

it("does not mutate original objects/arrays", () => {
const obj = { a: "bad\u0000", nested: { b: "ok" } };
const arr = ["\u0001", { c: "bad\u0002" }];
const objCopy = JSON.parse(JSON.stringify(obj));
const arrCopy = JSON.parse(JSON.stringify(arr));
const resultObj = Vastbase.sanitizeForJsonb(obj);
const resultArr = Vastbase.sanitizeForJsonb(arr);
// Original inputs remain unchanged
expect(obj).toEqual(objCopy);
expect(arr).toEqual(arrCopy);
// Results are sanitized copies
expect(resultObj).toEqual({ a: "bad", nested: { b: "ok" } });
expect(resultArr).toEqual(["", { c: "bad" }]);
});
});
5 changes: 5 additions & 0 deletions server/models/systemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const prisma = require("../utils/prisma");
const { v4 } = require("uuid");
const { MetaGenerator } = require("../utils/boot/MetaGenerator");
const { PGVector } = require("../utils/vectorDbProviders/pgvector");
const { Vastbase } = require("../utils/vectorDbProviders/vastbase");
const { NativeEmbedder } = require("../utils/EmbeddingEngines/native");
const { getBaseLLMProviderModel } = require("../utils/helpers");

Expand Down Expand Up @@ -458,6 +459,10 @@ const SystemSettings = {
// PGVector Keys
PGVectorConnectionString: !!PGVector.connectionString() || false,
PGVectorTableName: PGVector.tableName(),

// Vastbase Keys
VastbaseConnectionString: !!Vastbase.connectionString() || false,
VastbaseTableName: Vastbase.tableName(),
};
},

Expand Down
3 changes: 3 additions & 0 deletions server/utils/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ function getVectorDbClass(getExactly = null) {
case "pgvector":
const { PGVector } = require("../vectorDbProviders/pgvector");
return PGVector;
case "vastbase":
const { Vastbase } = require("../vectorDbProviders/vastbase");
return Vastbase;
default:
throw new Error("ENV: No VECTOR_DB value found in environment!");
}
Expand Down
Loading