mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-03 19:49:17 +02:00
account for no visible assistants (#2765)
This commit is contained in:
parent
1f4fe42f4b
commit
1581d35476
@ -106,6 +106,7 @@ import {
|
||||
orderAssistantsForUser,
|
||||
} from "@/lib/assistants/utils";
|
||||
import BlurBackground from "./shared_chat_search/BlurBackground";
|
||||
import { NoAssistantModal } from "@/components/modals/NoAssistantModal";
|
||||
|
||||
const TEMP_USER_MESSAGE_ID = -1;
|
||||
const TEMP_ASSISTANT_MESSAGE_ID = -2;
|
||||
@ -139,7 +140,7 @@ export function ChatPage({
|
||||
|
||||
const [showApiKeyModal, setShowApiKeyModal] = useState(true);
|
||||
|
||||
const { user, refreshUser, isLoadingUser } = useUser();
|
||||
const { user, refreshUser, isAdmin, isLoadingUser } = useUser();
|
||||
|
||||
const existingChatIdRaw = searchParams.get("chatId");
|
||||
const currentPersonaId = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID);
|
||||
@ -191,6 +192,7 @@ export function ChatPage({
|
||||
const search_param_temperature = searchParams.get(
|
||||
SEARCH_PARAM_NAMES.TEMPERATURE
|
||||
);
|
||||
|
||||
const defaultTemperature = search_param_temperature
|
||||
? parseFloat(search_param_temperature)
|
||||
: selectedAssistant?.tools.some(
|
||||
@ -225,6 +227,8 @@ export function ChatPage({
|
||||
finalAssistants[0] ||
|
||||
availableAssistants[0];
|
||||
|
||||
const noAssistants = liveAssistant == null || liveAssistant == undefined;
|
||||
|
||||
useEffect(() => {
|
||||
if (!loadedIdSessionRef.current && !currentPersonaId) {
|
||||
return;
|
||||
@ -1695,6 +1699,9 @@ export function ChatPage({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (noAssistants) {
|
||||
return;
|
||||
}
|
||||
const includes = checkAnyAssistantHasSearch(
|
||||
messageHistory,
|
||||
availableAssistants,
|
||||
@ -1704,6 +1711,9 @@ export function ChatPage({
|
||||
}, [messageHistory, availableAssistants, liveAssistant]);
|
||||
|
||||
const [retrievalEnabled, setRetrievalEnabled] = useState(() => {
|
||||
if (noAssistants) {
|
||||
return false;
|
||||
}
|
||||
return checkAnyAssistantHasSearch(
|
||||
messageHistory,
|
||||
availableAssistants,
|
||||
@ -1774,11 +1784,13 @@ export function ChatPage({
|
||||
<>
|
||||
<HealthCheckBanner />
|
||||
|
||||
{showApiKeyModal && !shouldShowWelcomeModal && (
|
||||
{showApiKeyModal && !shouldShowWelcomeModal ? (
|
||||
<ApiKeyModal
|
||||
hide={() => setShowApiKeyModal(false)}
|
||||
setPopup={setPopup}
|
||||
/>
|
||||
) : (
|
||||
noAssistants && <NoAssistantModal isAdmin={isAdmin} />
|
||||
)}
|
||||
|
||||
{/* ChatPopup is a custom popup that displays a admin-specified message on initial user visit.
|
||||
|
@ -3,11 +3,13 @@ export function BasicClickable({
|
||||
onClick,
|
||||
fullWidth = false,
|
||||
inset,
|
||||
className,
|
||||
}: {
|
||||
children: string | JSX.Element;
|
||||
onClick?: () => void;
|
||||
inset?: boolean;
|
||||
fullWidth?: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
@ -26,7 +28,9 @@ export function BasicClickable({
|
||||
select-none
|
||||
overflow-hidden
|
||||
hover:bg-hover-light
|
||||
${fullWidth ? "w-full" : ""}`}
|
||||
${fullWidth ? "w-full" : ""}
|
||||
${className ? className : ""}
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
|
37
web/src/components/modals/NoAssistantModal.tsx
Normal file
37
web/src/components/modals/NoAssistantModal.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
import { ModalWrapper } from "@/components/modals/ModalWrapper";
|
||||
|
||||
export const NoAssistantModal = ({ isAdmin }: { isAdmin: boolean }) => {
|
||||
return (
|
||||
<ModalWrapper modalClassName="bg-white max-w-2xl rounded-lg shadow-xl text-center">
|
||||
<>
|
||||
<h2 className="text-3xl font-bold text-gray-800 mb-4">
|
||||
No Assistant Available
|
||||
</h2>
|
||||
<p className="text-gray-600 mb-6">
|
||||
You currently have no assistant configured. To use this feature, you
|
||||
need to take action.
|
||||
</p>
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<p className="text-gray-600 mb-6">
|
||||
As an administrator, you can create a new assistant by visiting
|
||||
the admin panel.
|
||||
</p>
|
||||
<button
|
||||
onClick={() => {
|
||||
window.location.href = "/admin/assistants";
|
||||
}}
|
||||
className="inline-flex flex justify-center items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-background-800 text-center focus:outline-none focus:ring-2 focus:ring-offset-2 "
|
||||
>
|
||||
Go to Admin Panel
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<p className="text-gray-600 mb-2">
|
||||
Please contact your administrator to configure an assistant for you.
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
</ModalWrapper>
|
||||
);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user