From ba64543dd72db4a0c318a72909aedc05b5ffb277 Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Sat, 21 Sep 2024 12:55:54 -0700 Subject: [PATCH] Updated modals for clarity (#2529) * udpated modals for clarity * fix build --- .../initialSetup/welcome/WelcomeModal.tsx | 247 +++--------------- web/src/components/llm/ApiKeyForm.tsx | 7 +- web/src/components/llm/ApiKeyModal.tsx | 4 +- 3 files changed, 38 insertions(+), 220 deletions(-) diff --git a/web/src/components/initialSetup/welcome/WelcomeModal.tsx b/web/src/components/initialSetup/welcome/WelcomeModal.tsx index 5f32d614d..0cf74e313 100644 --- a/web/src/components/initialSetup/welcome/WelcomeModal.tsx +++ b/web/src/components/initialSetup/welcome/WelcomeModal.tsx @@ -24,50 +24,21 @@ export function _CompletedWelcomeFlowDummyComponent() { return null; } -function UsageTypeSection({ - title, - description, - callToAction, - onClick, -}: { - title: string; - description: string | JSX.Element; - callToAction: string; - onClick: () => void; -}) { - return ( -
- {title} -
{description}
-
{ - e.preventDefault(); - onClick(); - }} - > -
- {callToAction} -
-
-
- ); -} - export function _WelcomeModal({ user }: { user: User | null }) { const router = useRouter(); const [selectedFlow, setSelectedFlow] = useState( null ); - const [isHidden, setIsHidden] = useState(false); + const [canBegin, setCanBegin] = useState(false); const [apiKeyVerified, setApiKeyVerified] = useState(false); const [providerOptions, setProviderOptions] = useState< WellKnownLLMProviderDescriptor[] >([]); const { refreshProviderInfo } = useProviderStatus(); - const clientSetWelcomeFlowComplete = async () => { setWelcomeFlowComplete(); refreshProviderInfo(); + router.refresh(); }; useEffect(() => { @@ -81,193 +52,35 @@ export function _WelcomeModal({ user }: { user: User | null }) { fetchProviderInfo(); }, []); - if (isHidden) { - return null; - } - - let title; - let body; - switch (selectedFlow) { - case "search": - title = undefined; - body = ( -
- setSelectedFlow(null)} /> -
- - {apiKeyVerified && ( - - )} - Step 1: Setup an LLM - -
- {apiKeyVerified ? ( - - LLM setup complete! -

- If you want to change the key later, you'll be able to - easily to do so in the Admin Panel. -
- ) : ( - setApiKeyVerified(true)} - providerOptions={providerOptions} - /> - )} -
- - Step 2: Connect Data Sources - -
- - Connectors are the way that Danswer gets data from your - organization's various data sources. Once setup, we'll - automatically sync data from your apps and docs into Danswer, so - you can search through all of them in one place. - - -
- { - e.preventDefault(); - clientSetWelcomeFlowComplete(); - router.push("/admin/add-connector"); - }} - className="w-fit mx-auto" - > - - -
-
-
-
- ); - break; - case "chat": - title = undefined; - body = ( -
- setSelectedFlow(null)} /> - -
- - {apiKeyVerified && ( - - )} - Step 1: Setup an LLM - -
- {apiKeyVerified ? ( - - LLM setup complete! -

- If you want to change the key later or choose a different LLM, - you'll be able to easily to do so in the Admin Panel. -
- ) : ( -
- setApiKeyVerified(true)} - providerOptions={providerOptions} - /> -
- )} -
- - - Step 2: Start Chatting! - - - - Click the button below to start chatting with the LLM setup above! - Don't worry, if you do decide later on you want to connect - your organization's knowledge, you can always do that in the{" "} - { - e.preventDefault(); - router.push("/admin/add-connector"); - }} - > - Admin Panel - - . - - -
- { - e.preventDefault(); - clientSetWelcomeFlowComplete(); - router.push("/chat"); - setIsHidden(true); - }} - className="w-fit mx-auto" - > - - -
-
-
- ); - break; - default: - title = "🎉 Welcome to Danswer"; - body = ( - <> -
- How are you planning on using Danswer? -
- - - If you're looking to search through, chat with, or ask - direct questions of your organization's knowledge, then - this is the option for you! - - } - callToAction="Get Started" - onClick={() => setSelectedFlow("search")} - /> - - - If you're looking for a pure ChatGPT-like experience, then - this is the option for you! - - } - callToAction="Get Started" - onClick={() => { - setSelectedFlow("chat"); - }} - /> - - {/* TODO: add a Slack option here */} - {/* - */} - - ); - } - return ( - -
{body}
+ +
+ + Danswer brings all your company's knowledge to your fingertips, + ready to be accessed instantly. + + + To get started, we need to set up an API key for the Language Model + (LLM) provider. This key allows Danswer to interact with the AI model, + enabling intelligent responses to your queries. + + +
+ { + router.refresh(); + refreshProviderInfo(); + setCanBegin(true); + }} + providerOptions={providerOptions} + /> +
+ + +
); } diff --git a/web/src/components/llm/ApiKeyForm.tsx b/web/src/components/llm/ApiKeyForm.tsx index 1a1f24d91..f307e0c74 100644 --- a/web/src/components/llm/ApiKeyForm.tsx +++ b/web/src/components/llm/ApiKeyForm.tsx @@ -8,9 +8,11 @@ import { CustomLLMProviderUpdateForm } from "@/app/admin/configuration/llm/Custo export const ApiKeyForm = ({ onSuccess, providerOptions, + hidePopup, }: { onSuccess: () => void; providerOptions: WellKnownLLMProviderDescriptor[]; + hidePopup?: boolean; }) => { const [popup, setPopup] = useState<{ message: string; @@ -33,7 +35,10 @@ export const ApiKeyForm = ({ return (
- {popup && } + {!hidePopup && popup && ( + + )} + diff --git a/web/src/components/llm/ApiKeyModal.tsx b/web/src/components/llm/ApiKeyModal.tsx index 706413b4e..8a6342b4c 100644 --- a/web/src/components/llm/ApiKeyModal.tsx +++ b/web/src/components/llm/ApiKeyModal.tsx @@ -21,10 +21,10 @@ export const ApiKeyModal = ({ hide }: { hide: () => void }) => { return ( hide()} > -
+
Please provide an API Key below in order to start using