This commit is contained in:
StyleZhang 2024-04-01 21:17:17 +08:00
parent 1ab3b73c14
commit 4e31d7b64f
4 changed files with 8 additions and 6 deletions

View File

@ -29,6 +29,7 @@ type AnswerProps = {
responding?: boolean responding?: boolean
allToolIcons?: Record<string, string | Emoji> allToolIcons?: Record<string, string | Emoji>
showPromptLog?: boolean showPromptLog?: boolean
chatAnswerContainerInner?: string
} }
const Answer: FC<AnswerProps> = ({ const Answer: FC<AnswerProps> = ({
item, item,
@ -39,6 +40,7 @@ const Answer: FC<AnswerProps> = ({
responding, responding,
allToolIcons, allToolIcons,
showPromptLog, showPromptLog,
chatAnswerContainerInner,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const { const {
@ -70,7 +72,7 @@ const Answer: FC<AnswerProps> = ({
} }
</div> </div>
<div className='chat-answer-container grow w-0 ml-4'> <div className='chat-answer-container grow w-0 ml-4'>
<div className='relative pr-10'> <div className={`relative pr-10 ${chatAnswerContainerInner}`}>
<AnswerTriangle className='absolute -left-2 top-0 w-2 h-3 text-gray-100' /> <AnswerTriangle className='absolute -left-2 top-0 w-2 h-3 text-gray-100' />
<div <div
className={` className={`

View File

@ -50,6 +50,7 @@ export type ChatProps = {
onAnnotationRemoved?: (index: number) => void onAnnotationRemoved?: (index: number) => void
chatNode?: ReactNode chatNode?: ReactNode
onFeedback?: (messageId: string, feedback: Feedback) => void onFeedback?: (messageId: string, feedback: Feedback) => void
chatAnswerContainerInner?: string
} }
const Chat: FC<ChatProps> = ({ const Chat: FC<ChatProps> = ({
config, config,
@ -73,6 +74,7 @@ const Chat: FC<ChatProps> = ({
onAnnotationRemoved, onAnnotationRemoved,
chatNode, chatNode,
onFeedback, onFeedback,
chatAnswerContainerInner,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const { currentLogItem, setCurrentLogItem, showPromptLogModal, setShowPromptLogModal } = useAppStore() const { currentLogItem, setCurrentLogItem, showPromptLogModal, setShowPromptLogModal } = useAppStore()
@ -191,6 +193,7 @@ const Chat: FC<ChatProps> = ({
responding={isLast && isResponding} responding={isLast && isResponding}
allToolIcons={allToolIcons} allToolIcons={allToolIcons}
showPromptLog={showPromptLog} showPromptLog={showPromptLog}
chatAnswerContainerInner={chatAnswerContainerInner}
/> />
) )
} }

View File

@ -112,6 +112,7 @@ const ChatWrapper = forwardRef<ChatWrapperRefType>((_, ref) => {
)} )}
suggestedQuestions={suggestedQuestions} suggestedQuestions={suggestedQuestions}
showPromptLog showPromptLog
chatAnswerContainerInner='!pr-2'
/> />
) )
}) })

View File

@ -203,7 +203,7 @@ export const useChat = (
handleRun( handleRun(
params, params,
{ {
onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId }: any) => { onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId, errorMessage }: any) => {
responseItem.content = responseItem.content + message responseItem.content = responseItem.content + message
if (messageId && !hasSetResponseId) { if (messageId && !hasSetResponseId) {
@ -257,10 +257,6 @@ export const useChat = (
}, },
onError() { onError() {
handleResponding(false) handleResponding(false)
const newChatList = produce(chatListRef.current, (draft) => {
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
})
handleUpdateChatList(newChatList)
}, },
onWorkflowStarted: ({ workflow_run_id, task_id }) => { onWorkflowStarted: ({ workflow_run_id, task_id }) => {
taskIdRef.current = task_id taskIdRef.current = task_id