diff --git a/backend/danswer/server/features/persona/api.py b/backend/danswer/server/features/persona/api.py index 8b4305755dc9..6f7cba5bf222 100644 --- a/backend/danswer/server/features/persona/api.py +++ b/backend/danswer/server/features/persona/api.py @@ -239,11 +239,14 @@ def get_persona( persona_id: int, user: User | None = Depends(current_user), db_session: Session = Depends(get_session), + include_non_owned: bool = Query( + False, description="If true, return persona even if user doesn't own it." + ), ) -> PersonaSnapshot: return PersonaSnapshot.from_model( get_persona_by_id( persona_id=persona_id, - user=user, + user=user if not include_non_owned else None, db_session=db_session, is_for_edit=False, ) diff --git a/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx b/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx index 489163aa3c8e..c5825f5fb0e9 100644 --- a/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx +++ b/web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx @@ -2,7 +2,7 @@ import Prism from "prismjs"; import { humanReadableFormat } from "@/lib/time"; -import { BackendChatSession } from "../../interfaces"; +import { BackendChatSession, SharedChatSession } from "../../interfaces"; import { buildLatestMessageChain, getCitedDocumentsFromMessage, @@ -11,10 +11,10 @@ import { import { AIMessage, HumanMessage } from "../../message/Messages"; import { Button, Callout, Divider } from "@tremor/react"; import { useRouter } from "next/navigation"; -import { Persona } from "@/app/admin/assistants/interfaces"; import { useContext, useEffect, useState } from "react"; import { SettingsContext } from "@/components/settings/SettingsProvider"; import { DanswerInitializingLoader } from "@/components/DanswerInitializingLoader"; +import { Persona } from "@/app/admin/assistants/interfaces"; function BackToDanswerButton() { const router = useRouter(); @@ -34,10 +34,10 @@ function BackToDanswerButton() { export function SharedChatDisplay({ chatSession, - availableAssistants, + persona, }: { chatSession: BackendChatSession | null; - availableAssistants: Persona[]; + persona: Persona; }) { const [isReady, setIsReady] = useState(false); useEffect(() => { @@ -56,9 +56,6 @@ export function SharedChatDisplay({ ); } - const currentPersona = availableAssistants.find( - (persona) => persona.id === chatSession.persona_id - ); const messages = buildLatestMessageChain( processRawChatHistory(chatSession.messages) @@ -96,7 +93,7 @@ export function SharedChatDisplay({ return ( @@ -61,10 +74,7 @@ export default async function Page({ params }: { params: { chatId: string } }) {
- +
); diff --git a/web/src/components/chat_search/ProviderContext.tsx b/web/src/components/chat_search/ProviderContext.tsx index 609713f874b6..f0839373b8d3 100644 --- a/web/src/components/chat_search/ProviderContext.tsx +++ b/web/src/components/chat_search/ProviderContext.tsx @@ -37,6 +37,7 @@ export function ProviderContextProvider({ const fetchProviderInfo = useCallback(async () => { const { providers, options, defaultCheckSuccessful } = await checkLlmProvider(user); + setValidProviderExists(providers.length > 0 && defaultCheckSuccessful); setProviderOptions(options); }, [user, setValidProviderExists, setProviderOptions]); diff --git a/web/src/lib/assistants/fetchAssistantSS.ts b/web/src/lib/assistants/fetchAssistantSS.ts new file mode 100644 index 000000000000..7e777994b421 --- /dev/null +++ b/web/src/lib/assistants/fetchAssistantSS.ts @@ -0,0 +1,14 @@ +import { Persona } from "@/app/admin/assistants/interfaces"; +import { fetchSS } from "../utilsSS"; + +export async function fetchAssistantSS( + personaId: number +): Promise { + const response = await fetchSS( + `/persona/${personaId}?include_non_owned=true` + ); + if (response.ok) { + return (await response.json()) as Persona; + } + return null; +}