diff --git a/src/components/ChatWindow.tsx b/src/components/ChatWindow.tsx index c40b371e79..970e7cf609 100644 --- a/src/components/ChatWindow.tsx +++ b/src/components/ChatWindow.tsx @@ -36,6 +36,7 @@ interface ChatWindowProps extends HeaderProps { fullscreen?: boolean; scrollToBottom?: boolean; displaySettings?: boolean; // Controls if settings are displayed at the bottom of the ChatWindow + openSorryDialog?: () => void; } const messageListId = "chat-window-message-list"; @@ -49,6 +50,7 @@ const ChatWindow = ({ fullscreen, scrollToBottom, displaySettings, + openSorryDialog, }: ChatWindowProps) => { const [t] = useTranslation(); const [hasUserScrolled, setHasUserScrolled] = useState(false); @@ -76,6 +78,18 @@ const ChatWindow = ({ } }); + const handleChangeWebSearch = (value: boolean) => { + // Change this value when we can no longer support web search + const WEB_SEARCH_ALLOWED = false; + + if (WEB_SEARCH_ALLOWED) { + setIsWebSearchEnabled(value); + } else { + openSorryDialog?.(); + setIsWebSearchEnabled(false); + } + }; + return (
@@ -135,15 +151,17 @@ const ChatWindow = ({ )}
{displaySettings && ( -
-
-

Web search

- + <> +
+
+

Web search

+ +
-
+ )}
); diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx index 70f96ac383..caeeee1cc5 100644 --- a/src/components/Dialog.tsx +++ b/src/components/Dialog.tsx @@ -4,21 +4,19 @@ import Button from "./Button"; import { useTranslation } from "next-i18next"; import clsx from "clsx"; -export default function Dialog({ +const Dialog = ({ header, children, isShown, close, footerButton, - contentClassName, }: { header: React.ReactNode; children: React.ReactNode; isShown: boolean; close: () => void; footerButton?: React.ReactNode; - contentClassName?: string; -}) { +}) => { const [t] = useTranslation(); if (!isShown) { return <>{null}; @@ -48,8 +46,7 @@ export default function Dialog({ {/*body*/}
{children} @@ -68,4 +65,6 @@ export default function Dialog({
); -} +}; + +export default Dialog; diff --git a/src/components/Drawer.tsx b/src/components/Drawer.tsx index 8902b01eeb..395014fba2 100644 --- a/src/components/Drawer.tsx +++ b/src/components/Drawer.tsx @@ -283,8 +283,8 @@ const AuthItem: React.FC<{ const [t] = useTranslation(); const icon = session?.user ? : ; const text = session?.user - ? `${t("SIGN_IN", { ns: "drawer" })}` - : `${t("SIGN_OUT", { ns: "drawer" })}`; + ? `${t("SIGN_OUT", { ns: "drawer" })}` + : `${t("SIGN_IN", { ns: "drawer" })}`; const onClick = session?.user ? signOut : signIn; return ; diff --git a/src/components/HelpDialog.tsx b/src/components/HelpDialog.tsx index 5e1aa36188..971c48d347 100644 --- a/src/components/HelpDialog.tsx +++ b/src/components/HelpDialog.tsx @@ -13,14 +13,15 @@ export default function HelpDialog({ const [t] = useTranslation(); return ( -
+

AgentGPT {t("INTRODUCING_AGENTGPT", { ns: "help" })}

+
{t("TO_LEARN_MORE_ABOUT_AGENTGPT", { ns: "help", @@ -31,9 +32,9 @@ export default function HelpDialog({ > {t("AGENTGPT_DOCUMENTATION", { ns: "help" })} -
-

{t("FOLLOW_THE_JOURNEY", { ns: "help" })}

+
+

{t("FOLLOW_THE_JOURNEY", { ns: "help" })}

} - contentClassName="text-md relative flex flex-col gap-2 p-2 leading-relaxed" >

Get your own OpenAI API key{" "} @@ -213,56 +212,58 @@ export const SettingsDialog: React.FC<{

)} - - - {`${t("API_KEY", { - ns: "settings", - })}`} - - } - placeholder={"sk-..."} - type="password" - value={settings.customApiKey} - onChange={(e) => updateSettings("customApiKey", e.target.value)} - /> - - - - {`${t("LABEL_MODEL", { - ns: "settings", - })}`} - - } - type="combobox" - value={settings.customModelName} - onChange={() => null} - setValue={(e) => updateSettings("customModelName", e)} - attributes={{ options: GPT_MODEL_NAMES }} - disabled={disabled} - /> - - - Mode: - - } - value={agentMode} - disabled={agent !== null} - onChange={() => null} - setValue={updateAgentMode as (agentMode: string) => void} - type="combobox" - toolTipProperties={{ - message: `${AUTOMATIC_MODE} (Default): Agent automatically executes every task. \n\n${PAUSE_MODE}: Agent pauses after every set of task(s)`, - disabled: false, - }} - attributes={{ options: [AUTOMATIC_MODE, PAUSE_MODE] }} - /> - +
+ + + {`${t("API_KEY", { + ns: "settings", + })}`} + + } + placeholder={"sk-..."} + type="password" + value={settings.customApiKey} + onChange={(e) => updateSettings("customApiKey", e.target.value)} + /> + + + + {`${t("LABEL_MODEL", { + ns: "settings", + })}`} + + } + type="combobox" + value={settings.customModelName} + onChange={() => null} + setValue={(e) => updateSettings("customModelName", e)} + attributes={{ options: GPT_MODEL_NAMES }} + disabled={disabled} + /> + + + Mode: + + } + value={agentMode} + disabled={agent !== null} + onChange={() => null} + setValue={updateAgentMode as (agentMode: string) => void} + type="combobox" + toolTipProperties={{ + message: `${AUTOMATIC_MODE} (Default): Agent automatically executes every task. \n\n${PAUSE_MODE}: Agent pauses after every set of task(s)`, + disabled: false, + }} + attributes={{ options: [AUTOMATIC_MODE, PAUSE_MODE] }} + /> + +
); }; diff --git a/src/components/SignInDialog.tsx b/src/components/SignInDialog.tsx new file mode 100644 index 0000000000..01c8df4040 --- /dev/null +++ b/src/components/SignInDialog.tsx @@ -0,0 +1,30 @@ +import React from "react"; +import Dialog from "./Dialog"; +import Button from "./Button"; +import { useAuth } from "../hooks/useAuth"; + +export interface SignInDialogProps { + show: boolean; + close: () => void; +} + +export const SignInDialog = ({ show, close }: SignInDialogProps) => { + const { signIn } = useAuth(); + + return ( + void signIn()}>Sign in} + > +

+ Please{" "} + void signIn()}> + sign in + {" "} + to deploy an Agent! 🤖 +

+
+ ); +}; diff --git a/src/components/SorryDialog.tsx b/src/components/SorryDialog.tsx new file mode 100644 index 0000000000..979676780d --- /dev/null +++ b/src/components/SorryDialog.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import Dialog from "./Dialog"; + +export interface WebSearchDialogProps { + show: boolean; + close: () => void; +} + +export const SorryDialog = ({ show, close }: WebSearchDialogProps) => { + return ( + +

Due to costs, we've had to momentarily disable web search 🌐

+
+

+ Please monitor our  + + Roadmap +   + to understand when it may be back up. +

+
+ ); +}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 479187a80f..b60a31fd7a 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -29,6 +29,8 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import { useSettings } from "../hooks/useSettings"; import { languages } from "../utils/languages"; import nextI18NextConfig from "../../next-i18next.config.js"; +import { SorryDialog } from "../components/SorryDialog"; +import { SignInDialog } from "../components/SignInDialog"; const Home: NextPage = () => { const { i18n } = useTranslation(); @@ -53,6 +55,8 @@ const Home: NextPage = () => { const [showHelpDialog, setShowHelpDialog] = React.useState(false); const [showSettingsDialog, setShowSettingsDialog] = React.useState(false); + const [showSorryDialog, setShowSorryDialog] = React.useState(false); + const [showSignInDialog, setShowSignInDialog] = React.useState(false); const [hasSaved, setHasSaved] = React.useState(false); const agentUtils = useAgent(); @@ -98,6 +102,12 @@ const Home: NextPage = () => { agent != null || isEmptyOrBlank(name) || isEmptyOrBlank(goalInput); const handleNewGoal = () => { + // Do not force login locally for people that don't have auth setup + if (session === null && process.env.NODE_ENV === "production") { + setShowSignInDialog(true); + return; + } + const newAgent = new AutonomousAgent( name.trim(), goalInput.trim(), @@ -187,6 +197,14 @@ const Home: NextPage = () => { show={showSettingsDialog} close={() => setShowSettingsDialog(false)} /> + setShowSorryDialog(false)} + /> + setShowSignInDialog(false)} + />
setShowHelpDialog(true)} @@ -247,7 +265,8 @@ const Home: NextPage = () => { : undefined } scrollToBottom - // displaySettings (Disable web search) + displaySettings + openSorryDialog={() => setShowSorryDialog(true)} /> {tasks.length > 0 && }