Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
botway(core): back to work
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Jul 28, 2023
1 parent 9ed493b commit 1ad15b8
Show file tree
Hide file tree
Showing 6 changed files with 1,027 additions and 1,977 deletions.
29 changes: 29 additions & 0 deletions core/app/api/ai/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { NextResponse } from "next/server";
import { fetcher } from "@/tools/fetch";
import createClient from "@/supabase/server";

export const revalidate = 0;

export async function POST(request: Request) {
const body = await request.json();

const supabase = createClient();

const {
data: { user: user },
error: userError,
} = await supabase.auth.getUser();

if (userError) {
return NextResponse.json({ error: userError });
}

const ai = await fetcher(`https://ai-botway.hop.sh/api/new-bot`, {
method: "POST",
body: JSON.stringify({
prompt: body.prompt,
}),
});

return NextResponse.json({ message: "Success", answer: ai.data });
}
53 changes: 45 additions & 8 deletions core/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import { fetcher } from "@/tools/fetch";
import { Button } from "@/components/Button";
import { capitalizeFirstLetter } from "@/tools/text";
import { useCompletion } from "ai/react";

export const revalidate = 0;

Expand Down Expand Up @@ -142,6 +143,25 @@ const Home = ({ user }: any) => {
async function submitPrompt(formData: any) {
try {
setIsLoading(true);

const newBot = await fetcher("/api/ai", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ prompt: formData.prompt }),
});

if (newBot.message === "Success") {
toast.success(
"You have successfully created a new bot project",
toastStyle,
);

setPromptOpen(false);
} else {
toast.error(newBot.error, toastStyle);

setPromptOpen(false);
}
} catch (e: any) {
toast.error(e.message, toastStyle);
} finally {
Expand Down Expand Up @@ -882,7 +902,7 @@ const Home = ({ user }: any) => {
</Transition.Child>

<div className="fixed inset-0 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<div className="flex min-h-full mx-4 md:mx-32 items-center justify-center p-4 text-center">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
Expand All @@ -892,14 +912,29 @@ const Home = ({ user }: any) => {
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="min-w-full bg-secondary transform overflow-scroll rounded-xl p-0 text-left align-middle shadow-xl transition-all border border-gray-800">
<Dialog.Panel className="min-w-full bg-secondary transform overflow-scroll rounded-2xl p-0 text-left align-middle shadow-xl transition-all border border-gray-800">
<div>
{promptOpen ? (
isLoading ? (
<div className="m-4 gap-4 flex justify-between items-center">
<h1 className="text-base text-white">Creating</h1>
<LoadingDots />
</div>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div
className="gap-4 flex justify-between items-center"
style={{ margin: "22px" }}
>
<h1 className="text-sm md:text-xl text-white">
Creating
</h1>
<LoadingDots />
</div>
</Transition.Child>
) : (
<Formik
initialValues={{
Expand All @@ -910,7 +945,7 @@ const Home = ({ user }: any) => {
{() => (
<Form className="mt-2 column overflow-scroll min-h-full">
<Field
className="border-none outline-none focus:outline-none focus-within:outline-none bg-secondary text-xl placeholder:text-xl placeholder:text-gray-400 text-white rounded-sm block w-full p-4"
className="border-none outline-none focus:outline-none focus-within:outline-none bg-secondary text-sm md:text-xl placeholder:text-sm md:placeholder:text-xl placeholder:text-gray-400 text-white rounded-sm block w-full p-4"
id="prompt"
name="prompt"
type="text"
Expand All @@ -921,7 +956,9 @@ const Home = ({ user }: any) => {
</Formik>
)
) : (
<></>
<div className="items-center" style={{ margin: "22px" }}>
<h1 className="text-sm md:text-xl text-white">Done 🤝</h1>
</div>
)}
</div>
</Dialog.Panel>
Expand Down
36 changes: 18 additions & 18 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,47 @@
},
"dependencies": {
"@faker-js/faker": "^8.0.2",
"@headlessui/react": "^1.7.15",
"@headlessui/react": "^1.7.16",
"@primer/octicons-react": "^19.4.0",
"@supabase/auth-helpers-nextjs": "^0.7.2",
"@supabase/supabase-js": "^2.26.0",
"@tanstack/react-query": "^4.29.19",
"ai": "^2.1.17",
"@supabase/auth-helpers-nextjs": "^0.7.3",
"@supabase/supabase-js": "^2.31.0",
"@tanstack/react-query": "^4.32.0",
"ai": "^2.1.27",
"ajv": "^8.12.0",
"autoprefixer": "10.4.14",
"bcryptjs": "^2.4.3",
"boring-avatars": "^1.10.1",
"clsx": "^1.2.1",
"clsx": "^2.0.0",
"csstype": "^3.1.2",
"encoding": "^0.1.13",
"flowbite": "^1.7.0",
"flowbite-react": "^0.4.10",
"flowbite-react": "^0.5.0",
"formik": "^2.4.2",
"graphql": "^16.7.1",
"jose": "^4.14.4",
"marked": "^5.1.1",
"marked": "^5.1.2",
"mini-svg-data-uri": "^1.4.4",
"next": "13.4.9",
"octokit": "^2.1.0",
"postcss": "8.4.25",
"next": "13.4.12",
"octokit": "^3.1.0",
"postcss": "8.4.27",
"postcss-nested": "^6.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hot-toast": "^2.4.1",
"sass": "^1.63.6",
"slug": "^8.2.2",
"sass": "^1.64.1",
"slug": "^8.2.3",
"swr": "^2.2.0",
"tailwindcss": "3.3.2",
"tailwindcss": "3.3.3",
"uuid": "^9.0.0",
"yup": "^1.2.0"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.9",
"@types/bcryptjs": "^2.4.2",
"@types/marked": "^5.0.0",
"@types/node": "^20.4.1",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"@types/marked": "^5.0.1",
"@types/node": "^20.4.5",
"@types/react": "18.2.17",
"@types/react-dom": "18.2.7",
"@types/slug": "^5.0.3",
"tailwindcss-animate": "^1.0.6",
"typescript": "^5.1.6"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"packageManager": "[email protected]",
"devDependencies": {
"prettier": "^3.0.0",
"turbo": "^1.10.7"
"turbo": "^1.10.12"
}
}
2 changes: 1 addition & 1 deletion packages/botwaygo
Loading

0 comments on commit 1ad15b8

Please sign in to comment.