diff --git a/web/app/components/app/chat/answer/index.tsx b/web/app/components/app/chat/answer/index.tsx index 7138aeba881e40..af37d60b05129b 100644 --- a/web/app/components/app/chat/answer/index.tsx +++ b/web/app/components/app/chat/answer/index.tsx @@ -1,13 +1,13 @@ 'use client' import type { FC, ReactNode } from 'react' -import React, { useState } from 'react' +import React, { useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { UserCircleIcon } from '@heroicons/react/24/solid' import cn from 'classnames' import type { CitationItem, DisplayScene, FeedbackFunc, Feedbacktype, IChatItem } from '../type' import OperationBtn from '../operation' import LoadingAnim from '../loading-anim' -import { EditIconSolid, RatingIcon } from '../icon-component' +import { RatingIcon } from '../icon-component' import s from '../style.module.css' import MoreInfo from '../more-info' import CopyBtn from '../copy-btn' @@ -26,16 +26,8 @@ import { MessageFast } from '@/app/components/base/icons/src/vender/solid/commun import type { Emoji } from '@/app/components/tools/types' import type { VisionFile } from '@/types/app' import ImageGallery from '@/app/components/base/image-gallery' +import Log from '@/app/components/app/chat/log' -const Divider: FC<{ name: string }> = ({ name }) => { - const { t } = useTranslation() - return
- - {t('appLog.detail.annotationTip', { user: name })} - -
-
-} const IconWrapper: FC<{ children: React.ReactNode | string }> = ({ children }) => { return
{children} @@ -64,6 +56,7 @@ export type IAnswerProps = { onAnnotationAdded?: (annotationId: string, authorName: string, question: string, answer: string, index: number) => void onAnnotationRemoved?: (index: number) => void allToolIcons?: Record + isShowPromptLog?: boolean } // The component needs to maintain its own state to control whether to display input component const Answer: FC = ({ @@ -87,12 +80,11 @@ const Answer: FC = ({ onAnnotationAdded, onAnnotationRemoved, allToolIcons, + isShowPromptLog, }) => { const { id, content, more, feedback, adminFeedback, annotation, agent_thoughts } = item const isAgentMode = !!agent_thoughts && agent_thoughts.length > 0 const hasAnnotation = !!annotation?.id - const [showEdit, setShowEdit] = useState(false) - const [loading, setLoading] = useState(false) // const [annotation, setAnnotation] = useState(initAnnotation) // const [inputValue, setInputValue] = useState(initAnnotation?.content ?? '') const [localAdminFeedback, setLocalAdminFeedback] = useState(adminFeedback) @@ -241,9 +233,11 @@ const Answer: FC = ({
) + const ref = useRef(null) + return ( // data-id for debug the item message is right -
+
{ answerIcon || ( @@ -257,7 +251,7 @@ const Answer: FC = ({ ) }
-
+
{(isResponding && (isAgentMode ? (!content && (agent_thoughts || []).filter(item => !!item.thought || !!item.tool).length === 0) : !content)) @@ -326,11 +320,21 @@ const Answer: FC = ({ className={cn(s.copyBtn, 'mr-1')} /> )} - {!item.isOpeningStatement && isShowTextToSpeech && ( - + {((isShowPromptLog && !isResponding) || (!item.isOpeningStatement && isShowTextToSpeech)) && ( +
+ {isShowPromptLog && !isResponding && ( + + )} + {!item.isOpeningStatement && isShowTextToSpeech && ( + <> +
+ + + )} +
)} {(!item.isOpeningStatement && supportAnnotation) && ( = ({ onAnnotationAdded={handleAnnotationAdded} onAnnotationRemoved={handleAnnotationRemoved} allToolIcons={allToolIcons} + isShowPromptLog={isShowPromptLog} /> } return ( @@ -316,140 +317,132 @@ const Chat: FC = ({ ) })}
- { - !isHideSendInput && ( -
- {/* Thinking is sync and can not be stopped */} - {(isResponding && canStopResponding && ((!!chatList[chatList.length - 1]?.content) || (chatList[chatList.length - 1]?.agent_thoughts && chatList[chatList.length - 1].agent_thoughts!.length > 0))) && ( -
- + {!isHideSendInput && ( +
+ {/* Thinking is sync and can not be stopped */} + {(isResponding && canStopResponding && ((!!chatList[chatList.length - 1]?.content) || (chatList[chatList.length - 1]?.agent_thoughts && chatList[chatList.length - 1].agent_thoughts!.length > 0))) && ( +
+ +
+ )} + {isShowSuggestion && ( +
+
+
+
+ {TryToAskIcon} + {t('appDebug.feature.suggestedQuestionsAfterAnswer.tryToAsk')} +
+
- )} - { - isShowSuggestion && ( -
-
-
-
- {TryToAskIcon} - {t('appDebug.feature.suggestedQuestionsAfterAnswer.tryToAsk')} -
-
-
- {/* has scrollbar would hide part of first item */} -
- {suggestionList?.map((item, index) => ( -
- -
- ))} + {/* has scrollbar would hide part of first item */} +
+ {suggestionList?.map((item, index) => ( +
+
-
) - } -
+ ))} +
+
+ )} +
+ {visionConfig?.enabled && ( + <> +
+ = visionConfig.number_limits} + /> +
+
+
+ +
+ + )} +