Spaces:
Sleeping
Sleeping
random prompt
Browse filesFiles changed (5)
12345678910111213141516171819202122232425262728293031323317 unmodified lines51525354555657import { useState } from "react";import { useLocalStorage } from "react-use";import { ArrowUp, Dice1, Dice6 } from "lucide-react";import { useRouter } from "next/navigation";import { Button } from "@/components/ui/button";import { useLoginModal } from "@/components/contexts/login-context";import { PromptBuilder } from "./prompt-builder";import { EnhancedSettings } from "@/types";import { Settings } from "./settings";import classNames from "classnames";const prompts = ["Create a landing page for a SaaS product, with a hero section, a features section, a pricing section, and a call to action section.","Create a portfolio website for a designer, with a hero section, a projects section, a about section, and a contact section.","Create a blog website for a writer, with a hero section, a blog section, a about section, and a contact section.","Create a Tic Tac Toe game, with a game board, a history section, and a score section.","Create a Weather App, with a search bar, a weather section, and a forecast section.","Create a Calculator, with a calculator section, and a history section.","Create a Todo List, with a todo list section, and a history section.","Create a Calendar, with a calendar section, and a history section.","Create a Music Player, with a music player section, and a history section.","Create a Quiz App, with a quiz section, and a history section.","Create a Pomodoro Timer, with a timer section, and a history section.","Create a Notes App, with a notes section, and a history section.","Create a Task Manager, with a task list section, and a history section.","Create a Password Generator, with a password generator section, and a history section.","Create a Currency Converter, with a currency converter section, and a history section.","Create a Dictionary, with a dictionary section, and a history section.",];export const FakeAskAi = () => {const router = useRouter();17 unmodified linesconst randomPrompt = () => {setRandomPromptLoading(true);setTimeout(() => {setPrompt(prompts[Math.floor(Math.random() * prompts.length)]);setRandomPromptLoading(false);}, 400);};123456789101112131417 unmodified lines323334353637383940import { useState } from "react";import { useLocalStorage } from "react-use";import { ArrowUp, Dice6 } from "lucide-react";import { useRouter } from "next/navigation";import { Button } from "@/components/ui/button";import { PromptBuilder } from "./prompt-builder";import { EnhancedSettings } from "@/types";import { Settings } from "./settings";import classNames from "classnames";import { PROMPTS_FOR_AI } from "@/lib/prompts";export const FakeAskAi = () => {const router = useRouter();17 unmodified linesconst randomPrompt = () => {setRandomPromptLoading(true);setTimeout(() => {setPrompt(PROMPTS_FOR_AI[Math.floor(Math.random() * PROMPTS_FOR_AI.length)]);setRandomPromptLoading(false);}, 400);};
12345613 unmodified lines20212223242543 unmodified lines69707172737475767778798071 unmodified lines152153154155156157103 unmodified lines2612622632642652669 unmodified lines276277278279280281282import { useRef, useState } from "react";import classNames from "classnames";import { ArrowUp, ChevronDown, CircleStop } from "lucide-react";import { useLocalStorage, useUpdateEffect, useMount } from "react-use";import { toast } from "sonner";13 unmodified linesimport { Settings } from "./settings";import { useProModal } from "@/components/contexts/pro-context";import { MAX_FREE_PROJECTS } from "@/lib/utils";export const AskAi = ({project,43 unmodified lines);const [think, setThink] = useState("");const [openThink, setOpenThink] = useState(false);const handleThink = (think: string) => {setThink(think);setIsThinking(true);setOpenThink(true);};useMount(() => {if (promptStorage && promptStorage.trim() !== "") {71 unmodified lines}}, [think]);return (<div className="p-3 w-full"><div className="relative bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent z-20 w-full group">103 unmodified lines}}}/></div><div className="flex items-center justify-between gap-2 px-4 pb-3 mt-2"><div className="flex-1 flex items-center justify-start gap-1.5 flex-wrap">9 unmodified lines/>{!isNew && <Uploader project={project} />}{isNew && <ReImagine onRedesign={(md) => callAi(md)} />}{!isNew && <Selector />}</div><div className="flex items-center justify-end gap-2"><Button12345613 unmodified lines2021222324252643 unmodified lines7071727374757671 unmodified lines148149150151152153154155156157158159160161162163103 unmodified lines2672682692702712722732742752762772782792802812822832842852869 unmodified lines296297298299300301302import { useRef, useState } from "react";import classNames from "classnames";import { ArrowUp, ChevronDown, CircleStop, Dice6 } from "lucide-react";import { useLocalStorage, useUpdateEffect, useMount } from "react-use";import { toast } from "sonner";13 unmodified linesimport { Settings } from "./settings";import { useProModal } from "@/components/contexts/pro-context";import { MAX_FREE_PROJECTS } from "@/lib/utils";import { PROMPTS_FOR_AI } from "@/lib/prompts";export const AskAi = ({project,43 unmodified lines);const [think, setThink] = useState("");const [openThink, setOpenThink] = useState(false);const [randomPromptLoading, setRandomPromptLoading] = useState(false);useMount(() => {if (promptStorage && promptStorage.trim() !== "") {71 unmodified lines}}, [think]);const randomPrompt = () => {setRandomPromptLoading(true);setTimeout(() => {setPrompt(PROMPTS_FOR_AI[Math.floor(Math.random() * PROMPTS_FOR_AI.length)]);setRandomPromptLoading(false);}, 400);};return (<div className="p-3 w-full"><div className="relative bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent z-20 w-full group">103 unmodified lines}}}/>{isNew && !isAiWorking && isSameHtml && (<Buttonsize="iconXs"variant="outline"className="!rounded-md -translate-y-2 -translate-x-4"onClick={() => randomPrompt()}><Dice6className={classNames("size-4", {"animate-spin animation-duration-500": randomPromptLoading,})}/></Button>)}</div><div className="flex items-center justify-between gap-2 px-4 pb-3 mt-2"><div className="flex-1 flex items-center justify-start gap-1.5 flex-wrap">9 unmodified lines/>{!isNew && <Uploader project={project} />}{isNew && <ReImagine onRedesign={(md) => callAi(md)} />}{!isNew && !isSameHtml && <Selector />}</div><div className="flex items-center justify-end gap-2"><Button
57 unmodified lines5859606162636457 unmodified lines});useEffect(() => {if (hasUnsavedChanges && !isAiWorking) {setShowSavePopup(true);} else {setShowSavePopup(false);57 unmodified lines5859606162636457 unmodified lines});useEffect(() => {if (hasUnsavedChanges && !isAiWorking && project?.name) {setShowSavePopup(true);} else {setShowSavePopup(false);
90 unmodified lines91929394959697989990 unmodified linesCreate Project</div>)}{projects.map((project: ProjectType) => (<ProjectCardkey={project.name}project={project}onDelete={() => onDelete(project)}/>90 unmodified lines91929394959697989990 unmodified linesCreate Project</div>)}{projects.map((project: ProjectType, index: number) => (<ProjectCardkey={index}project={project}onDelete={() => onDelete(project)}/>
145 unmodified lines146147148149145 unmodified lines</html>\`\`\`IMPORTANT: While creating a new page, UPDATE ALL THE OTHERS (using the UPDATE_PAGE_START and SEARCH/REPLACE format) pages to add or replace the link to the new page, otherwise the user will not be able to navigate to the new page. (Dont use onclick to navigate, only href)No need to explain what you did. Just return the expected result.`145 unmodified lines146147148149150151152153154155156157158159160161162163164165166167168145 unmodified lines</html>\`\`\`IMPORTANT: While creating a new page, UPDATE ALL THE OTHERS (using the UPDATE_PAGE_START and SEARCH/REPLACE format) pages to add or replace the link to the new page, otherwise the user will not be able to navigate to the new page. (Dont use onclick to navigate, only href)No need to explain what you did. Just return the expected result.`export const PROMPTS_FOR_AI = ["Create a landing page for a SaaS product, with a hero section, a features section, a pricing section, and a call to action section.","Create a portfolio website for a designer, with a hero section, a projects section, a about section, and a contact section.","Create a blog website for a writer, with a hero section, a blog section, a about section, and a contact section.","Create a Tic Tac Toe game, with a game board, a history section, and a score section.","Create a Weather App, with a search bar, a weather section, and a forecast section.","Create a Calculator, with a calculator section, and a history section.","Create a Todo List, with a todo list section, and a history section.","Create a Calendar, with a calendar section, and a history section.","Create a Music Player, with a music player section, and a history section.","Create a Quiz App, with a quiz section, and a history section.","Create a Pomodoro Timer, with a timer section, and a history section.","Create a Notes App, with a notes section, and a history section.","Create a Task Manager, with a task list section, and a history section.","Create a Password Generator, with a password generator section, and a history section.","Create a Currency Converter, with a currency converter section, and a history section.","Create a Dictionary, with a dictionary section, and a history section.",];
components/editor/ask-ai/fake-ask.tsx+5-22
components/editor/ask-ai/index.tsx+28-8
components/editor/index.tsx+1-1
components/my-projects/index.tsx+2-2
lib/prompts.ts+20-1