fix: do not init audio model

This commit is contained in:
jialin
2025-02-28 12:23:02 +08:00
parent 295b4b3b72
commit 9927da5088
14 changed files with 134 additions and 70 deletions
@@ -198,10 +198,9 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
};
const submitMessage = async (current?: { role: string; content: string }) => {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
try {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
const validTextList = textList.filter((item) => item.text);
const validFileList = fileList.filter((item) => item.text);
@@ -229,7 +229,9 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
<FileImageOutlined className="font-size-32 text-secondary" />
</span>
<span>
{intl.formatMessage({ id: 'playground.params.empty.tips' })}
{intl.formatMessage({
id: 'playground.params.empty.tips'
})}
</span>
</div>
)}
@@ -308,7 +310,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
})}
>
<Button
size="middle"
size="small"
type="text"
icon={<SwapOutlined />}
onClick={handleToggleParamsStyle}
@@ -218,9 +218,9 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
};
const submitMessage = async () => {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
try {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
const documentList: any[] = [...textList, ...fileList];
const validDocus = documentList.filter((item) => item.text);
+19 -13
View File
@@ -41,10 +41,6 @@ interface MessageProps {
ref?: any;
}
const initialValues = {
language: 'auto'
};
const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
const intl = useIntl();
const { modelList } = props;
@@ -57,8 +53,9 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
const selectModel = searchParams.get('model')
? modelType === 'stt' && searchParams.get('model')
: '';
const defaultModel = selectModel || modelList[0]?.value || '';
const [parameters, setParams] = useState<any>({
model: selectModel,
model: defaultModel,
language: 'auto'
});
const [show, setShow] = useState(false);
@@ -112,9 +109,9 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
};
const submitMessage = async () => {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
try {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
setLoading(true);
setMessageId();
setTokenResult(null);
@@ -181,9 +178,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
}
};
const handleClear = () => {
if (!messageList.length) {
return;
}
setMessageId();
setMessageList([]);
setTokenResult(null);
@@ -243,6 +237,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
}, []);
const handleOnGenerate = async () => {
if (loading) {
handleStopConversation();
return;
}
submitMessage();
};
@@ -340,7 +338,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
title={
loading
? intl.formatMessage({
id: 'playground.audio.generating'
id: 'common.button.stop'
})
: intl.formatMessage({
id: 'playground.audio.button.generate'
@@ -350,12 +348,20 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
{
<Button
disabled={!audioData}
loading={loading}
type="primary"
size="middle"
shape="circle"
onClick={handleOnGenerate}
icon={<SendOutlined></SendOutlined>}
icon={
loading ? (
<IconFont
type="icon-stop1"
className="font-size-14"
></IconFont>
) : (
<SendOutlined></SendOutlined>
)
}
></Button>
}
</Tooltip>
+10 -15
View File
@@ -92,6 +92,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
};
});
const defaultModel = useMemo(() => {
return selectModel || modelList[0]?.value || '';
}, [modelList]);
const viewCodeContent = useMemo(() => {
return TextToSpeechCode({
api: AUDIO_TEXT_TO_SPEECH_API,
@@ -147,9 +151,9 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
};
const submitMessage = async (current?: { role: string; content: string }) => {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
try {
await formRef.current?.form.validateFields();
if (!parameters.model) return;
setLoading(true);
setMessageId();
setTokenResult(null);
@@ -235,14 +239,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
const handleSelectModel = useCallback(
async (value: string) => {
if (!value) {
setVoiceList([]);
setParams((pre: any) => {
return {
...pre,
voice: ''
};
});
formRef.current?.form.setFieldValue('voice', '');
return;
}
const model = modelList.find((item) => item.value === value);
@@ -259,10 +255,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setParams((pre: any) => {
return {
...pre,
model: value,
voice: newList[0]?.value
};
});
formRef.current?.form.setFieldValue('voice', newList[0]?.value);
},
[modelList]
);
@@ -307,11 +303,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
}, [paramsConfig, intl, voiceList]);
useEffect(() => {
if (!parameters.model && modelList.length) {
const model = modelList[0]?.value;
handleSelectModel(model);
if (defaultModel) {
handleSelectModel(defaultModel);
}
}, [modelList, parameters.model, handleSelectModel]);
}, [defaultModel]);
useEffect(() => {
if (scroller.current) {
@@ -506,7 +506,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
})}
>
<Button
size="middle"
size="small"
type="text"
icon={<SwapOutlined />}
onClick={handleToggleParamsStyle}