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
allToolIcons?: Record<string, string | Emoji>
showPromptLog?: boolean
chatAnswerContainerInner?: string
}
const Answer: FC<AnswerProps> = ({
item,
@ -39,6 +40,7 @@ const Answer: FC<AnswerProps> = ({
responding,
allToolIcons,
showPromptLog,
chatAnswerContainerInner,
}) => {
const { t } = useTranslation()
const {
@ -70,7 +72,7 @@ const Answer: FC<AnswerProps> = ({
}
</div>
<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' />
<div
className={`

View File

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

View File

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

View File

@ -203,7 +203,7 @@ export const useChat = (
handleRun(
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
if (messageId && !hasSetResponseId) {
@ -257,10 +257,6 @@ export const useChat = (
},
onError() {
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 }) => {
taskIdRef.current = task_id