chore: press enter to submit chat message
This commit is contained in:
@@ -238,7 +238,7 @@ const AudioInput: React.FC<AudioInputProps> = (props) => {
|
||||
|
||||
const generateFileNameByTime = (type?: string) => {
|
||||
const format = getAudioFormat(type);
|
||||
return `recording-${dayjs().format('YYYY-MM-DD-HH_mm_ss')}${format.suffix}`;
|
||||
return `Recording-${dayjs().format('YYYY-MM-DD-HH_mm_ss')}${format.suffix}`;
|
||||
};
|
||||
// start recording
|
||||
const StartRecording = async () => {
|
||||
|
||||
@@ -3,7 +3,6 @@ import ScatterChart from '@/components/echarts/scatter';
|
||||
import HighlightCode from '@/components/highlight-code';
|
||||
import IconFont from '@/components/icon-font';
|
||||
import SealInputNumber from '@/components/seal-form/input-number';
|
||||
import HotKeys, { KeyMap } from '@/config/hotkeys';
|
||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||
import useRequestToken from '@/hooks/use-request-token';
|
||||
import {
|
||||
@@ -29,7 +28,6 @@ import {
|
||||
useRef,
|
||||
useState
|
||||
} from 'react';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { EMBEDDING_API, handleEmbedding } from '../apis';
|
||||
import { LLM_METAKEYS } from '../hooks/config';
|
||||
import { useInitLLmMeta } from '../hooks/use-init-meta';
|
||||
@@ -447,17 +445,17 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
[]
|
||||
);
|
||||
|
||||
useHotkeys(
|
||||
HotKeys.SUBMIT,
|
||||
(e: any) => {
|
||||
e.preventDefault();
|
||||
handleSendMessage();
|
||||
},
|
||||
{
|
||||
enabled: !loading,
|
||||
preventDefault: true
|
||||
}
|
||||
);
|
||||
// useHotkeys(
|
||||
// HotKeys.SUBMIT,
|
||||
// (e: any) => {
|
||||
// e.preventDefault();
|
||||
// handleSendMessage();
|
||||
// },
|
||||
// {
|
||||
// enabled: !loading,
|
||||
// preventDefault: true
|
||||
// }
|
||||
// );
|
||||
|
||||
useEffect(() => {
|
||||
if (scroller.current) {
|
||||
@@ -526,7 +524,6 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
<Tooltip
|
||||
title={
|
||||
<span>
|
||||
[{KeyMap.SUBMIT.textKeybinding}]{' '}
|
||||
{intl.formatMessage({ id: 'common.button.submit' })}
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import AlertInfo from '@/components/alert-info';
|
||||
import SealInputNumber from '@/components/seal-form/input-number';
|
||||
import HotKeys, { KeyMap } from '@/config/hotkeys';
|
||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||
import useRequestToken from '@/hooks/use-request-token';
|
||||
import {
|
||||
@@ -23,7 +22,6 @@ import {
|
||||
useRef,
|
||||
useState
|
||||
} from 'react';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { rerankerQuery } from '../apis';
|
||||
import { ParamsSchema } from '../config/types';
|
||||
import { LLM_METAKEYS } from '../hooks/config';
|
||||
@@ -439,17 +437,17 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
useHotkeys(
|
||||
HotKeys.SUBMIT,
|
||||
(e: any) => {
|
||||
e.preventDefault();
|
||||
handleSearch(queryValue);
|
||||
},
|
||||
{
|
||||
enabled: !loading,
|
||||
preventDefault: true
|
||||
}
|
||||
);
|
||||
// useHotkeys(
|
||||
// HotKeys.SUBMIT,
|
||||
// (e: any) => {
|
||||
// e.preventDefault();
|
||||
// handleSearch(queryValue);
|
||||
// },
|
||||
// {
|
||||
// enabled: !loading,
|
||||
// preventDefault: true
|
||||
// }
|
||||
// );
|
||||
|
||||
useEffect(() => {
|
||||
if (scroller.current) {
|
||||
@@ -483,7 +481,6 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
<Tooltip
|
||||
title={
|
||||
<span>
|
||||
[{KeyMap.SUBMIT.textKeybinding}]{' '}
|
||||
{intl.formatMessage({ id: 'common.button.submit' })}
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import SealSelect from '@/components/seal-form/seal-select';
|
||||
import SpeechContent from '@/components/speech-content';
|
||||
import routeCachekey from '@/config/route-cachekey';
|
||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||
import { SendOutlined } from '@ant-design/icons';
|
||||
import { getLocale, useIntl, useSearchParams } from '@umijs/max';
|
||||
import { Form, Spin } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
@@ -392,7 +391,6 @@ const GroundTTS: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
onInputChange={handleInputChange}
|
||||
clearAll={handleClear}
|
||||
shouldResetMessage={false}
|
||||
submitIcon={<SendOutlined></SendOutlined>}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -314,6 +314,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
imguid={activeImgUid}
|
||||
imageStatus={imageStatus}
|
||||
imageSrc={image}
|
||||
loading={loading}
|
||||
disabled={loading || !imageStatus.isOriginal}
|
||||
onSave={handleOnSave}
|
||||
clearUploadMask={handleClearUploadMask}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import IconFont from '@/components/icon-font';
|
||||
import HotKeys, { KeyMap } from '@/config/hotkeys';
|
||||
import { ClearOutlined, SendOutlined, SwapOutlined } from '@ant-design/icons';
|
||||
import { ClearOutlined, EnterOutlined, SwapOutlined } from '@ant-design/icons';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Button, Checkbox, Divider, Input, Tooltip } from 'antd';
|
||||
import _ from 'lodash';
|
||||
@@ -279,6 +279,16 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
||||
}
|
||||
};
|
||||
|
||||
const handleOnKeydown = (e: any) => {
|
||||
if (e.key === KeyMap.ENTER.keybinding) {
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
handleSendMessage();
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteLastImage = useCallback(() => {
|
||||
if (message.imgs && message.imgs?.length > 0) {
|
||||
const newImgList = [...(message.imgs || [])];
|
||||
@@ -293,19 +303,6 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
||||
handleInputChange: handleInputChange
|
||||
}));
|
||||
|
||||
useHotkeys(
|
||||
HotKeys.SUBMIT,
|
||||
(e: any) => {
|
||||
console.log('submit message', loading);
|
||||
e.preventDefault();
|
||||
handleSendMessage();
|
||||
},
|
||||
{
|
||||
enabled: !loading && !isDisabled,
|
||||
enableOnFormTags: focused,
|
||||
preventDefault: true
|
||||
}
|
||||
);
|
||||
useHotkeys(
|
||||
HotKeys.ADD,
|
||||
(e: any) => {
|
||||
@@ -428,7 +425,7 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
||||
disabled={isDisabled}
|
||||
>
|
||||
{submitIcon ?? (
|
||||
<SendOutlined rotate={0} className="font-size-14" />
|
||||
<EnterOutlined rotate={0} className="font-size-14" />
|
||||
)}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
@@ -461,6 +458,7 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
||||
minRows: defaultSize.minRows,
|
||||
maxRows: defaultSize.maxRows
|
||||
}}
|
||||
onKeyDown={handleOnKeydown}
|
||||
onChange={handleInputChange}
|
||||
value={message.content}
|
||||
size="large"
|
||||
@@ -476,6 +474,7 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
||||
minRows: defaultSize.minRows,
|
||||
maxRows: defaultSize.maxRows
|
||||
}}
|
||||
onKeyDown={handleOnKeydown}
|
||||
onChange={handleInputChange}
|
||||
value={message.content}
|
||||
size="large"
|
||||
|
||||
@@ -69,10 +69,11 @@ export const useInitLLmMeta = (
|
||||
const { initialize: innitializeParams } = useOverlayScroller();
|
||||
|
||||
const defaultModel = useMemo(() => {
|
||||
return (
|
||||
searchParams.get('model') ||
|
||||
(isChat ? model ?? modelList?.[0]?.value : model)
|
||||
);
|
||||
if (isChat) {
|
||||
return searchParams.get('model') || model || modelList?.[0]?.value;
|
||||
}
|
||||
// use for multiple chat
|
||||
return model;
|
||||
}, [model, modelList, isChat]);
|
||||
const extractLLMMeta = (meta: any) => {
|
||||
const towKeys = new Set(precisionTwoKeys);
|
||||
|
||||
Reference in New Issue
Block a user