Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ import {
SubLabel,
TextArrayField,
TextFormField,
BooleanFormField,
} from "@/components/admin/connectors/Field";
import { useState } from "react";
import { Bubble } from "@/components/Bubble";
import { GroupsIcon } from "@/components/icons/icons";
import { useSWRConfig } from "swr";
import { useUserGroups } from "@/lib/hooks";
import { FullLLMProvider } from "./interfaces";
import { PopupSpec } from "@/components/admin/connectors/Popup";
import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled";
import * as Yup from "yup";
import isEqual from "lodash/isEqual";
import { IsPublicGroupSelector } from "@/components/IsPublicGroupSelector";
Expand Down
17 changes: 2 additions & 15 deletions web/src/app/admin/configuration/llm/LLMProviderUpdateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ import { LLM_PROVIDERS_ADMIN_URL } from "./constants";
import {
SelectorFormField,
TextFormField,
BooleanFormField,
MultiSelectField,
} from "@/components/admin/connectors/Field";
import { useState } from "react";
import { Bubble } from "@/components/Bubble";
import { GroupsIcon } from "@/components/icons/icons";
import { useSWRConfig } from "swr";
import {
defaultModelsByProvider,
getDisplayNameForModel,
useUserGroups,
} from "@/lib/hooks";
import { defaultModelsByProvider, getDisplayNameForModel } from "@/lib/hooks";
import { FullLLMProvider, WellKnownLLMProviderDescriptor } from "./interfaces";
import { PopupSpec } from "@/components/admin/connectors/Popup";
import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled";
import * as Yup from "yup";
import isEqual from "lodash/isEqual";
import { IsPublicGroupSelector } from "@/components/IsPublicGroupSelector";
Expand All @@ -43,11 +35,6 @@ export function LLMProviderUpdateForm({
}) {
const { mutate } = useSWRConfig();

const isPaidEnterpriseFeaturesEnabled = usePaidEnterpriseFeaturesEnabled();

// EE only
const { data: userGroups, isLoading: userGroupsIsLoading } = useUserGroups();

const [isTesting, setIsTesting] = useState(false);
const [testError, setTestError] = useState<string>("");

Expand Down Expand Up @@ -278,7 +265,7 @@ export function LLMProviderUpdateForm({
</div>
))}

