mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-12 09:00:53 +02:00
ensure assistant response parsed correctly (#2823)
This commit is contained in:
parent
0a0215ceee
commit
f3fb7c572e
@ -9,7 +9,10 @@ import { redirect } from "next/navigation";
|
|||||||
import { BackendChatSession } from "../../interfaces";
|
import { BackendChatSession } from "../../interfaces";
|
||||||
import { SharedChatDisplay } from "./SharedChatDisplay";
|
import { SharedChatDisplay } from "./SharedChatDisplay";
|
||||||
import { Persona } from "@/app/admin/assistants/interfaces";
|
import { Persona } from "@/app/admin/assistants/interfaces";
|
||||||
import { fetchAssistantsSS } from "@/lib/assistants/fetchAssistantsSS";
|
import {
|
||||||
|
FetchAssistantsResponse,
|
||||||
|
fetchAssistantsSS,
|
||||||
|
} from "@/lib/assistants/fetchAssistantsSS";
|
||||||
import FunctionalHeader from "@/components/chat_search/Header";
|
import FunctionalHeader from "@/components/chat_search/Header";
|
||||||
import { defaultPersona } from "@/app/admin/assistants/lib";
|
import { defaultPersona } from "@/app/admin/assistants/lib";
|
||||||
|
|
||||||
@ -44,7 +47,8 @@ export default async function Page({ params }: { params: { chatId: string } }) {
|
|||||||
const authTypeMetadata = results[0] as AuthTypeMetadata | null;
|
const authTypeMetadata = results[0] as AuthTypeMetadata | null;
|
||||||
const user = results[1] as User | null;
|
const user = results[1] as User | null;
|
||||||
const chatSession = results[2] as BackendChatSession | null;
|
const chatSession = results[2] as BackendChatSession | null;
|
||||||
const availableAssistants = results[3] as Persona[] | null;
|
const assistantsResponse = results[3] as FetchAssistantsResponse | null;
|
||||||
|
const [availableAssistants, _] = assistantsResponse ?? [[], null];
|
||||||
|
|
||||||
const authDisabled = authTypeMetadata?.authType === "disabled";
|
const authDisabled = authTypeMetadata?.authType === "disabled";
|
||||||
if (!authDisabled && !user) {
|
if (!authDisabled && !user) {
|
||||||
@ -54,10 +58,11 @@ export default async function Page({ params }: { params: { chatId: string } }) {
|
|||||||
if (user && !user.is_verified && authTypeMetadata?.requiresVerification) {
|
if (user && !user.is_verified && authTypeMetadata?.requiresVerification) {
|
||||||
return redirect("/auth/waiting-on-verification");
|
return redirect("/auth/waiting-on-verification");
|
||||||
}
|
}
|
||||||
const persona = chatSession?.persona_id
|
|
||||||
? (availableAssistants?.find((p) => p.id === chatSession.persona_id) ??
|
const persona: Persona =
|
||||||
availableAssistants?.[0] ??
|
chatSession?.persona_id && availableAssistants?.length
|
||||||
null)
|
? (availableAssistants.find((p) => p.id === chatSession.persona_id) ??
|
||||||
|
defaultPersona)
|
||||||
: (availableAssistants?.[0] ?? defaultPersona);
|
: (availableAssistants?.[0] ?? defaultPersona);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user