mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-17 19:41:05 +02:00
account for no visible assistants (#2765)
This commit is contained in:
parent
1f4fe42f4b
commit
1581d35476
@ -106,6 +106,7 @@ import {
|
|||||||
orderAssistantsForUser,
|
orderAssistantsForUser,
|
||||||
} from "@/lib/assistants/utils";
|
} from "@/lib/assistants/utils";
|
||||||
import BlurBackground from "./shared_chat_search/BlurBackground";
|
import BlurBackground from "./shared_chat_search/BlurBackground";
|
||||||
|
import { NoAssistantModal } from "@/components/modals/NoAssistantModal";
|
||||||
|
|
||||||
const TEMP_USER_MESSAGE_ID = -1;
|
const TEMP_USER_MESSAGE_ID = -1;
|
||||||
const TEMP_ASSISTANT_MESSAGE_ID = -2;
|
const TEMP_ASSISTANT_MESSAGE_ID = -2;
|
||||||
@ -139,7 +140,7 @@ export function ChatPage({
|
|||||||
|
|
||||||
const [showApiKeyModal, setShowApiKeyModal] = useState(true);
|
const [showApiKeyModal, setShowApiKeyModal] = useState(true);
|
||||||
|
|
||||||
const { user, refreshUser, isLoadingUser } = useUser();
|
const { user, refreshUser, isAdmin, isLoadingUser } = useUser();
|
||||||
|
|
||||||
const existingChatIdRaw = searchParams.get("chatId");
|
const existingChatIdRaw = searchParams.get("chatId");
|
||||||
const currentPersonaId = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID);
|
const currentPersonaId = searchParams.get(SEARCH_PARAM_NAMES.PERSONA_ID);
|
||||||
@ -191,6 +192,7 @@ export function ChatPage({
|
|||||||
const search_param_temperature = searchParams.get(
|
const search_param_temperature = searchParams.get(
|
||||||
SEARCH_PARAM_NAMES.TEMPERATURE
|
SEARCH_PARAM_NAMES.TEMPERATURE
|
||||||
);
|
);
|
||||||
|
|
||||||
const defaultTemperature = search_param_temperature
|
const defaultTemperature = search_param_temperature
|
||||||
? parseFloat(search_param_temperature)
|
? parseFloat(search_param_temperature)
|
||||||
: selectedAssistant?.tools.some(
|
: selectedAssistant?.tools.some(
|
||||||
@ -225,6 +227,8 @@ export function ChatPage({
|
|||||||
finalAssistants[0] ||
|
finalAssistants[0] ||
|
||||||
availableAssistants[0];
|
availableAssistants[0];
|
||||||
|
|
||||||
|
const noAssistants = liveAssistant == null || liveAssistant == undefined;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loadedIdSessionRef.current && !currentPersonaId) {
|
if (!loadedIdSessionRef.current && !currentPersonaId) {
|
||||||
return;
|
return;
|
||||||
@ -1695,6 +1699,9 @@ export function ChatPage({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (noAssistants) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const includes = checkAnyAssistantHasSearch(
|
const includes = checkAnyAssistantHasSearch(
|
||||||
messageHistory,
|
messageHistory,
|
||||||
availableAssistants,
|
availableAssistants,
|
||||||
@ -1704,6 +1711,9 @@ export function ChatPage({
|
|||||||
}, [messageHistory, availableAssistants, liveAssistant]);
|
}, [messageHistory, availableAssistants, liveAssistant]);
|
||||||
|
|
||||||
const [retrievalEnabled, setRetrievalEnabled] = useState(() => {
|
const [retrievalEnabled, setRetrievalEnabled] = useState(() => {
|
||||||
|
if (noAssistants) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return checkAnyAssistantHasSearch(
|
return checkAnyAssistantHasSearch(
|
||||||
messageHistory,
|
messageHistory,
|
||||||
availableAssistants,
|
availableAssistants,
|
||||||
@ -1774,11 +1784,13 @@ export function ChatPage({
|
|||||||
<>
|
<>
|
||||||
<HealthCheckBanner />
|
<HealthCheckBanner />
|
||||||
|
|
||||||
{showApiKeyModal && !shouldShowWelcomeModal && (
|
{showApiKeyModal && !shouldShowWelcomeModal ? (
|
||||||
<ApiKeyModal
|
<ApiKeyModal
|
||||||
hide={() => setShowApiKeyModal(false)}
|
hide={() => setShowApiKeyModal(false)}
|
||||||
setPopup={setPopup}
|
setPopup={setPopup}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
noAssistants && <NoAssistantModal isAdmin={isAdmin} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ChatPopup is a custom popup that displays a admin-specified message on initial user visit.
|
{/* ChatPopup is a custom popup that displays a admin-specified message on initial user visit.
|
||||||
|
@ -3,11 +3,13 @@ export function BasicClickable({
|
|||||||
onClick,
|
onClick,
|
||||||
fullWidth = false,
|
fullWidth = false,
|
||||||
inset,
|
inset,
|
||||||
|
className,
|
||||||
}: {
|
}: {
|
||||||
children: string | JSX.Element;
|
children: string | JSX.Element;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
inset?: boolean;
|
inset?: boolean;
|
||||||
fullWidth?: boolean;
|
fullWidth?: boolean;
|
||||||
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
@ -26,7 +28,9 @@ export function BasicClickable({
|
|||||||
select-none
|
select-none
|
||||||
overflow-hidden
|
overflow-hidden
|
||||||
hover:bg-hover-light
|
hover:bg-hover-light
|
||||||
${fullWidth ? "w-full" : ""}`}
|
${fullWidth ? "w-full" : ""}
|
||||||
|
${className ? className : ""}
|
||||||
|
`}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</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