example: embedchain playground (#384)

This commit is contained in:
Sahil Kumar Yadav
2023-08-08 21:13:05 +05:30
committed by GitHub
parent 5e94980aaa
commit ec09a8a6fc
60 changed files with 13340 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import Wrapper from "@/components/PageWrapper";
import Sidebar from "@/containers/Sidebar";
import ChatWindow from "@/containers/ChatWindow";
import { useState } from "react";
import Head from "next/head";
export default function App() {
const [botTitle, setBotTitle] = useState("");
return (
<>
<Head>
<title>{botTitle}</title>
</Head>
<Sidebar />
<Wrapper>
<ChatWindow
embedding_model="open_ai"
app_type="app"
setBotTitle={setBotTitle}
/>
</Wrapper>
</>
);
}

View File

@@ -0,0 +1,14 @@
import "@/styles/globals.css";
import Script from "next/script";
export default function App({ Component, pageProps }) {
return (
<>
<Script
src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/1.7.0/flowbite.min.js"
strategy="beforeInteractive"
/>
<Component {...pageProps} />
</>
);
}

View File

@@ -0,0 +1,18 @@
import { Html, Head, Main, NextScript } from "next/document";
export default function Document() {
return (
<Html lang="en">
<Head>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/1.7.0/flowbite.min.css"
rel="stylesheet"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}

View File

@@ -0,0 +1,52 @@
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 framework to easily create LLM powered bots over any
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>
</>
);
}