File size: 1,598 Bytes
a85c9b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import Wrapper from "@/components/PageWrapper";
import Sidebar from "@/containers/Sidebar";
import CreateBot from "@/components/dashboard/CreateBot";
import SetOpenAIKey from "@/components/dashboard/SetOpenAIKey";
import PurgeChats from "@/components/dashboard/PurgeChats";
import DeleteBot from "@/components/dashboard/DeleteBot";
import { useEffect, useState } from "react";

export default function Home() {
  const [isKeyPresent, setIsKeyPresent] = useState(false);

  useEffect(() => {
    fetch("/api/check_key")
      .then((response) => response.json())
      .then((data) => {
        if (data.status === "ok") {
          setIsKeyPresent(true);
        }
      });
  }, []);

  return (
    <>
      <Sidebar />
      <Wrapper>
        <div className="text-center">
          <h1 className="mb-4 text-4xl font-extrabold leading-none tracking-tight text-gray-900 md:text-5xl">
            Welcome to Embedchain Playground
          </h1>
          <p className="mb-6 text-lg font-normal text-gray-500 lg:text-xl">
            Embedchain is a Data Platform for LLMs - Load, index, retrieve, and sync any unstructured data
            dataset
          </p>
        </div>
        <div
          className={`pt-6 gap-y-4 gap-x-8 ${
            isKeyPresent ? "grid lg:grid-cols-2" : "w-[50%] mx-auto"
          }`}
        >
          <SetOpenAIKey setIsKeyPresent={setIsKeyPresent} />
          {isKeyPresent && (
            <>
              <CreateBot />
              <DeleteBot />
              <PurgeChats />
            </>
          )}
        </div>
      </Wrapper>
    </>
  );
}