mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-04 11:24:00 +08:00
### What problem does this PR solve? Fix: Fixed the issue with external chat box reporting errors #3909 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
0a3c6fff7c
commit
00f99ecbd5
@ -23,6 +23,7 @@ interface IProps {
|
|||||||
prompt?: string;
|
prompt?: string;
|
||||||
showLikeButton: boolean;
|
showLikeButton: boolean;
|
||||||
audioBinary?: string;
|
audioBinary?: string;
|
||||||
|
showLoudspeaker?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AssistantGroupButton = ({
|
export const AssistantGroupButton = ({
|
||||||
@ -31,6 +32,7 @@ export const AssistantGroupButton = ({
|
|||||||
prompt,
|
prompt,
|
||||||
audioBinary,
|
audioBinary,
|
||||||
showLikeButton,
|
showLikeButton,
|
||||||
|
showLoudspeaker = true,
|
||||||
}: IProps) => {
|
}: IProps) => {
|
||||||
const { visible, hideModal, showModal, onFeedbackOk, loading } =
|
const { visible, hideModal, showModal, onFeedbackOk, loading } =
|
||||||
useSendFeedback(messageId);
|
useSendFeedback(messageId);
|
||||||
@ -52,12 +54,14 @@ export const AssistantGroupButton = ({
|
|||||||
<Radio.Button value="a">
|
<Radio.Button value="a">
|
||||||
<CopyToClipboard text={content}></CopyToClipboard>
|
<CopyToClipboard text={content}></CopyToClipboard>
|
||||||
</Radio.Button>
|
</Radio.Button>
|
||||||
<Radio.Button value="b" onClick={handleRead}>
|
{showLoudspeaker && (
|
||||||
<Tooltip title={t('chat.read')}>
|
<Radio.Button value="b" onClick={handleRead}>
|
||||||
{isPlaying ? <PauseCircleOutlined /> : <SoundOutlined />}
|
<Tooltip title={t('chat.read')}>
|
||||||
</Tooltip>
|
{isPlaying ? <PauseCircleOutlined /> : <SoundOutlined />}
|
||||||
<audio src="" ref={ref}></audio>
|
</Tooltip>
|
||||||
</Radio.Button>
|
<audio src="" ref={ref}></audio>
|
||||||
|
</Radio.Button>
|
||||||
|
)}
|
||||||
{showLikeButton && (
|
{showLikeButton && (
|
||||||
<>
|
<>
|
||||||
<Radio.Button value="c" onClick={handleLike}>
|
<Radio.Button value="c" onClick={handleLike}>
|
||||||
|
@ -34,6 +34,7 @@ interface IProps extends Partial<IRemoveMessageById>, IRegenerateMessage {
|
|||||||
clickDocumentButton?: (documentId: string, chunk: IReferenceChunk) => void;
|
clickDocumentButton?: (documentId: string, chunk: IReferenceChunk) => void;
|
||||||
index: number;
|
index: number;
|
||||||
showLikeButton?: boolean;
|
showLikeButton?: boolean;
|
||||||
|
showLoudspeaker?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MessageItem = ({
|
const MessageItem = ({
|
||||||
@ -48,6 +49,7 @@ const MessageItem = ({
|
|||||||
removeMessageById,
|
removeMessageById,
|
||||||
regenerateMessage,
|
regenerateMessage,
|
||||||
showLikeButton = true,
|
showLikeButton = true,
|
||||||
|
showLoudspeaker = true,
|
||||||
}: IProps) => {
|
}: IProps) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const isAssistant = item.role === MessageType.Assistant;
|
const isAssistant = item.role === MessageType.Assistant;
|
||||||
@ -120,6 +122,7 @@ const MessageItem = ({
|
|||||||
prompt={item.prompt}
|
prompt={item.prompt}
|
||||||
showLikeButton={showLikeButton}
|
showLikeButton={showLikeButton}
|
||||||
audioBinary={item.audio_binary}
|
audioBinary={item.audio_binary}
|
||||||
|
showLoudspeaker={showLoudspeaker}
|
||||||
></AssistantGroupButton>
|
></AssistantGroupButton>
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import MessageInput from '@/components/message-input';
|
import MessageInput from '@/components/message-input';
|
||||||
import MessageItem from '@/components/message-item';
|
import MessageItem from '@/components/message-item';
|
||||||
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
||||||
import { MessageType } from '@/constants/chat';
|
import { MessageType, SharedFrom } from '@/constants/chat';
|
||||||
import { useSendButtonDisabled } from '@/pages/chat/hooks';
|
import { useSendButtonDisabled } from '@/pages/chat/hooks';
|
||||||
import { Flex, Spin } from 'antd';
|
import { Flex, Spin } from 'antd';
|
||||||
import { forwardRef, useMemo } from 'react';
|
import { forwardRef, useMemo } from 'react';
|
||||||
@ -17,7 +17,7 @@ import { useFetchFlowSSE } from '@/hooks/flow-hooks';
|
|||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const ChatContainer = () => {
|
const ChatContainer = () => {
|
||||||
const { sharedId: conversationId } = useGetSharedChatSearchParams();
|
const { sharedId: conversationId, from } = useGetSharedChatSearchParams();
|
||||||
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
||||||
useClickDrawer();
|
useClickDrawer();
|
||||||
|
|
||||||
@ -32,14 +32,14 @@ const ChatContainer = () => {
|
|||||||
hasError,
|
hasError,
|
||||||
} = useSendSharedMessage();
|
} = useSendSharedMessage();
|
||||||
const sendDisabled = useSendButtonDisabled(value);
|
const sendDisabled = useSendButtonDisabled(value);
|
||||||
const useData = (from: SharedFrom) =>
|
|
||||||
useMemo(() => {
|
|
||||||
return from === SharedFrom.Agent
|
|
||||||
? useFetchFlowSSE
|
|
||||||
: useFetchNextConversationSSE;
|
|
||||||
}, [from]);
|
|
||||||
|
|
||||||
const { data: InforForm } = useData(from)();
|
const useFetchAvatar = useMemo(() => {
|
||||||
|
return from === SharedFrom.Agent
|
||||||
|
? useFetchFlowSSE
|
||||||
|
: useFetchNextConversationSSE;
|
||||||
|
}, [from]);
|
||||||
|
|
||||||
|
const { data: avatarData } = useFetchAvatar();
|
||||||
|
|
||||||
if (!conversationId) {
|
if (!conversationId) {
|
||||||
return <div>empty</div>;
|
return <div>empty</div>;
|
||||||
@ -55,7 +55,7 @@ const ChatContainer = () => {
|
|||||||
return (
|
return (
|
||||||
<MessageItem
|
<MessageItem
|
||||||
key={message.id}
|
key={message.id}
|
||||||
avatardialog={InforForm?.avatar}
|
avatardialog={avatarData?.avatar}
|
||||||
item={message}
|
item={message}
|
||||||
nickname="You"
|
nickname="You"
|
||||||
reference={buildMessageItemReference(
|
reference={buildMessageItemReference(
|
||||||
@ -72,6 +72,8 @@ const ChatContainer = () => {
|
|||||||
}
|
}
|
||||||
index={i}
|
index={i}
|
||||||
clickDocumentButton={clickDocumentButton}
|
clickDocumentButton={clickDocumentButton}
|
||||||
|
showLikeButton={false}
|
||||||
|
showLoudspeaker={false}
|
||||||
></MessageItem>
|
></MessageItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user