From 351ee543a0773ecb6acf99f3888dd648091d7f85 Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Fri, 22 Nov 2024 14:10:37 -0800 Subject: [PATCH 1/2] k --- .../app/admin/assistants/AssistantEditor.tsx | 2 + .../components/context/AssistantsContext.tsx | 55 +++++++++++-------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/web/src/app/admin/assistants/AssistantEditor.tsx b/web/src/app/admin/assistants/AssistantEditor.tsx index 6fe9301a7aa..c3f3eb5dfcf 100644 --- a/web/src/app/admin/assistants/AssistantEditor.tsx +++ b/web/src/app/admin/assistants/AssistantEditor.tsx @@ -412,7 +412,9 @@ export function AssistantEditor({ }); } } + await refreshAssistants(); + console.log("redirectType", redirectType); router.push( redirectType === SuccessfulPersonaUpdateRedirectType.ADMIN ? `/admin/assistants?u=${Date.now()}` diff --git a/web/src/components/context/AssistantsContext.tsx b/web/src/components/context/AssistantsContext.tsx index 4c389240266..f811fecc7e9 100644 --- a/web/src/components/context/AssistantsContext.tsx +++ b/web/src/components/context/AssistantsContext.tsx @@ -81,34 +81,34 @@ export const AssistantsProvider: React.FC<{ checkImageGenerationAvailability(); }, []); - useEffect(() => { - const fetchPersonas = async () => { - if (!isAdmin && !isCurator) { - return; - } + const fetchPersonas = async () => { + if (!isAdmin && !isCurator) { + return; + } - try { - const [editableResponse, allResponse] = await Promise.all([ - fetch("/api/admin/persona?get_editable=true"), - fetch("/api/admin/persona"), - ]); - - if (editableResponse.ok) { - const editablePersonas = await editableResponse.json(); - setEditablePersonas(editablePersonas); - } + try { + const [editableResponse, allResponse] = await Promise.all([ + fetch("/api/admin/persona?get_editable=true"), + fetch("/api/admin/persona"), + ]); + + if (editableResponse.ok) { + const editablePersonas = await editableResponse.json(); + setEditablePersonas(editablePersonas); + } - if (allResponse.ok) { - const allPersonas = await allResponse.json(); - setAllAssistants(allPersonas); - } else { - console.error("Error fetching personas:", allResponse); - } - } catch (error) { - console.error("Error fetching personas:", error); + if (allResponse.ok) { + const allPersonas = await allResponse.json(); + setAllAssistants(allPersonas); + } else { + console.error("Error fetching personas:", allResponse); } - }; + } catch (error) { + console.error("Error fetching personas:", error); + } + }; + useEffect(() => { fetchPersonas(); }, [isAdmin, isCurator]); @@ -144,6 +144,7 @@ export const AssistantsProvider: React.FC<{ }); if (!response.ok) throw new Error("Failed to fetch assistants"); let assistants: Persona[] = await response.json(); + if (!hasImageCompatibleModel) { assistants = assistants.filter( (assistant) => @@ -152,15 +153,21 @@ export const AssistantsProvider: React.FC<{ ) ); } + if (!hasAnyConnectors) { assistants = assistants.filter( (assistant) => assistant.num_chunks === 0 ); } + setAssistants(assistants); + + // Fetch and update allAssistants for admins and curators + await fetchPersonas(); } catch (error) { console.error("Error refreshing assistants:", error); } + setRecentAssistants( assistants.filter( (assistant) => From c7d58616b5943768e2e581751f4ede7a4f3292da Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Fri, 22 Nov 2024 14:13:04 -0800 Subject: [PATCH 2/2] k --- web/src/components/context/AssistantsContext.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/src/components/context/AssistantsContext.tsx b/web/src/components/context/AssistantsContext.tsx index f811fecc7e9..2e40cb5bf44 100644 --- a/web/src/components/context/AssistantsContext.tsx +++ b/web/src/components/context/AssistantsContext.tsx @@ -98,8 +98,10 @@ export const AssistantsProvider: React.FC<{ } if (allResponse.ok) { + console.log("allResponse", allResponse); const allPersonas = await allResponse.json(); setAllAssistants(allPersonas); + console.log("allAssistants", allAssistants); } else { console.error("Error fetching personas:", allResponse); }