{!hideAdvanced && (
{!(hideAdvanced && llmProviderDescriptor.name != "azure") && (
<>
<Divider />

Expand Down
5 changes: 4 additions & 1 deletion web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,10 @@ export function ChatPage({
<HealthCheckBanner />

{showApiKeyModal && !shouldShowWelcomeModal && (
<ApiKeyModal hide={() => setShowApiKeyModal(false)} />
<ApiKeyModal
hide={() => setShowApiKeyModal(false)}
setPopup={setPopup}
/>
)}

{/* ChatPopup is a custom popup that displays a admin-specified message on initial user visit.
Expand Down
60 changes: 33 additions & 27 deletions web/src/components/initialSetup/welcome/WelcomeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { checkLlmProvider } from "./lib";
import { User } from "@/lib/types";
import { useProviderStatus } from "@/components/chat_search/ProviderContext";

import { usePopup } from "@/components/admin/connectors/Popup";

function setWelcomeFlowComplete() {
Cookies.set(COMPLETED_WELCOME_FLOW_COOKIE, "true", { expires: 365 });
}
Expand All @@ -28,6 +30,7 @@ export function _WelcomeModal({ user }: { user: User | null }) {
const [providerOptions, setProviderOptions] = useState<
WellKnownLLMProviderDescriptor[]
>([]);
const { popup, setPopup } = usePopup();

const { refreshProviderInfo } = useProviderStatus();
const clientSetWelcomeFlowComplete = async () => {
Expand All @@ -48,34 +51,37 @@ export function _WelcomeModal({ user }: { user: User | null }) {
}, []);

return (
<Modal title={"Welcome to Danswer!"} width="w-full max-w-3xl">
<div>
<Text className="mb-4">
Danswer brings all your company&apos;s knowledge to your fingertips,
ready to be accessed instantly.
</Text>
<Text className="mb-4">
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.
</Text>
<>
{popup}
<Modal title={"Welcome to Danswer!"} width="w-full max-w-3xl">
<div>
<Text className="mb-4">
Danswer brings all your company&apos;s knowledge to your fingertips,
ready to be accessed instantly.
</Text>
<Text className="mb-4">
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.
</Text>

<div className="max-h-[900px] overflow-y-scroll">
<ApiKeyForm
hidePopup
onSuccess={() => {
router.refresh();
refreshProviderInfo();
setCanBegin(true);
}}
providerOptions={providerOptions}
/>
<div className="max-h-[900px] overflow-y-scroll">
<ApiKeyForm
setPopup={setPopup}
onSuccess={() => {
router.refresh();
refreshProviderInfo();
setCanBegin(true);
}}
providerOptions={providerOptions}
/>
</div>
<Divider />
<Button disabled={!canBegin} onClick={clientSetWelcomeFlowComplete}>
Get Started
</Button>
</div>
<Divider />
<Button disabled={!canBegin} onClick={clientSetWelcomeFlowComplete}>
Get Started
</Button>
</div>
</Modal>
</Modal>
</>
);
}
15 changes: 3 additions & 12 deletions web/src/components/llm/ApiKeyForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Popup } from "../admin/connectors/Popup";
import { PopupSpec } from "../admin/connectors/Popup";
import { useState } from "react";
import { TabGroup, TabList, Tab, TabPanels, TabPanel } from "@tremor/react";
import { WellKnownLLMProviderDescriptor } from "@/app/admin/configuration/llm/interfaces";
Expand All @@ -8,17 +8,12 @@ import { CustomLLMProviderUpdateForm } from "@/app/admin/configuration/llm/Custo
export const ApiKeyForm = ({
onSuccess,
providerOptions,
hidePopup,
setPopup,
}: {
onSuccess: () => void;
providerOptions: WellKnownLLMProviderDescriptor[];
hidePopup?: boolean;
setPopup: (popup: PopupSpec) => void;
}) => {
const [popup, setPopup] = useState<{
message: string;
type: "success" | "error";
} | null>(null);

const defaultProvider = providerOptions[0]?.name;
const providerNameToIndexMap = new Map<string, number>();
providerOptions.forEach((provider, index) => {
Expand All @@ -35,10 +30,6 @@ export const ApiKeyForm = ({

return (
<div>
{!hidePopup && popup && (
<Popup message={popup.message} type={popup.type} />
)}

<TabGroup
index={providerNameToIndexMap.get(providerName) || 0}
onIndexChange={(index) =>
Expand Down
10 changes: 9 additions & 1 deletion web/src/components/llm/ApiKeyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import { ApiKeyForm } from "./ApiKeyForm";
import { Modal } from "../Modal";
import { useRouter } from "next/navigation";
import { useProviderStatus } from "../chat_search/ProviderContext";
import { PopupSpec } from "../admin/connectors/Popup";

export const ApiKeyModal = ({ hide }: { hide: () => void }) => {
export const ApiKeyModal = ({
hide,
setPopup,
}: {
hide: () => void;
setPopup: (popup: PopupSpec) => void;
}) => {
const router = useRouter();

const {
Expand Down Expand Up @@ -39,6 +46,7 @@ export const ApiKeyModal = ({ hide }: { hide: () => void }) => {
</div>

<ApiKeyForm
setPopup={setPopup}
onSuccess={() => {
router.refresh();
refreshProviderInfo();
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/search/SearchSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,10 @@ export const SearchSection = ({
{!shouldDisplayNoSources &&
showApiKeyModal &&
!shouldShowWelcomeModal && (
<ApiKeyModal hide={() => setShowApiKeyModal(false)} />
<ApiKeyModal
setPopup={setPopup}
hide={() => setShowApiKeyModal(false)}
/>
)}

{deletingChatSession && (
Expand Down
Loading