diff --git a/src/frontend/src/components/Answer/Answer.tsx b/src/frontend/src/components/Answer/Answer.tsx index a2bc6217..92b7ac19 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,23 +61,33 @@ 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}

    -

    Location: {citation.location}

    -

    Price level: {citation.price_level}

    -

    Rating: {citation.rating}

    -

    {citation.description}

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

    {citation.name}

    +

    Location: {citation.location}

    +

    Price level: {citation.price_level}

    +

    Rating: {citation.rating}

    +

    {citation.description}

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