* v2 Login screen (#254) * adding gradients for modal and sidebar * adding font setup * redesigned login screen for MultiUserAuth * completed multi user mode login screen * linting * login screen for single user auth redesign complete * created reusable gradient for login screen --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * v2 sidebar (#262) * adding gradients for modal and sidebar * adding font setup * redesigned login screen for MultiUserAuth * completed multi user mode login screen * linting * login screen for single user auth redesign complete * WIP sidebar redesign * created reusable gradient for login screen * remove dark mode items * update new workspace button * completed sidebar for desktop view * add interactivity states --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * remove duplicated pkg * v2 settings (#264) * adding gradients for modal and sidebar * adding font setup * redesigned login screen for MultiUserAuth * completed multi user mode login screen * linting * login screen for single user auth redesign complete * WIP sidebar redesign * created reusable gradient for login screen * remove dark mode items * update new workspace button * completed sidebar for desktop view * WIP added colors/gradients to admin settings * WIP fix discord logo import * WIP settings redesign - added routes for general settings and restyled components * WIP settings for LLM Preference, VectorDB, ExportImport * settings menu UI complete WIP functionality * settings fully functional/removed dark mode logo * linting * removing unneeded dependency * Fix admin sidebar visibility Fix API Keys location and work with single/mum Fix Appearance location - WIP on funcitonality * update api key page * fix permissions for appearance * Single user mode fixes * fix multi user mode enabled * fix import export * Rename AdminSidebar to SettingsSidebar * Fix mobile sidebar links --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * V2 user logout (#265) * Add user logout button * hide other 3 dot button * wrap admin routes * V2 workspace modal (#267) Update new workspace modal remove duplicate tailwind colors * v2 Settings modal styles (#266) * EditUserModal styles complete * workspaces modals styles complete * create invite link modal styles complete * create new api key modal styles complete --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * v2 Chats Redesign (#270) * fix default message for new workspace * prompt input box ui redesign complete * ui tweak to prompt input * WIP chat msg redesign * chat container and historical chat messages redesign * manage workspace modal appears when clicking upload a document on empty workspace * fixed loading skeleton styles * citations redesign complete * restyle pending chat and prompt reply components * default chat messages styles updated * linting * update how chats are returned --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * Onboarding modal flow for first time setup (#274) * WIP onboarding modal flow * onboarding flow complete and private route redirection for onboarding setep * redirect to home on onboarding complete * add onboarding redirect using paths.onboarding() * Apply changes to auth flow, onboarding determination, and flows * remove formref --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * v2 document picker (#275) * remove unneeded comments * WIP document picker UI * WIP basic UI complete for document picker tab and settings tab * linting * settings menu complete, document row WIP * WIP document picker loading from localFiles * WIP file picker logic * refactoring document picker to work with backend * WIP refactoring document picker * WIP refactor document picker to work with backend * file uploading with dropzone working * WIP deleting file when not embedded * WIP embeddings * WIP embedding with temp button and hardcoded paths * WIP placeholder for WorkspaceDirectory component * WIP WorkspaceDirectory * WIP * sort workspaceDocs and availibleDocs complete * added directories util * add and remove document from ws working * v2 document picker complete * reference modal ui bug fixes * truncate function bug fix * ManageWorkspace modal bug fixes * blocking mobile users modal for workspace settings * mobile ui fixes * linting * ui padding fixes * citation bug fixes * code review changes * debounce handlers * change tempFile object to array * selection count fix * Convert workspace modal to div Memo workspace settings update conditional rendering of workspace settings * Show no documents --------- Co-authored-by: timothycarambat <rambat1010@gmail.com> * mobile sidebar styles * padding on Mobile view mobile sidebar items * UI touchup * suggestion implementations * CSS fixes and animation perfomance change to GPU accelerated and 60fps * change will-change * remove transitions from onboarding modals, simplify on-change handlers * Swap onboarding to memoized components and debounce onchange handlers * remove console log * remove Avenir font --------- Co-authored-by: Sean Hatfield <seanhatfield5@gmail.com>
311 lines
12 KiB
JavaScript
311 lines
12 KiB
JavaScript
import React, { memo, useEffect, useState } from "react";
|
|
|
|
import VectorDBOption from "../../../../../components/VectorDBOption";
|
|
import ChromaLogo from "../../../../../media/vectordbs/chroma.png";
|
|
import PineconeLogo from "../../../../../media/vectordbs/pinecone.png";
|
|
import LanceDbLogo from "../../../../../media/vectordbs/lancedb.png";
|
|
import WeaviateLogo from "../../../../../media/vectordbs/weaviate.png";
|
|
import QDrantLogo from "../../../../../media/vectordbs/qdrant.png";
|
|
import System from "../../../../../models/system";
|
|
import PreLoader from "../../../../../components/Preloader";
|
|
|
|
function VectorDatabaseConnection({ nextStep, prevStep, currentStep }) {
|
|
const [vectorDB, setVectorDB] = useState("lancedb");
|
|
const [settings, setSettings] = useState({});
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
async function fetchKeys() {
|
|
const _settings = await System.keys();
|
|
setSettings(_settings);
|
|
setVectorDB(_settings?.VectorDB || "lancedb");
|
|
setLoading(false);
|
|
}
|
|
if (currentStep === 2) {
|
|
fetchKeys();
|
|
}
|
|
}, [currentStep]);
|
|
|
|
const updateVectorChoice = (selection) => {
|
|
setVectorDB(selection);
|
|
};
|
|
|
|
const handleSubmit = async (e, formElement) => {
|
|
e.preventDefault();
|
|
const form = formElement || e.target;
|
|
const data = {};
|
|
const formData = new FormData(form);
|
|
for (var [key, value] of formData.entries()) data[key] = value;
|
|
const { error } = await System.updateSystem(data);
|
|
if (error) {
|
|
alert(`Failed to save settings: ${error}`, "error");
|
|
return;
|
|
}
|
|
nextStep();
|
|
return;
|
|
};
|
|
|
|
if (loading)
|
|
return (
|
|
<div className="w-full h-full flex justify-center items-center p-20">
|
|
<PreLoader />
|
|
</div>
|
|
);
|
|
|
|
return (
|
|
<div>
|
|
<form onSubmit={handleSubmit} className="flex flex-col w-full">
|
|
<div className="flex flex-col w-full px-1 md:px-8 py-12">
|
|
<div className="text-white text-sm font-medium pb-4">
|
|
Select your preferred vector database provider
|
|
</div>
|
|
<div className="w-full flex md:flex-wrap overflow-x-scroll gap-4 max-w-[900px]">
|
|
<input hidden={true} name="VectorDB" value={vectorDB} />
|
|
<VectorDBOption
|
|
name="Chroma"
|
|
value="chroma"
|
|
link="trychroma.com"
|
|
description="Open source vector database you can host yourself or on the cloud."
|
|
checked={vectorDB === "chroma"}
|
|
image={ChromaLogo}
|
|
onClick={updateVectorChoice}
|
|
/>
|
|
<VectorDBOption
|
|
name="Pinecone"
|
|
value="pinecone"
|
|
link="pinecone.io"
|
|
description="100% cloud-based vector database for enterprise use cases."
|
|
checked={vectorDB === "pinecone"}
|
|
image={PineconeLogo}
|
|
onClick={updateVectorChoice}
|
|
/>
|
|
<VectorDBOption
|
|
name="QDrant"
|
|
value="qdrant"
|
|
link="qdrant.tech"
|
|
description="Open source local and distributed cloud vector database."
|
|
checked={vectorDB === "qdrant"}
|
|
image={QDrantLogo}
|
|
onClick={updateVectorChoice}
|
|
/>
|
|
<VectorDBOption
|
|
name="Weaviate"
|
|
value="weaviate"
|
|
link="weaviate.io"
|
|
description="Open source local and cloud hosted multi-modal vector database."
|
|
checked={vectorDB === "weaviate"}
|
|
image={WeaviateLogo}
|
|
onClick={updateVectorChoice}
|
|
/>
|
|
<VectorDBOption
|
|
name="LanceDB"
|
|
value="lancedb"
|
|
link="lancedb.com"
|
|
description="100% local vector DB that runs on the same instance as AnythingLLM."
|
|
checked={vectorDB === "lancedb"}
|
|
image={LanceDbLogo}
|
|
onClick={updateVectorChoice}
|
|
/>
|
|
</div>
|
|
<div className="mt-10 flex flex-wrap gap-4 max-w-[800px]">
|
|
{vectorDB === "pinecone" && (
|
|
<>
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
Pinecone DB API Key
|
|
</label>
|
|
<input
|
|
type="password"
|
|
name="PineConeKey"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="Pinecone API Key"
|
|
defaultValue={settings?.PineConeKey ? "*".repeat(20) : ""}
|
|
required={true}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
Pinecone Index Environment
|
|
</label>
|
|
<input
|
|
type="text"
|
|
name="PineConeEnvironment"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="us-gcp-west-1"
|
|
defaultValue={settings?.PineConeEnvironment}
|
|
required={true}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
Pinecone Index Name
|
|
</label>
|
|
<input
|
|
type="text"
|
|
name="PineConeIndex"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="my-index"
|
|
defaultValue={settings?.PineConeIndex}
|
|
required={true}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{vectorDB === "chroma" && (
|
|
<>
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
Chroma Endpoint
|
|
</label>
|
|
<input
|
|
type="url"
|
|
name="ChromaEndpoint"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="http://localhost:8000"
|
|
defaultValue={settings?.ChromaEndpoint}
|
|
required={true}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
API Header
|
|
</label>
|
|
<input
|
|
name="ChromaApiHeader"
|
|
autoComplete="off"
|
|
type="text"
|
|
defaultValue={settings?.ChromaApiHeader}
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="X-Api-Key"
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
API Key
|
|
</label>
|
|
<input
|
|
name="ChromaApiKey"
|
|
autoComplete="off"
|
|
type="password"
|
|
defaultValue={settings?.ChromaApiKey ? "*".repeat(20) : ""}
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="sk-myApiKeyToAccessMyChromaInstance"
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{vectorDB === "lancedb" && (
|
|
<div className="w-full h-10 items-center justify-center flex">
|
|
<p className="text-sm font-base text-white text-opacity-60">
|
|
There is no configuration needed for LanceDB.
|
|
</p>
|
|
</div>
|
|
)}
|
|
|
|
{vectorDB === "qdrant" && (
|
|
<>
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
QDrant API Endpoint
|
|
</label>
|
|
<input
|
|
type="url"
|
|
name="QdrantEndpoint"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="http://localhost:6633"
|
|
defaultValue={settings?.QdrantEndpoint}
|
|
required={true}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
API Key
|
|
</label>
|
|
<input
|
|
type="password"
|
|
name="QdrantApiKey"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="wOeqxsYP4....1244sba"
|
|
defaultValue={settings?.QdrantApiKey}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{vectorDB === "weaviate" && (
|
|
<>
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
Weaviate Endpoint
|
|
</label>
|
|
<input
|
|
type="url"
|
|
name="WeaviateEndpoint"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="http://localhost:8080"
|
|
defaultValue={settings?.WeaviateEndpoint}
|
|
required={true}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex flex-col w-60">
|
|
<label className="text-white text-sm font-semibold block mb-4">
|
|
API Key
|
|
</label>
|
|
<input
|
|
type="password"
|
|
name="WeaviateApiKey"
|
|
className="bg-zinc-900 text-white placeholder-white placeholder-opacity-60 text-sm rounded-lg focus:border-white block w-full p-2.5"
|
|
placeholder="sk-123Abcweaviate"
|
|
defaultValue={settings?.WeaviateApiKey}
|
|
autoComplete="off"
|
|
spellCheck={false}
|
|
/>
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className="flex w-full justify-between items-center p-6 space-x-2 border-t rounded-b border-gray-500/50">
|
|
<button
|
|
onClick={prevStep}
|
|
type="button"
|
|
className="px-4 py-2 rounded-lg text-white hover:bg-sidebar"
|
|
>
|
|
Back
|
|
</button>
|
|
<button
|
|
type="submit"
|
|
className="border border-slate-200 px-4 py-2 rounded-lg text-slate-800 bg-slate-200 text-sm items-center flex gap-x-2 hover:text-white hover:bg-transparent focus:ring-gray-800 font-semibold shadow"
|
|
>
|
|
Continue
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default memo(VectorDatabaseConnection);
|