feat: show citation info in run history (#3399)

This commit is contained in:
Nite Knite 2024-04-12 12:19:27 +08:00 committed by GitHub
parent b00466f025
commit c9abb75fce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 14 additions and 11 deletions

View File

@ -121,7 +121,7 @@ const ChatItem: FC<ChatItemProps> = ({
isResponding={isResponding} isResponding={isResponding}
noChatInput noChatInput
noStopResponding noStopResponding
chatContainerclassName='p-4' chatContainerClassName='p-4'
chatFooterClassName='p-4 pb-0' chatFooterClassName='p-4 pb-0'
suggestedQuestions={suggestedQuestions} suggestedQuestions={suggestedQuestions}
onSend={doSend} onSend={doSend}

View File

@ -119,7 +119,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
config={config} config={config}
chatList={chatList} chatList={chatList}
isResponding={isResponding} isResponding={isResponding}
chatContainerclassName='p-6' chatContainerClassName='p-6'
chatFooterClassName='px-6 pt-10 pb-4' chatFooterClassName='px-6 pt-10 pb-4'
suggestedQuestions={suggestedQuestions} suggestedQuestions={suggestedQuestions}
onSend={doSend} onSend={doSend}

View File

@ -163,8 +163,8 @@ const Answer: FC<AnswerProps> = ({
} }
<SuggestedQuestions item={item} /> <SuggestedQuestions item={item} />
{ {
!!citation?.length && config?.retriever_resource?.enabled && !responding && ( !!citation?.length && !responding && (
<Citation data={citation} showHitInfo={config.supportCitationHitInfo} /> <Citation data={citation} showHitInfo={config?.supportCitationHitInfo} />
) )
} }
</div> </div>

View File

@ -11,6 +11,7 @@ import {
} from 'react' } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import classNames from 'classnames'
import type { import type {
ChatConfig, ChatConfig,
ChatItem, ChatItem,
@ -36,7 +37,7 @@ export type ChatProps = {
onStopResponding?: () => void onStopResponding?: () => void
noChatInput?: boolean noChatInput?: boolean
onSend?: OnSend onSend?: OnSend
chatContainerclassName?: string chatContainerClassName?: string
chatContainerInnerClassName?: string chatContainerInnerClassName?: string
chatFooterClassName?: string chatFooterClassName?: string
chatFooterInnerClassName?: string chatFooterInnerClassName?: string
@ -60,7 +61,7 @@ const Chat: FC<ChatProps> = ({
noStopResponding, noStopResponding,
onStopResponding, onStopResponding,
noChatInput, noChatInput,
chatContainerclassName, chatContainerClassName,
chatContainerInnerClassName, chatContainerInnerClassName,
chatFooterClassName, chatFooterClassName,
chatFooterInnerClassName, chatFooterInnerClassName,
@ -171,7 +172,7 @@ const Chat: FC<ChatProps> = ({
<div className='relative h-full'> <div className='relative h-full'>
<div <div
ref={chatContainerRef} ref={chatContainerRef}
className={`relative h-full overflow-y-auto ${chatContainerclassName}`} className={classNames('relative h-full overflow-y-auto', chatContainerClassName)}
> >
{chatNode} {chatNode}
<div <div

View File

@ -35,7 +35,7 @@ const ChatRecord = () => {
content: item.answer, content: item.answer,
feedback: item.feedback, feedback: item.feedback,
isAnswer: true, isAnswer: true,
citation: item.retriever_resources, citation: item.metadata?.retriever_resources,
message_files: item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [], message_files: item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [],
workflow_run_id: item.workflow_run_id, workflow_run_id: item.workflow_run_id,
}) })
@ -82,9 +82,11 @@ const ChatRecord = () => {
</div> </div>
<div className='grow h-0'> <div className='grow h-0'>
<Chat <Chat
config={{} as any} config={{
supportCitationHitInfo: true,
} as any}
chatList={chatMessageList} chatList={chatMessageList}
chatContainerclassName='px-4' chatContainerClassName='px-4'
chatContainerInnerClassName='pt-6' chatContainerInnerClassName='pt-6'
chatFooterClassName='px-4 rounded-b-2xl' chatFooterClassName='px-4 rounded-b-2xl'
chatFooterInnerClassName='pb-4' chatFooterInnerClassName='pb-4'

View File

@ -94,7 +94,7 @@ const ChatWrapper = forwardRef<ChatWrapperRefType>((_, ref) => {
} as any} } as any}
chatList={chatList} chatList={chatList}
isResponding={isResponding} isResponding={isResponding}
chatContainerclassName='px-4' chatContainerClassName='px-4'
chatContainerInnerClassName='pt-6' chatContainerInnerClassName='pt-6'
chatFooterClassName='px-4 rounded-bl-2xl' chatFooterClassName='px-4 rounded-bl-2xl'
chatFooterInnerClassName='pb-4' chatFooterInnerClassName='pb-4'