From 9462908560e75ac08de3e96b016b30e55f4b05fa Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Sun, 11 May 2025 19:40:05 +0000 Subject: [PATCH] Collapse references by default --- src/frontend/src/components/Answer/Answer.tsx | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) 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. + ); + })}
- + )}
)} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy