balibabu
commited on
Commit
·
831bf51
1
Parent(s):
0ad4869
Fix: Fixed the issue with external chat box reporting errors #3909 (#4079)
Browse files### 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)
web/src/components/message-item/group-button.tsx
CHANGED
@@ -23,6 +23,7 @@ interface IProps {
|
|
23 |
prompt?: string;
|
24 |
showLikeButton: boolean;
|
25 |
audioBinary?: string;
|
|
|
26 |
}
|
27 |
|
28 |
export const AssistantGroupButton = ({
|
@@ -31,6 +32,7 @@ export const AssistantGroupButton = ({
|
|
31 |
prompt,
|
32 |
audioBinary,
|
33 |
showLikeButton,
|
|
|
34 |
}: IProps) => {
|
35 |
const { visible, hideModal, showModal, onFeedbackOk, loading } =
|
36 |
useSendFeedback(messageId);
|
@@ -52,12 +54,14 @@ export const AssistantGroupButton = ({
|
|
52 |
<Radio.Button value="a">
|
53 |
<CopyToClipboard text={content}></CopyToClipboard>
|
54 |
</Radio.Button>
|
55 |
-
|
56 |
-
<
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
61 |
{showLikeButton && (
|
62 |
<>
|
63 |
<Radio.Button value="c" onClick={handleLike}>
|
|
|
23 |
prompt?: string;
|
24 |
showLikeButton: boolean;
|
25 |
audioBinary?: string;
|
26 |
+
showLoudspeaker?: boolean;
|
27 |
}
|
28 |
|
29 |
export const AssistantGroupButton = ({
|
|
|
32 |
prompt,
|
33 |
audioBinary,
|
34 |
showLikeButton,
|
35 |
+
showLoudspeaker = true,
|
36 |
}: IProps) => {
|
37 |
const { visible, hideModal, showModal, onFeedbackOk, loading } =
|
38 |
useSendFeedback(messageId);
|
|
|
54 |
<Radio.Button value="a">
|
55 |
<CopyToClipboard text={content}></CopyToClipboard>
|
56 |
</Radio.Button>
|
57 |
+
{showLoudspeaker && (
|
58 |
+
<Radio.Button value="b" onClick={handleRead}>
|
59 |
+
<Tooltip title={t('chat.read')}>
|
60 |
+
{isPlaying ? <PauseCircleOutlined /> : <SoundOutlined />}
|
61 |
+
</Tooltip>
|
62 |
+
<audio src="" ref={ref}></audio>
|
63 |
+
</Radio.Button>
|
64 |
+
)}
|
65 |
{showLikeButton && (
|
66 |
<>
|
67 |
<Radio.Button value="c" onClick={handleLike}>
|
web/src/components/message-item/index.tsx
CHANGED
@@ -34,6 +34,7 @@ interface IProps extends Partial<IRemoveMessageById>, IRegenerateMessage {
|
|
34 |
clickDocumentButton?: (documentId: string, chunk: IReferenceChunk) => void;
|
35 |
index: number;
|
36 |
showLikeButton?: boolean;
|
|
|
37 |
}
|
38 |
|
39 |
const MessageItem = ({
|
@@ -48,6 +49,7 @@ const MessageItem = ({
|
|
48 |
removeMessageById,
|
49 |
regenerateMessage,
|
50 |
showLikeButton = true,
|
|
|
51 |
}: IProps) => {
|
52 |
const { theme } = useTheme();
|
53 |
const isAssistant = item.role === MessageType.Assistant;
|
@@ -120,6 +122,7 @@ const MessageItem = ({
|
|
120 |
prompt={item.prompt}
|
121 |
showLikeButton={showLikeButton}
|
122 |
audioBinary={item.audio_binary}
|
|
|
123 |
></AssistantGroupButton>
|
124 |
)
|
125 |
) : (
|
|
|
34 |
clickDocumentButton?: (documentId: string, chunk: IReferenceChunk) => void;
|
35 |
index: number;
|
36 |
showLikeButton?: boolean;
|
37 |
+
showLoudspeaker?: boolean;
|
38 |
}
|
39 |
|
40 |
const MessageItem = ({
|
|
|
49 |
removeMessageById,
|
50 |
regenerateMessage,
|
51 |
showLikeButton = true,
|
52 |
+
showLoudspeaker = true,
|
53 |
}: IProps) => {
|
54 |
const { theme } = useTheme();
|
55 |
const isAssistant = item.role === MessageType.Assistant;
|
|
|
122 |
prompt={item.prompt}
|
123 |
showLikeButton={showLikeButton}
|
124 |
audioBinary={item.audio_binary}
|
125 |
+
showLoudspeaker={showLoudspeaker}
|
126 |
></AssistantGroupButton>
|
127 |
)
|
128 |
) : (
|
web/src/pages/chat/share/large.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import MessageInput from '@/components/message-input';
|
2 |
import MessageItem from '@/components/message-item';
|
3 |
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
4 |
-
import { MessageType } from '@/constants/chat';
|
5 |
import { useSendButtonDisabled } from '@/pages/chat/hooks';
|
6 |
import { Flex, Spin } from 'antd';
|
7 |
import { forwardRef, useMemo } from 'react';
|
@@ -17,7 +17,7 @@ import { useFetchFlowSSE } from '@/hooks/flow-hooks';
|
|
17 |
import styles from './index.less';
|
18 |
|
19 |
const ChatContainer = () => {
|
20 |
-
const { sharedId: conversationId } = useGetSharedChatSearchParams();
|
21 |
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
22 |
useClickDrawer();
|
23 |
|
@@ -32,14 +32,14 @@ const ChatContainer = () => {
|
|
32 |
hasError,
|
33 |
} = useSendSharedMessage();
|
34 |
const sendDisabled = useSendButtonDisabled(value);
|
35 |
-
const useData = (from: SharedFrom) =>
|
36 |
-
useMemo(() => {
|
37 |
-
return from === SharedFrom.Agent
|
38 |
-
? useFetchFlowSSE
|
39 |
-
: useFetchNextConversationSSE;
|
40 |
-
}, [from]);
|
41 |
|
42 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
if (!conversationId) {
|
45 |
return <div>empty</div>;
|
@@ -55,7 +55,7 @@ const ChatContainer = () => {
|
|
55 |
return (
|
56 |
<MessageItem
|
57 |
key={message.id}
|
58 |
-
avatardialog={
|
59 |
item={message}
|
60 |
nickname="You"
|
61 |
reference={buildMessageItemReference(
|
@@ -72,6 +72,8 @@ const ChatContainer = () => {
|
|
72 |
}
|
73 |
index={i}
|
74 |
clickDocumentButton={clickDocumentButton}
|
|
|
|
|
75 |
></MessageItem>
|
76 |
);
|
77 |
})}
|
|
|
1 |
import MessageInput from '@/components/message-input';
|
2 |
import MessageItem from '@/components/message-item';
|
3 |
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
4 |
+
import { MessageType, SharedFrom } from '@/constants/chat';
|
5 |
import { useSendButtonDisabled } from '@/pages/chat/hooks';
|
6 |
import { Flex, Spin } from 'antd';
|
7 |
import { forwardRef, useMemo } from 'react';
|
|
|
17 |
import styles from './index.less';
|
18 |
|
19 |
const ChatContainer = () => {
|
20 |
+
const { sharedId: conversationId, from } = useGetSharedChatSearchParams();
|
21 |
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
22 |
useClickDrawer();
|
23 |
|
|
|
32 |
hasError,
|
33 |
} = useSendSharedMessage();
|
34 |
const sendDisabled = useSendButtonDisabled(value);
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
const useFetchAvatar = useMemo(() => {
|
37 |
+
return from === SharedFrom.Agent
|
38 |
+
? useFetchFlowSSE
|
39 |
+
: useFetchNextConversationSSE;
|
40 |
+
}, [from]);
|
41 |
+
|
42 |
+
const { data: avatarData } = useFetchAvatar();
|
43 |
|
44 |
if (!conversationId) {
|
45 |
return <div>empty</div>;
|
|
|
55 |
return (
|
56 |
<MessageItem
|
57 |
key={message.id}
|
58 |
+
avatardialog={avatarData?.avatar}
|
59 |
item={message}
|
60 |
nickname="You"
|
61 |
reference={buildMessageItemReference(
|
|
|
72 |
}
|
73 |
index={i}
|
74 |
clickDocumentButton={clickDocumentButton}
|
75 |
+
showLikeButton={false}
|
76 |
+
showLoudspeaker={false}
|
77 |
></MessageItem>
|
78 |
);
|
79 |
})}
|