diff --git a/src/frontend/src/components/Answer/Answer.tsx b/src/frontend/src/components/Answer/Answer.tsx index a542064c..01b8bd3f 100644 --- a/src/frontend/src/components/Answer/Answer.tsx +++ b/src/frontend/src/components/Answer/Answer.tsx @@ -1,4 +1,4 @@ -import { useMemo } from "react"; +import { useMemo, useState } from "react"; import { Stack, IconButton } from "@fluentui/react"; import DOMPurify from "dompurify"; @@ -29,6 +29,7 @@ export const Answer = ({ onFollowupQuestionClicked, showFollowupQuestions }: Props) => { + const [isReferencesCollapsed, setIsReferencesCollapsed] = useState(true); const followupQuestions = answer.context.followup_questions; const messageContent = answer.message.content; const parsedAnswer = useMemo(() => parseAnswerToHtml(messageContent, isStreaming, onCitationClicked), [answer]); @@ -60,22 +61,32 @@ export const Answer = ({ {!!parsedAnswer.citations.length && ( - References: + + setIsReferencesCollapsed(!isReferencesCollapsed)} + /> + References: + + + {!isReferencesCollapsed && (
    - {parsedAnswer.citations.map((rowId, ind) => { - const citation = answer.context.data_points[rowId]; - if (!citation) return null; - return ( -
  1. -

    {citation.name}

    -

    Brand: {citation.brand}

    -

    Price: {citation.price}

    -

    {citation.description}

    -
  2. - ); - })} + {parsedAnswer.citations.map((rowId, ind) => { + const citation = answer.context.data_points[rowId]; + if (!citation) return null; + return ( +
  3. +

    {citation.name}

    +

    Brand: {citation.brand}

    +

    Price: {citation.price}

    +

    {citation.description}

    +
  4. + ); + })}
- + )}
)}