mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-23 12:31:30 +02:00
validated + cleaned
This commit is contained in:
@@ -28,6 +28,7 @@ export function AssistantGalleryCard({
|
|||||||
setPopup: (popup: PopupSpec) => void;
|
setPopup: (popup: PopupSpec) => void;
|
||||||
selectedAssistant: boolean;
|
selectedAssistant: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const { refreshUser } = useUser();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -82,7 +83,7 @@ export function AssistantGalleryCard({
|
|||||||
message: `"${assistant.name}" has been removed from your list.`,
|
message: `"${assistant.name}" has been removed from your list.`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
router.refresh();
|
await refreshUser();
|
||||||
} else {
|
} else {
|
||||||
setPopup({
|
setPopup({
|
||||||
message: `"${assistant.name}" could not be removed from your list.`,
|
message: `"${assistant.name}" could not be removed from your list.`,
|
||||||
@@ -110,7 +111,7 @@ export function AssistantGalleryCard({
|
|||||||
message: `"${assistant.name}" has been added to your list.`,
|
message: `"${assistant.name}" has been added to your list.`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
router.refresh();
|
await refreshUser();
|
||||||
} else {
|
} else {
|
||||||
setPopup({
|
setPopup({
|
||||||
message: `"${assistant.name}" could not be added to your list.`,
|
message: `"${assistant.name}" could not be added to your list.`,
|
||||||
|
@@ -27,11 +27,17 @@ export default async function GalleryPage({
|
|||||||
openedFolders,
|
openedFolders,
|
||||||
shouldShowWelcomeModal,
|
shouldShowWelcomeModal,
|
||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
|
hasAnyConnectors,
|
||||||
|
hasImageCompatibleModel,
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AssistantsProvider initialAssistants={assistants}>
|
<AssistantsProvider
|
||||||
|
initialAssistants={assistants}
|
||||||
|
hasAnyConnectors={hasAnyConnectors}
|
||||||
|
hasImageCompatibleModel={hasImageCompatibleModel}
|
||||||
|
>
|
||||||
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
||||||
|
|
||||||
<InstantSSRAutoRefresh />
|
<InstantSSRAutoRefresh />
|
||||||
|
@@ -138,7 +138,6 @@ export function AssistantSharingModal({
|
|||||||
onOutsideClick={onClose}
|
onOutsideClick={onClose}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{isUpdating && <Spinner />}
|
|
||||||
<p className="text-text-600 text-lg mb-6">
|
<p className="text-text-600 text-lg mb-6">
|
||||||
Manage access to this assistant by sharing it with other users.
|
Manage access to this assistant by sharing it with other users.
|
||||||
</p>
|
</p>
|
||||||
@@ -225,6 +224,7 @@ export function AssistantSharingModal({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
{isUpdating && <Spinner />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -109,6 +109,7 @@ function AssistantListItem({
|
|||||||
setPopup: (popupSpec: PopupSpec | null) => void;
|
setPopup: (popupSpec: PopupSpec | null) => void;
|
||||||
isDragging?: boolean;
|
isDragging?: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const { refreshUser } = useUser();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [showSharingModal, setShowSharingModal] = useState(false);
|
const [showSharingModal, setShowSharingModal] = useState(false);
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ function AssistantListItem({
|
|||||||
message: `"${assistant.name}" has been removed from your list.`,
|
message: `"${assistant.name}" has been removed from your list.`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
router.refresh();
|
await refreshUser();
|
||||||
} else {
|
} else {
|
||||||
setPopup({
|
setPopup({
|
||||||
message: `"${assistant.name}" could not be removed from your list.`,
|
message: `"${assistant.name}" could not be removed from your list.`,
|
||||||
@@ -226,7 +227,7 @@ function AssistantListItem({
|
|||||||
message: `"${assistant.name}" has been added to your list.`,
|
message: `"${assistant.name}" has been added to your list.`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
router.refresh();
|
await refreshUser();
|
||||||
} else {
|
} else {
|
||||||
setPopup({
|
setPopup({
|
||||||
message: `"${assistant.name}" could not be added to your list.`,
|
message: `"${assistant.name}" could not be added to your list.`,
|
||||||
@@ -359,7 +360,7 @@ export function AssistantsList() {
|
|||||||
message: `"${deletingPersona.name}" has been deleted.`,
|
message: `"${deletingPersona.name}" has been deleted.`,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
router.refresh();
|
await refreshUser();
|
||||||
} else {
|
} else {
|
||||||
setPopup({
|
setPopup({
|
||||||
message: `"${deletingPersona.name}" could not be deleted.`,
|
message: `"${deletingPersona.name}" could not be deleted.`,
|
||||||
@@ -380,7 +381,7 @@ export function AssistantsList() {
|
|||||||
makePublicPersona.id,
|
makePublicPersona.id,
|
||||||
newPublicStatus
|
newPublicStatus
|
||||||
);
|
);
|
||||||
router.refresh();
|
await refreshAssistants();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@@ -27,10 +27,16 @@ export default async function GalleryPage({
|
|||||||
openedFolders,
|
openedFolders,
|
||||||
shouldShowWelcomeModal,
|
shouldShowWelcomeModal,
|
||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
|
hasAnyConnectors,
|
||||||
|
hasImageCompatibleModel,
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AssistantsProvider initialAssistants={assistants}>
|
<AssistantsProvider
|
||||||
|
initialAssistants={assistants}
|
||||||
|
hasAnyConnectors={hasAnyConnectors}
|
||||||
|
hasImageCompatibleModel={hasImageCompatibleModel}
|
||||||
|
>
|
||||||
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
||||||
|
|
||||||
<InstantSSRAutoRefresh />
|
<InstantSSRAutoRefresh />
|
||||||
|
@@ -35,6 +35,7 @@ export function AssistantsTab({
|
|||||||
const [_, llmName] = getFinalLLM(llmProviders, null, null);
|
const [_, llmName] = getFinalLLM(llmProviders, null, null);
|
||||||
const { finalAssistants, refreshAssistants } = useAssistants();
|
const { finalAssistants, refreshAssistants } = useAssistants();
|
||||||
const [assistants, setAssistants] = useState(finalAssistants);
|
const [assistants, setAssistants] = useState(finalAssistants);
|
||||||
|
console.log(finalAssistants);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAssistants(finalAssistants);
|
setAssistants(finalAssistants);
|
||||||
|
@@ -34,13 +34,19 @@ export default async function Page({
|
|||||||
shouldShowWelcomeModal,
|
shouldShowWelcomeModal,
|
||||||
assistants,
|
assistants,
|
||||||
userInputPrompts,
|
userInputPrompts,
|
||||||
|
hasAnyConnectors,
|
||||||
|
hasImageCompatibleModel,
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InstantSSRAutoRefresh />
|
<InstantSSRAutoRefresh />
|
||||||
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
||||||
<AssistantsProvider initialAssistants={assistants}>
|
<AssistantsProvider
|
||||||
|
initialAssistants={assistants}
|
||||||
|
hasAnyConnectors={hasAnyConnectors}
|
||||||
|
hasImageCompatibleModel={hasImageCompatibleModel}
|
||||||
|
>
|
||||||
<ChatProvider
|
<ChatProvider
|
||||||
value={{
|
value={{
|
||||||
chatSessions,
|
chatSessions,
|
||||||
|
@@ -36,6 +36,7 @@ import WrappedSearch from "./WrappedSearch";
|
|||||||
import { SearchProvider } from "@/components/context/SearchContext";
|
import { SearchProvider } from "@/components/context/SearchContext";
|
||||||
import { fetchLLMProvidersSS } from "@/lib/llm/fetchLLMs";
|
import { fetchLLMProvidersSS } from "@/lib/llm/fetchLLMs";
|
||||||
import { LLMProviderDescriptor } from "../admin/configuration/llm/interfaces";
|
import { LLMProviderDescriptor } from "../admin/configuration/llm/interfaces";
|
||||||
|
import { AssistantsProvider } from "@/components/context/AssisantsContext";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
|
|
||||||
export default async function Home({
|
export default async function Home({
|
||||||
@@ -193,36 +194,39 @@ export default async function Home({
|
|||||||
<HealthCheckBanner />
|
<HealthCheckBanner />
|
||||||
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
{shouldShowWelcomeModal && <WelcomeModal user={user} />}
|
||||||
<InstantSSRAutoRefresh />
|
<InstantSSRAutoRefresh />
|
||||||
|
|
||||||
{shouldDisplayNoSourcesModal && <NoSourcesModal />}
|
{shouldDisplayNoSourcesModal && <NoSourcesModal />}
|
||||||
|
|
||||||
{shouldDisplaySourcesIncompleteModal && (
|
{shouldDisplaySourcesIncompleteModal && (
|
||||||
<NoCompleteSourcesModal ccPairs={ccPairs} />
|
<NoCompleteSourcesModal ccPairs={ccPairs} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 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.
|
||||||
Only used in the EE version of the app. */}
|
Only used in the EE version of the app. */}
|
||||||
<ChatPopup />
|
<ChatPopup />
|
||||||
|
<AssistantsProvider
|
||||||
<SearchProvider
|
initialAssistants={assistants}
|
||||||
value={{
|
hasAnyConnectors={hasAnyConnectors}
|
||||||
querySessions,
|
hasImageCompatibleModel={false}
|
||||||
ccPairs,
|
|
||||||
documentSets,
|
|
||||||
assistants,
|
|
||||||
tags,
|
|
||||||
agenticSearchEnabled,
|
|
||||||
disabledAgentic: DISABLE_LLM_DOC_RELEVANCE,
|
|
||||||
initiallyToggled: toggleSidebar,
|
|
||||||
shouldShowWelcomeModal,
|
|
||||||
shouldDisplayNoSources: shouldDisplayNoSourcesModal,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<WrappedSearch
|
<SearchProvider
|
||||||
initiallyToggled={toggleSidebar}
|
value={{
|
||||||
searchTypeDefault={searchTypeDefault}
|
querySessions,
|
||||||
/>
|
ccPairs,
|
||||||
</SearchProvider>
|
documentSets,
|
||||||
|
assistants,
|
||||||
|
tags,
|
||||||
|
agenticSearchEnabled,
|
||||||
|
disabledAgentic: DISABLE_LLM_DOC_RELEVANCE,
|
||||||
|
initiallyToggled: toggleSidebar,
|
||||||
|
shouldShowWelcomeModal,
|
||||||
|
shouldDisplayNoSources: shouldDisplayNoSourcesModal,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<WrappedSearch
|
||||||
|
initiallyToggled={toggleSidebar}
|
||||||
|
searchTypeDefault={searchTypeDefault}
|
||||||
|
/>
|
||||||
|
</SearchProvider>
|
||||||
|
</AssistantsProvider>
|
||||||
|
s
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ import { AssistantIcon } from "@/components/assistants/AssistantIcon";
|
|||||||
import { addAssistantToList } from "@/lib/assistants/updateAssistantPreferences";
|
import { addAssistantToList } from "@/lib/assistants/updateAssistantPreferences";
|
||||||
import { useAssistants } from "../context/AssisantsContext";
|
import { useAssistants } from "../context/AssisantsContext";
|
||||||
import { useUser } from "../user/UserProvider";
|
import { useUser } from "../user/UserProvider";
|
||||||
|
import { Bell } from "@phosphor-icons/react";
|
||||||
|
|
||||||
export const NotificationCard = () => {
|
export const NotificationCard = () => {
|
||||||
const [showDropdown, setShowDropdown] = useState(false);
|
const [showDropdown, setShowDropdown] = useState(false);
|
||||||
@@ -118,18 +119,12 @@ export const NotificationCard = () => {
|
|||||||
}, [showDropdown]);
|
}, [showDropdown]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="my-auto relative">
|
||||||
<div
|
<div
|
||||||
onClick={() => setShowDropdown(!showDropdown)}
|
onClick={() => setShowDropdown(!showDropdown)}
|
||||||
className="cursor-pointer relative notification-dropdown"
|
className="cursor-pointer relative notification-dropdown"
|
||||||
>
|
>
|
||||||
<svg
|
<Bell size={20} />
|
||||||
className="w-6 h-6 text-text-600 hover:text-text-800"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="currentColor"
|
|
||||||
>
|
|
||||||
<path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z" />
|
|
||||||
</svg>
|
|
||||||
{sortedNotifications.length > 0 && (
|
{sortedNotifications.length > 0 && (
|
||||||
<span className="absolute top-0 right-0 h-2 w-2 bg-red-500 rounded-full"></span>
|
<span className="absolute top-0 right-0 h-2 w-2 bg-red-500 rounded-full"></span>
|
||||||
)}
|
)}
|
||||||
|
@@ -24,7 +24,14 @@ const AssistantsContext = createContext<AssistantsContextProps | undefined>(
|
|||||||
export const AssistantsProvider: React.FC<{
|
export const AssistantsProvider: React.FC<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
initialAssistants: Persona[];
|
initialAssistants: Persona[];
|
||||||
}> = ({ children, initialAssistants }) => {
|
hasAnyConnectors: boolean;
|
||||||
|
hasImageCompatibleModel: boolean;
|
||||||
|
}> = ({
|
||||||
|
children,
|
||||||
|
initialAssistants,
|
||||||
|
hasAnyConnectors,
|
||||||
|
hasImageCompatibleModel,
|
||||||
|
}) => {
|
||||||
const [assistants, setAssistants] = useState<Persona[]>(
|
const [assistants, setAssistants] = useState<Persona[]>(
|
||||||
initialAssistants || []
|
initialAssistants || []
|
||||||
);
|
);
|
||||||
@@ -39,7 +46,20 @@ export const AssistantsProvider: React.FC<{
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!response.ok) throw new Error("Failed to fetch assistants");
|
if (!response.ok) throw new Error("Failed to fetch assistants");
|
||||||
const assistants = await response.json();
|
let assistants: Persona[] = await response.json();
|
||||||
|
if (!hasImageCompatibleModel) {
|
||||||
|
assistants = assistants.filter(
|
||||||
|
(assistant) =>
|
||||||
|
!assistant.tools.some(
|
||||||
|
(tool) => tool.in_code_tool_id === "ImageGenerationTool"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!hasAnyConnectors) {
|
||||||
|
assistants = assistants.filter(
|
||||||
|
(assistant) => assistant.num_chunks === 0
|
||||||
|
);
|
||||||
|
}
|
||||||
setAssistants(assistants);
|
setAssistants(assistants);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error refreshing assistants:", error);
|
console.error("Error refreshing assistants:", error);
|
||||||
@@ -56,9 +76,11 @@ export const AssistantsProvider: React.FC<{
|
|||||||
user,
|
user,
|
||||||
assistants
|
assistants
|
||||||
);
|
);
|
||||||
|
|
||||||
const finalAssistants = user
|
const finalAssistants = user
|
||||||
? orderAssistantsForUser(visibleAssistants, user)
|
? orderAssistantsForUser(visibleAssistants, user)
|
||||||
: visibleAssistants;
|
: visibleAssistants;
|
||||||
|
|
||||||
const ownedButHiddenAssistants = getUserCreatedAssistants(
|
const ownedButHiddenAssistants = getUserCreatedAssistants(
|
||||||
user,
|
user,
|
||||||
hiddenAssistants
|
hiddenAssistants
|
||||||
|
@@ -47,6 +47,8 @@ interface FetchChatDataResult {
|
|||||||
finalDocumentSidebarInitialWidth?: number;
|
finalDocumentSidebarInitialWidth?: number;
|
||||||
shouldShowWelcomeModal: boolean;
|
shouldShowWelcomeModal: boolean;
|
||||||
userInputPrompts: InputPrompt[];
|
userInputPrompts: InputPrompt[];
|
||||||
|
hasAnyConnectors: boolean;
|
||||||
|
hasImageCompatibleModel: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchChatData(searchParams: {
|
export async function fetchChatData(searchParams: {
|
||||||
@@ -251,5 +253,7 @@ export async function fetchChatData(searchParams: {
|
|||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
shouldShowWelcomeModal,
|
shouldShowWelcomeModal,
|
||||||
userInputPrompts,
|
userInputPrompts,
|
||||||
|
hasAnyConnectors,
|
||||||
|
hasImageCompatibleModel,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user