2023-07-01 18:22:28 +03:00
|
|
|
/* eslint-disable */
|
2023-05-18 14:37:03 +03:00
|
|
|
"use client";
|
2023-06-15 12:52:46 +03:00
|
|
|
import Link from "next/link";
|
2023-07-01 18:22:28 +03:00
|
|
|
import { useEffect } from "react";
|
2023-06-15 12:52:46 +03:00
|
|
|
|
2023-06-13 17:33:41 +03:00
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
|
|
import { Divider } from "@/lib/components/ui/Divider";
|
|
|
|
import PageHeading from "@/lib/components/ui/PageHeading";
|
2023-07-01 18:22:28 +03:00
|
|
|
import { getBrainFromLocalStorage } from "@/lib/context/BrainProvider/helpers/brainLocalStorage";
|
|
|
|
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
|
|
|
|
2023-06-15 12:52:46 +03:00
|
|
|
|
2023-05-27 01:12:57 +03:00
|
|
|
import { Crawler } from "./components/Crawler";
|
|
|
|
import { FileUploader } from "./components/FileUploader";
|
2023-05-21 19:50:58 +03:00
|
|
|
|
2023-06-15 12:52:46 +03:00
|
|
|
const UploadPage = (): JSX.Element => {
|
2023-07-01 18:22:28 +03:00
|
|
|
const { setActiveBrain, setDefaultBrain } = useBrainContext();
|
|
|
|
|
|
|
|
const fetchAndSetActiveBrain = async () => {
|
|
|
|
const storedBrain = getBrainFromLocalStorage();
|
|
|
|
if (storedBrain) {
|
|
|
|
setActiveBrain({ ...storedBrain });
|
|
|
|
return storedBrain;
|
|
|
|
} else {
|
|
|
|
const defaultBrain = await setDefaultBrain();
|
|
|
|
return defaultBrain;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchBrains = async () => {
|
|
|
|
await fetchAndSetActiveBrain();
|
|
|
|
};
|
|
|
|
fetchBrains();
|
|
|
|
}, []);
|
|
|
|
|
2023-05-23 11:06:58 +03:00
|
|
|
return (
|
2023-06-11 11:44:23 +03:00
|
|
|
<main className="pt-10">
|
2023-05-27 01:12:57 +03:00
|
|
|
<PageHeading
|
|
|
|
title="Upload Knowledge"
|
|
|
|
subtitle="Text, document, spreadsheet, presentation, audio, video, and URLs supported"
|
|
|
|
/>
|
|
|
|
<FileUploader />
|
|
|
|
<Divider text="or" className="m-5" />
|
|
|
|
<Crawler />
|
|
|
|
<div className="flex flex-col items-center justify-center gap-5 mt-5">
|
|
|
|
<Link href={"/chat"}>
|
|
|
|
<Button variant={"secondary"} className="py-3">
|
|
|
|
Chat
|
2023-05-23 11:06:58 +03:00
|
|
|
</Button>
|
2023-05-27 01:12:57 +03:00
|
|
|
</Link>
|
2023-05-23 11:06:58 +03:00
|
|
|
</div>
|
2023-05-27 01:12:57 +03:00
|
|
|
</main>
|
2023-05-23 11:06:58 +03:00
|
|
|
);
|
2023-06-15 12:52:46 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default UploadPage;
|