diff --git a/src/locales/en-US/playground.ts b/src/locales/en-US/playground.ts index d5e8b608..726f85e1 100644 --- a/src/locales/en-US/playground.ts +++ b/src/locales/en-US/playground.ts @@ -95,6 +95,7 @@ export default { 'playground.multiple.on': 'Enable', 'playground.multiple.off': 'Disable', 'playground.image.params.sampler': 'Sampler', + 'playground.image.params.schedule': 'Schedule', 'playground.image.params.samplerSteps': 'Sampler Steps', 'playground.image.params.seed': 'Seed', 'playground.image.params.negativePrompt': 'Negative Prompt', diff --git a/src/locales/zh-CN/playground.ts b/src/locales/zh-CN/playground.ts index 1a38e8b7..e6dcd7a4 100644 --- a/src/locales/zh-CN/playground.ts +++ b/src/locales/zh-CN/playground.ts @@ -92,6 +92,7 @@ export default { 'playground.multiple.on': '开启', 'playground.multiple.off': '关闭', 'playground.image.params.sampler': '采样方法', + 'playground.image.params.schedule': '调度', 'playground.image.params.samplerSteps': '迭代步数', 'playground.image.params.seed': '随机种子', 'playground.image.params.negativePrompt': '负向提示', diff --git a/src/pages/llmodels/components/table-list.tsx b/src/pages/llmodels/components/table-list.tsx index 1bb3186a..080a465c 100644 --- a/src/pages/llmodels/components/table-list.tsx +++ b/src/pages/llmodels/components/table-list.tsx @@ -236,14 +236,9 @@ const Models: React.FC = ({ const setActionList = useCallback((record: ListItem) => { return _.filter(ActionList, (action: any) => { if (action.key === 'chat') { - return record.ready_replicas > 0 && !record.embedding_only; - } - if (action.key === 'embedding') { - return ( - (record.embedding_only || record.reranker) && - record.ready_replicas > 0 - ); + return record.ready_replicas > 0; } + return true; }); }, []); diff --git a/src/pages/playground/components/ground-embedding.tsx b/src/pages/playground/components/ground-embedding.tsx index 2e3d2e23..1f485880 100644 --- a/src/pages/playground/components/ground-embedding.tsx +++ b/src/pages/playground/components/ground-embedding.tsx @@ -14,6 +14,7 @@ import { import { useIntl, useSearchParams } from '@umijs/max'; import { Button, Checkbox, Segmented, Tabs, Tooltip } from 'antd'; import classNames from 'classnames'; +import _ from 'lodash'; import { PCA } from 'ml-pca'; import 'overlayscrollbars/overlayscrollbars.css'; import { Resizable } from 're-resizable'; @@ -147,7 +148,8 @@ const GroundEmbedding: React.FC = forwardRef((props, ref) => { }; }); setScatterData(list); - const embeddingJson = embeddings.map((item, index) => { + const embeddingJson = embeddings.map((o, index) => { + const item = _.cloneDeep(o); item.embedding = item.embedding.slice(0, 5); item.embedding.push(null); return item; @@ -286,7 +288,7 @@ const GroundEmbedding: React.FC = forwardRef((props, ref) => { const dataLlist = text.split('\n').map((item: string) => { return { text: item?.trim(), - uid: setMessageId(), + uid: inputListRef.current?.setMessageId(), name: '' }; }); @@ -300,7 +302,7 @@ const GroundEmbedding: React.FC = forwardRef((props, ref) => { .map((item, index) => { return { ...item, - uid: setMessageId() + uid: inputListRef.current?.setMessageId() }; }); setTextList(result); @@ -449,20 +451,22 @@ const GroundEmbedding: React.FC = forwardRef((props, ref) => { style={{ width: 60 }} > ) : ( - + + )} diff --git a/src/pages/playground/components/ground-images.tsx b/src/pages/playground/components/ground-images.tsx index 3e9ce863..fc2f74eb 100644 --- a/src/pages/playground/components/ground-images.tsx +++ b/src/pages/playground/components/ground-images.tsx @@ -52,7 +52,8 @@ const initialValues = { sampler: 'euler_a', cfg_scale: 4.5, sample_steps: 10, - negative_prompt: null + negative_prompt: null, + schedule: 'discrete' }; const GroundImages: React.FC = forwardRef((props, ref) => { @@ -241,9 +242,7 @@ const GroundImages: React.FC = forwardRef((props, ref) => { const params = { stream: true, - stream_options: { - // chunk_result: false - }, + stream_options: {}, prompt: current?.content || currentPrompt || '', ..._.omitBy(finalParameters, (value: string) => !value) }; @@ -253,6 +252,15 @@ const GroundImages: React.FC = forwardRef((props, ref) => { url: `${CREAT_IMAGE_API}?t=${Date.now()}`, signal: requestToken.current.signal }); + if (result.error) { + setTokenResult({ + error: true, + errorMessage: + result?.data?.error?.message || result?.data?.error || '' + }); + setImageList([]); + return; + } const { reader, decoder } = result; const imgSize = _.split(finalParameters.size, 'x'); @@ -265,7 +273,6 @@ const GroundImages: React.FC = forwardRef((props, ref) => { }); return; } - console.log('imgItem.dataUrl:', chunk.data); chunk?.data?.forEach((item: any) => { const imgItem = newImageList[item.index]; if (item.b64_json) { @@ -285,7 +292,6 @@ const GroundImages: React.FC = forwardRef((props, ref) => { }; }); setImageList([...newImageList]); - console.log('newImageList:', newImageList); }); } catch (error) { console.log('error:', error); @@ -320,7 +326,8 @@ const GroundImages: React.FC = forwardRef((props, ref) => { sampler: 'euler_a', cfg_scale: 4.5, sample_steps: 10, - negative_prompt: null + negative_prompt: null, + schedule: 'discrete' }); setParams((pre: object) => { return { @@ -329,7 +336,8 @@ const GroundImages: React.FC = forwardRef((props, ref) => { sampler: 'euler_a', cfg_scale: 4.5, sample_steps: 10, - negative_prompt: null + negative_prompt: null, + schedule: 'discrete' }; }); } else { @@ -342,7 +350,8 @@ const GroundImages: React.FC = forwardRef((props, ref) => { 'sampler', 'cfg_scale', 'sample_steps', - 'negative_prompt' + 'negative_prompt', + 'schedule' ]) }; }); @@ -519,8 +528,8 @@ const GroundImages: React.FC = forwardRef((props, ref) => { })} actions={['clear']} defaultSize={{ - minRows: 6, - maxRows: 6 + minRows: 5, + maxRows: 5 }} loading={loading} disabled={!parameters.model} diff --git a/src/pages/playground/components/ground-left.tsx b/src/pages/playground/components/ground-left.tsx index 84f08786..fad6f900 100644 --- a/src/pages/playground/components/ground-left.tsx +++ b/src/pages/playground/components/ground-left.tsx @@ -294,6 +294,10 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { )}
= forwardRef((props, ref) => { ] .filter((item) => item.text) .map((item, index) => { + item.percent = undefined; + item.score = undefined; + item.rank = undefined; return { ...item, uid: setMessageId() diff --git a/src/pages/playground/components/ground-stt.tsx b/src/pages/playground/components/ground-stt.tsx index e3dc70d9..f5d485b2 100644 --- a/src/pages/playground/components/ground-stt.tsx +++ b/src/pages/playground/components/ground-stt.tsx @@ -1,3 +1,4 @@ +import AlertInfo from '@/components/alert-info'; import AudioAnimation from '@/components/audio-animation'; import AudioPlayer from '@/components/audio-player'; import IconFont from '@/components/icon-font'; @@ -54,7 +55,6 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { const controllerRef = useRef(null); const scroller = useRef(null); const paramsRef = useRef(null); - const messageListLengthCache = useRef(0); const [audioPermissionOn, setAudioPermissionOn] = useState(true); const [audioData, setAudioData] = useState(null); const [audioChunks, setAudioChunks] = useState({ @@ -113,7 +113,10 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { setTokenResult({ error: true, errorMessage: - result?.data?.error?.message || result?.data?.message || '' + result?.data?.error?.message || + result?.data?.message || + result.error.detail || + '' }); return; } @@ -172,6 +175,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { async (data: { file: any; fileList: any }) => { const res = await readAudioFile(data.file); setAudioData(res); + setTokenResult(null); }, [] ); @@ -187,6 +191,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { const handleOnRecord = useCallback((val: boolean) => { setIsRecording(val); setAudioData(null); + setTokenResult(null); console.log('data===', val); }, []); @@ -326,24 +331,34 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { >
<> -
- {messageList.length ? ( - messageList[0]?.content - ) : ( - - {intl.formatMessage({ - id: 'playground.audio.generating.tips' - })} - - )} -
+ {!tokenResult && ( +
+ {messageList.length ? ( + messageList[0]?.content + ) : ( + + {intl.formatMessage({ + id: 'playground.audio.generating.tips' + })} + + )} +
+ )} + {tokenResult && ( +
+ +
+ )} {loading && (
diff --git a/src/pages/playground/components/ground-tts.tsx b/src/pages/playground/components/ground-tts.tsx index 3bb0a0ad..c2cb206b 100644 --- a/src/pages/playground/components/ground-tts.tsx +++ b/src/pages/playground/components/ground-tts.tsx @@ -1,3 +1,4 @@ +import AlertInfo from '@/components/alert-info'; import IconFont from '@/components/icon-font'; import SealSelect from '@/components/seal-form/seal-select'; import SpeechContent from '@/components/speech-content'; @@ -25,7 +26,6 @@ import '../style/ground-left.less'; import '../style/system-message-wrap.less'; import DynamicParams from './dynamic-params'; import MessageInput from './message-input'; -import ReferenceParams from './reference-params'; import ViewCodeModal from './view-code-modal'; interface MessageProps { @@ -96,7 +96,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { }; const submitMessage = async (current?: { role: string; content: string }) => { - await formRef.current?.form.validateFields(); + // await formRef.current?.form.validateFields(); if (!parameters.model) return; try { setLoading(true); @@ -120,6 +120,19 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { console.log('result:', res); + if (res.error) { + setTokenResult({ + error: true, + errorMessage: + res?.data?.error?.message || + res?.data?.error || + res.error?.detail || + '' + }); + setMessageList([]); + return; + } + setMessageList([ { input: current?.content || currentPrompt, @@ -132,7 +145,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { } ]); } catch (error) { - // console.log('error:', error); + console.log('error:', error); } finally { setLoading(false); } @@ -280,7 +293,10 @@ const GroundLeft: React.FC = forwardRef((props, ref) => {
{tokenResult && (
- +
)}
@@ -289,6 +305,10 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { checkLabel={intl.formatMessage({ id: 'playground.toolbar.autoplay' })} + defaultSize={{ + minRows: 5, + maxRows: 5 + }} onCheck={handleOnCheckChange} loading={loading} disabled={!parameters.model} diff --git a/src/pages/playground/components/message-input.tsx b/src/pages/playground/components/message-input.tsx index c02fc57b..ca53f9d8 100644 --- a/src/pages/playground/components/message-input.tsx +++ b/src/pages/playground/components/message-input.tsx @@ -473,7 +473,10 @@ const MessageInput: React.FC = forwardRef( {actions.includes('paste') ? (