mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-05-31 18:45:54 +08:00
### What problem does this PR solve? feat: Hide the upload button in the external agent's chat box #1880 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
4121636084
commit
8e75a23ad0
@ -1,3 +1,4 @@
|
|||||||
|
import { SharedFrom } from '@/constants/chat';
|
||||||
import {
|
import {
|
||||||
useCreateNextToken,
|
useCreateNextToken,
|
||||||
useFetchTokenList,
|
useFetchTokenList,
|
||||||
@ -71,9 +72,9 @@ export const useShowTokenEmptyError = () => {
|
|||||||
return { showTokenEmptyError };
|
return { showTokenEmptyError };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUrlWithToken = (token: string) => {
|
const getUrlWithToken = (token: string, from: string = 'chat') => {
|
||||||
const { protocol, host } = window.location;
|
const { protocol, host } = window.location;
|
||||||
return `${protocol}//${host}/chat/share?shared_id=${token}`;
|
return `${protocol}//${host}/chat/share?shared_id=${token}&from=${from}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useFetchTokenListBeforeOtherStep = (dialogId: string, idKey: string) => {
|
const useFetchTokenListBeforeOtherStep = (dialogId: string, idKey: string) => {
|
||||||
@ -131,9 +132,18 @@ export const useShowEmbedModal = (dialogId: string, idKey: string) => {
|
|||||||
export const usePreviewChat = (dialogId: string, idKey: string) => {
|
export const usePreviewChat = (dialogId: string, idKey: string) => {
|
||||||
const { handleOperate } = useFetchTokenListBeforeOtherStep(dialogId, idKey);
|
const { handleOperate } = useFetchTokenListBeforeOtherStep(dialogId, idKey);
|
||||||
|
|
||||||
const open = useCallback((t: string) => {
|
const open = useCallback(
|
||||||
window.open(getUrlWithToken(t), '_blank');
|
(t: string) => {
|
||||||
}, []);
|
window.open(
|
||||||
|
getUrlWithToken(
|
||||||
|
t,
|
||||||
|
idKey === 'canvasId' ? SharedFrom.Agent : SharedFrom.Chat,
|
||||||
|
),
|
||||||
|
'_blank',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[idKey],
|
||||||
|
);
|
||||||
|
|
||||||
const handlePreview = useCallback(async () => {
|
const handlePreview = useCallback(async () => {
|
||||||
const token = await handleOperate();
|
const token = await handleOperate();
|
||||||
|
@ -66,6 +66,7 @@ interface IProps {
|
|||||||
conversationId: string;
|
conversationId: string;
|
||||||
uploadUrl?: string;
|
uploadUrl?: string;
|
||||||
isShared?: boolean;
|
isShared?: boolean;
|
||||||
|
showUploadIcon?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getBase64 = (file: FileType): Promise<string> =>
|
const getBase64 = (file: FileType): Promise<string> =>
|
||||||
@ -85,6 +86,7 @@ const MessageInput = ({
|
|||||||
sendLoading,
|
sendLoading,
|
||||||
onInputChange,
|
onInputChange,
|
||||||
conversationId,
|
conversationId,
|
||||||
|
showUploadIcon = true,
|
||||||
uploadUrl = '/v1/document/upload_and_parse',
|
uploadUrl = '/v1/document/upload_and_parse',
|
||||||
}: IProps) => {
|
}: IProps) => {
|
||||||
const { t } = useTranslate('chat');
|
const { t } = useTranslate('chat');
|
||||||
@ -158,7 +160,7 @@ const MessageInput = ({
|
|||||||
className={classNames({ [styles.inputWrapper]: fileList.length === 0 })}
|
className={classNames({ [styles.inputWrapper]: fileList.length === 0 })}
|
||||||
suffix={
|
suffix={
|
||||||
<Space>
|
<Space>
|
||||||
{conversationId && (
|
{conversationId && showUploadIcon && (
|
||||||
<Upload
|
<Upload
|
||||||
action={uploadUrl}
|
action={uploadUrl}
|
||||||
fileList={fileList}
|
fileList={fileList}
|
||||||
|
@ -10,3 +10,8 @@ export const variableEnabledFieldMap = {
|
|||||||
frequencyPenaltyEnabled: 'frequency_penalty',
|
frequencyPenaltyEnabled: 'frequency_penalty',
|
||||||
maxTokensEnabled: 'max_tokens',
|
maxTokensEnabled: 'max_tokens',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export enum SharedFrom {
|
||||||
|
Agent = 'agent',
|
||||||
|
Chat = 'chat',
|
||||||
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
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 { 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 } from 'react';
|
import { forwardRef } from 'react';
|
||||||
import {
|
import {
|
||||||
useCreateSharedConversationOnMount,
|
useCreateSharedConversationOnMount,
|
||||||
|
useGetSharedChatSearchParams,
|
||||||
useSelectCurrentSharedConversation,
|
useSelectCurrentSharedConversation,
|
||||||
useSendSharedMessage,
|
useSendSharedMessage,
|
||||||
} from '../shared-hooks';
|
} from '../shared-hooks';
|
||||||
@ -37,6 +38,7 @@ const ChatContainer = () => {
|
|||||||
addNewestAnswer,
|
addNewestAnswer,
|
||||||
);
|
);
|
||||||
const sendDisabled = useSendButtonDisabled(value);
|
const sendDisabled = useSendButtonDisabled(value);
|
||||||
|
const { from } = useGetSharedChatSearchParams();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -74,6 +76,7 @@ const ChatContainer = () => {
|
|||||||
onPressEnter={handlePressEnter}
|
onPressEnter={handlePressEnter}
|
||||||
sendLoading={sendLoading}
|
sendLoading={sendLoading}
|
||||||
uploadUrl="/v1/api/document/upload_and_parse"
|
uploadUrl="/v1/api/document/upload_and_parse"
|
||||||
|
showUploadIcon={from === SharedFrom.Chat}
|
||||||
></MessageInput>
|
></MessageInput>
|
||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { MessageType } from '@/constants/chat';
|
import { MessageType, SharedFrom } from '@/constants/chat';
|
||||||
import {
|
import {
|
||||||
useCreateSharedConversation,
|
useCreateSharedConversation,
|
||||||
useFetchSharedConversation,
|
useFetchSharedConversation,
|
||||||
@ -225,3 +225,12 @@ export const useSendSharedMessage = (
|
|||||||
loading: !done,
|
loading: !done,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useGetSharedChatSearchParams = () => {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
|
return {
|
||||||
|
from: searchParams.get('from') as SharedFrom,
|
||||||
|
sharedId: searchParams.get('shared_id'),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user