update chat provider values

This commit is contained in:
pablodanswer
2024-12-16 11:39:25 -08:00
parent d0483dd269
commit 0502417cbe
4 changed files with 54 additions and 50 deletions

View File

@@ -1,31 +1,15 @@
"use client"; "use client";
import SidebarWrapper from "../SidebarWrapper"; import SidebarWrapper from "../SidebarWrapper";
import { ChatSession } from "@/app/chat/interfaces";
import { Folder } from "@/app/chat/folders/interfaces";
import { Persona } from "@/app/admin/assistants/interfaces";
import { User } from "@/lib/types";
import { AssistantsGallery } from "./AssistantsGallery"; import { AssistantsGallery } from "./AssistantsGallery";
export default function WrappedAssistantsGallery({ export default function WrappedAssistantsGallery({
chatSessions, toggleSidebar,
initiallyToggled,
folders,
openedFolders,
}: { }: {
chatSessions: ChatSession[]; toggleSidebar: boolean;
folders: Folder[];
initiallyToggled: boolean;
openedFolders?: { [key: number]: boolean };
}) { }) {
return ( return (
<SidebarWrapper <SidebarWrapper page="chat" initiallyToggled={toggleSidebar}>
page="chat"
initiallyToggled={initiallyToggled}
chatSessions={chatSessions}
folders={folders}
openedFolders={openedFolders}
>
<AssistantsGallery /> <AssistantsGallery />
</SidebarWrapper> </SidebarWrapper>
); );

View File

@@ -5,6 +5,7 @@ import { unstable_noStore as noStore } from "next/cache";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import WrappedAssistantsGallery from "./WrappedAssistantsGallery"; import WrappedAssistantsGallery from "./WrappedAssistantsGallery";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
import { ChatProvider } from "@/components/context/ChatContext";
export default async function GalleryPage(props: { export default async function GalleryPage(props: {
searchParams: Promise<{ [key: string]: string }>; searchParams: Promise<{ [key: string]: string }>;
@@ -26,22 +27,38 @@ export default async function GalleryPage(props: {
openedFolders, openedFolders,
toggleSidebar, toggleSidebar,
shouldShowWelcomeModal, shouldShowWelcomeModal,
availableSources,
ccPairs,
documentSets,
tags,
llmProviders,
defaultAssistantId,
} = data; } = data;
return ( return (
<> <ChatProvider
value={{
chatSessions,
availableSources,
ccPairs,
documentSets,
tags,
availableDocumentSets: documentSets,
availableTags: tags,
llmProviders,
folders,
openedFolders,
shouldShowWelcomeModal,
defaultAssistantId,
}}
>
{shouldShowWelcomeModal && ( {shouldShowWelcomeModal && (
<WelcomeModal user={user} requestCookies={requestCookies} /> <WelcomeModal user={user} requestCookies={requestCookies} />
)} )}
<InstantSSRAutoRefresh /> <InstantSSRAutoRefresh />
<WrappedAssistantsGallery <WrappedAssistantsGallery toggleSidebar={toggleSidebar} />
initiallyToggled={toggleSidebar} </ChatProvider>
chatSessions={chatSessions}
folders={folders}
openedFolders={openedFolders}
/>
</>
); );
} }

View File

@@ -1,28 +1,14 @@
"use client"; "use client";
import { AssistantsList } from "./AssistantsList"; import { AssistantsList } from "./AssistantsList";
import SidebarWrapper from "../SidebarWrapper"; import SidebarWrapper from "../SidebarWrapper";
import { ChatSession } from "@/app/chat/interfaces";
import { Folder } from "@/app/chat/folders/interfaces";
export default function WrappedAssistantsMine({ export default function WrappedAssistantsMine({
chatSessions,
initiallyToggled, initiallyToggled,
folders,
openedFolders,
}: { }: {
chatSessions: ChatSession[];
folders: Folder[];
initiallyToggled: boolean; initiallyToggled: boolean;
openedFolders?: { [key: number]: boolean };
}) { }) {
return ( return (
<SidebarWrapper <SidebarWrapper page="chat" initiallyToggled={initiallyToggled}>
page="chat"
initiallyToggled={initiallyToggled}
chatSessions={chatSessions}
folders={folders}
openedFolders={openedFolders}
>
<AssistantsList /> <AssistantsList />
</SidebarWrapper> </SidebarWrapper>
); );

View File

@@ -6,6 +6,7 @@ import { redirect } from "next/navigation";
import WrappedAssistantsMine from "./WrappedAssistantsMine"; import WrappedAssistantsMine from "./WrappedAssistantsMine";
import { WelcomeModal } from "@/components/initialSetup/welcome/WelcomeModalWrapper"; import { WelcomeModal } from "@/components/initialSetup/welcome/WelcomeModalWrapper";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
import { ChatProvider } from "@/components/context/ChatContext";
export default async function GalleryPage(props: { export default async function GalleryPage(props: {
searchParams: Promise<{ [key: string]: string }>; searchParams: Promise<{ [key: string]: string }>;
@@ -27,21 +28,37 @@ export default async function GalleryPage(props: {
openedFolders, openedFolders,
toggleSidebar, toggleSidebar,
shouldShowWelcomeModal, shouldShowWelcomeModal,
availableSources,
ccPairs,
documentSets,
tags,
llmProviders,
defaultAssistantId,
} = data; } = data;
return ( return (
<> <ChatProvider
value={{
chatSessions,
availableSources,
ccPairs,
documentSets,
tags,
availableDocumentSets: documentSets,
availableTags: tags,
llmProviders,
folders,
openedFolders,
shouldShowWelcomeModal,
defaultAssistantId,
}}
>
{shouldShowWelcomeModal && ( {shouldShowWelcomeModal && (
<WelcomeModal user={user} requestCookies={requestCookies} /> <WelcomeModal user={user} requestCookies={requestCookies} />
)} )}
<InstantSSRAutoRefresh /> <InstantSSRAutoRefresh />
<WrappedAssistantsMine <WrappedAssistantsMine initiallyToggled={toggleSidebar} />
initiallyToggled={toggleSidebar} </ChatProvider>
chatSessions={chatSessions}
folders={folders}
openedFolders={openedFolders}
/>
</>
); );
} }