Skip to content

Commit

Permalink
Onboarding nits (#2907)
Browse files Browse the repository at this point in the history
* temporary stash

* welcome flow

* minor update

* k

* minor updates to welcome flow
  • Loading branch information
pablonyx authored Oct 27, 2024
1 parent a1bfa78 commit 179dc41
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 100 deletions.
14 changes: 13 additions & 1 deletion backend/danswer/one_shot_answer/answer_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,19 @@ def stream_answer_objects(

persona = temporary_persona if temporary_persona else chat_session.persona

llm, fast_llm = get_llms_for_persona(persona=persona)
try:
llm, fast_llm = get_llms_for_persona(persona=persona)
except ValueError as e:
logger.error(
f"Failed to initialize LLMs for persona '{persona.name}': {str(e)}"
)
if "No LLM provider" in str(e):
raise ValueError(
"Please configure a Generative AI model to use this feature."
) from e
raise ValueError(
"Failed to initialize the AI model. Please check your configuration and try again."
) from e

llm_tokenizer = get_tokenizer(
model_name=llm.config.model_name,
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/assistants/gallery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default async function GalleryPage({
chatSessions,
folders,
openedFolders,
shouldShowWelcomeModal,
toggleSidebar,
shouldShowWelcomeModal,
} = data;

return (
Expand Down
6 changes: 3 additions & 3 deletions web/src/app/assistants/mine/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { InstantSSRAutoRefresh } from "@/components/SSRAutoRefresh";
import { WelcomeModal } from "@/components/initialSetup/welcome/WelcomeModalWrapper";

import { fetchChatData } from "@/lib/chat/fetchChatData";
import { unstable_noStore as noStore } from "next/cache";
import { redirect } from "next/navigation";
import WrappedAssistantsMine from "./WrappedAssistantsMine";
import { AssistantsProvider } from "@/components/context/AssistantsContext";
import { WelcomeModal } from "@/components/initialSetup/welcome/WelcomeModalWrapper";

export default async function GalleryPage({
searchParams,
Expand All @@ -24,8 +24,8 @@ export default async function GalleryPage({
chatSessions,
folders,
openedFolders,
shouldShowWelcomeModal,
toggleSidebar,
shouldShowWelcomeModal,
} = data;

return (
Expand Down
4 changes: 3 additions & 1 deletion web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export function ChatPage({

const { assistants: availableAssistants, finalAssistants } = useAssistants();

const [showApiKeyModal, setShowApiKeyModal] = useState(true);
const [showApiKeyModal, setShowApiKeyModal] = useState(
!shouldShowWelcomeModal
);

const { user, isAdmin, isLoadingUser } = useUser();

Expand Down
24 changes: 5 additions & 19 deletions web/src/app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ import { CCPairBasicInfo, DocumentSet, Tag, User } from "@/lib/types";
import { cookies } from "next/headers";
import { SearchType } from "@/lib/search/interfaces";
import { Persona } from "../admin/assistants/interfaces";
import {
WelcomeModal,
hasCompletedWelcomeFlowSS,
} from "@/components/initialSetup/welcome/WelcomeModalWrapper";
import { unstable_noStore as noStore } from "next/cache";
import { InstantSSRAutoRefresh } from "@/components/SSRAutoRefresh";
import { personaComparator } from "../admin/assistants/lib";
import { FullEmbeddingModelResponse } from "@/components/embedding/interfaces";
import { NoSourcesModal } from "@/components/initialSetup/search/NoSourcesModal";
import { NoCompleteSourcesModal } from "@/components/initialSetup/search/NoCompleteSourceModal";
import { ChatPopup } from "../chat/ChatPopup";
import {
FetchAssistantsResponse,
Expand All @@ -38,6 +32,10 @@ import { fetchLLMProvidersSS } from "@/lib/llm/fetchLLMs";
import { LLMProviderDescriptor } from "../admin/configuration/llm/interfaces";
import { AssistantsProvider } from "@/components/context/AssistantsContext";
import { headers } from "next/headers";
import {
hasCompletedWelcomeFlowSS,
WelcomeModal,
} from "@/components/initialSetup/welcome/WelcomeModalWrapper";

export default async function Home({
searchParams,
Expand Down Expand Up @@ -170,14 +168,6 @@ export default async function Home({
ccPairs.length === 0 &&
!shouldShowWelcomeModal;

const shouldDisplaySourcesIncompleteModal =
!ccPairs.some(
(ccPair) => ccPair.has_successful_run && ccPair.docs_indexed > 0
) &&
!shouldDisplayNoSourcesModal &&
!shouldShowWelcomeModal &&
(!user || user.role == "admin");

const sidebarToggled = cookies().get(SIDEBAR_TOGGLED_COOKIE_NAME);
const agenticSearchToggle = cookies().get(AGENTIC_SEARCH_TYPE_COOKIE_NAME);

Expand All @@ -192,12 +182,8 @@ export default async function Home({
return (
<>
<HealthCheckBanner />
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
<InstantSSRAutoRefresh />
{shouldDisplayNoSourcesModal && <NoSourcesModal />}
{shouldDisplaySourcesIncompleteModal && (
<NoCompleteSourcesModal ccPairs={ccPairs} />
)}
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
{/* ChatPopup is a custom popup that displays a admin-specified message on initial user visit.
Only used in the EE version of the app. */}
<ChatPopup />
Expand Down
45 changes: 30 additions & 15 deletions web/src/components/chat_search/UnconfiguredProviderText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,41 @@ import { useProviderStatus } from "./ProviderContext";

export default function CredentialNotConfigured({
showConfigureAPIKey,
noSources,
}: {
showConfigureAPIKey: () => void;
noSources?: boolean;
}) {
const { shouldShowConfigurationNeeded } = useProviderStatus();

if (!shouldShowConfigurationNeeded) {
return null;
}

return (
<p className="text-base text-center w-full text-subtle">
Please note that you have not yet configured an LLM provider. You can
configure one{" "}
<button
onClick={showConfigureAPIKey}
className="text-link hover:underline cursor-pointer"
>
here
</button>
.
</p>
<>
{noSources ? (
<p className="text-base text-center w-full text-subtle">
You have not yet added any sources. Please add{" "}
<a
href="/admin/add-connector"
className="text-link hover:underline cursor-pointer"
>
a source
</a>{" "}
to continue.
</p>
) : (
shouldShowConfigurationNeeded && (
<p className="text-base text-center w-full text-subtle">
Please note that you have not yet configured an LLM provider. You
can configure one{" "}
<button
onClick={showConfigureAPIKey}
className="text-link hover:underline cursor-pointer"
>
here
</button>
.
</p>
)
)}
</>
);
}
55 changes: 0 additions & 55 deletions web/src/components/initialSetup/search/NoSourcesModal.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions web/src/components/initialSetup/welcome/WelcomeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export function _WelcomeModal({ user }: { user: User | null }) {
{popup}

<Modal
onOutsideClick={() => {
setWelcomeFlowComplete();
router.refresh();
}}
title={"Welcome to Danswer!"}
width="w-full max-h-[900px] overflow-y-scroll max-w-3xl"
>
Expand Down
9 changes: 4 additions & 5 deletions web/src/components/llm/ApiKeyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ export const ApiKeyModal = ({
}
return (
<Modal
title="Set an API Key!"
title="Configure a Generative AI Model"
width="max-w-3xl w-full"
onOutsideClick={() => hide()}
>
<>
<div className="mb-5 text-sm text-gray-700">
Please provide an API Key below in order to start using Danswer – you
can always change this later.
Please provide an API Key – you can always change this or switch
models later.
<br />
If you&apos;d rather look around first, you can
If you would rather look around first, you can{" "}
<strong onClick={() => hide()} className="text-link cursor-pointer">
{" "}
skip this step
</strong>
.
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/search/SearchSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import UnconfiguredProviderText from "../chat_search/UnconfiguredProviderText";
import { DateRangePickerValue } from "@tremor/react";
import { Tag } from "@/lib/types";
import { isEqual } from "lodash";
import { WelcomeModal } from "../initialSetup/welcome/WelcomeModalWrapper";

export type searchState =
| "input"
Expand Down Expand Up @@ -783,6 +784,7 @@ export const SearchSection = ({
</div>

<UnconfiguredProviderText
noSources={shouldDisplayNoSources}
showConfigureAPIKey={() => setShowApiKeyModal(true)}
/>

Expand Down

0 comments on commit 179dc41

Please sign in to comment.