fix: do not init audio model
This commit is contained in:
@@ -8,6 +8,15 @@ const removeBracketsFromLine = (row: string) => {
|
|||||||
return row.startsWith('(…)') ? row.slice(3) : row;
|
return row.startsWith('(…)') ? row.slice(3) : row;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface MessageProps {
|
||||||
|
inputStr: string;
|
||||||
|
reset?: boolean;
|
||||||
|
page?: number;
|
||||||
|
isComplete?: boolean;
|
||||||
|
chunked?: boolean;
|
||||||
|
progress?: number;
|
||||||
|
percent?: number;
|
||||||
|
}
|
||||||
class AnsiParser {
|
class AnsiParser {
|
||||||
private cursorRow: number = 0;
|
private cursorRow: number = 0;
|
||||||
private cursorCol: number = 0;
|
private cursorCol: number = 0;
|
||||||
@@ -17,6 +26,8 @@ class AnsiParser {
|
|||||||
private isProcessing: boolean = false;
|
private isProcessing: boolean = false;
|
||||||
private taskQueue: string[] = [];
|
private taskQueue: string[] = [];
|
||||||
private page: number = 1;
|
private page: number = 1;
|
||||||
|
private progress: number = 0;
|
||||||
|
private percent: number = 0;
|
||||||
private isComplete: boolean = false;
|
private isComplete: boolean = false;
|
||||||
private chunked: boolean = true; // true: send data in chunks, false: send all data at once
|
private chunked: boolean = true; // true: send data in chunks, false: send all data at once
|
||||||
private pageSize: number = 500;
|
private pageSize: number = 500;
|
||||||
@@ -44,8 +55,16 @@ class AnsiParser {
|
|||||||
this.page = 1;
|
this.page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setPage(page: number) {
|
public setPage(page: number | undefined) {
|
||||||
this.page = page;
|
this.page = page ?? 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setPercent(percent: number | undefined) {
|
||||||
|
this.percent = percent ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setProgress(progress: number | undefined) {
|
||||||
|
this.progress = progress ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setIsCompelete(isComplete: boolean) {
|
public setIsCompelete(isComplete: boolean) {
|
||||||
@@ -179,6 +198,12 @@ class AnsiParser {
|
|||||||
const result = this.processInput(input);
|
const result = this.processInput(input);
|
||||||
if (this.chunked) {
|
if (this.chunked) {
|
||||||
self.postMessage({ result: result.data, lines: result.lines });
|
self.postMessage({ result: result.data, lines: result.lines });
|
||||||
|
} else if (!this.isComplete) {
|
||||||
|
self.postMessage({
|
||||||
|
result: '',
|
||||||
|
percent: this.percent,
|
||||||
|
isComplete: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error processing input:', error);
|
console.error('Error processing input:', error);
|
||||||
@@ -194,7 +219,11 @@ class AnsiParser {
|
|||||||
if (this.taskQueue.length > 0) {
|
if (this.taskQueue.length > 0) {
|
||||||
this.processQueue();
|
this.processQueue();
|
||||||
} else if (this.isComplete && !this.chunked) {
|
} else if (this.isComplete && !this.chunked) {
|
||||||
self.postMessage({ result: this.getScreenText() });
|
self.postMessage({
|
||||||
|
result: this.getScreenText(),
|
||||||
|
percent: this.percent,
|
||||||
|
isComplete: true
|
||||||
|
});
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,18 +237,20 @@ class AnsiParser {
|
|||||||
}
|
}
|
||||||
const parser = new AnsiParser();
|
const parser = new AnsiParser();
|
||||||
|
|
||||||
self.onmessage = function (event) {
|
self.onmessage = function (event: MessageEvent<MessageProps>) {
|
||||||
const {
|
const {
|
||||||
inputStr,
|
inputStr,
|
||||||
reset,
|
reset,
|
||||||
page,
|
page,
|
||||||
isComplete = false,
|
isComplete = false,
|
||||||
chunked = true
|
chunked = true,
|
||||||
|
percent = 0
|
||||||
} = event.data;
|
} = event.data;
|
||||||
|
|
||||||
parser.setPage(page);
|
parser.setPage(page);
|
||||||
parser.setIsCompelete(isComplete);
|
parser.setIsCompelete(isComplete);
|
||||||
parser.setChunked(chunked);
|
parser.setChunked(chunked);
|
||||||
|
parser.setPercent(percent);
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
parser.reset();
|
parser.reset();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
border: none;
|
border: none;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background-color: var(--ant-color-split);
|
background-color: var(--ant-color-split);
|
||||||
|
border-color: var(--ant-color-split);
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
|
|||||||
@@ -907,3 +907,7 @@ body {
|
|||||||
width: 0;
|
width: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-notification .ant-notification-notice-close {
|
||||||
|
width: fit-content !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ const useSetChunkFetch = () => {
|
|||||||
|
|
||||||
let isReading = true;
|
let isReading = true;
|
||||||
|
|
||||||
while (true) {
|
while (isReading) {
|
||||||
const { done, value } = await reader.read();
|
const { done, value } = await reader.read();
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { message } from 'antd';
|
|||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
export default function useDownloadStream() {
|
export default function useDownloadStream() {
|
||||||
const chunkRequedtRef = useRef<any>(null);
|
const chunkRequestRef = useRef<any>(null);
|
||||||
const logParseWorker = useRef<any>(null);
|
const logParseWorker = useRef<any>(null);
|
||||||
const clearScreen = useRef(false);
|
const clearScreen = useRef(false);
|
||||||
const filename = useRef('log');
|
const filename = useRef('log');
|
||||||
@@ -26,19 +26,13 @@ export default function useDownloadStream() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateContent = (data: string, options?: HandlerOptions) => {
|
const updateContent = (data: string, options?: HandlerOptions) => {
|
||||||
const { isComplete } = options || {};
|
const { isComplete, percent } = options || {};
|
||||||
|
|
||||||
downloadNotificationRef.current?.({
|
|
||||||
...options,
|
|
||||||
duration: isComplete ? 1 : null,
|
|
||||||
filename: filename.current
|
|
||||||
});
|
|
||||||
|
|
||||||
logParseWorker.current?.postMessage({
|
logParseWorker.current?.postMessage({
|
||||||
inputStr: data,
|
inputStr: data,
|
||||||
page: 1,
|
|
||||||
reset: clearScreen.current,
|
reset: clearScreen.current,
|
||||||
isComplete: isComplete,
|
isComplete: isComplete,
|
||||||
|
percent: percent,
|
||||||
chunked: false
|
chunked: false
|
||||||
});
|
});
|
||||||
clearScreen.current = false;
|
clearScreen.current = false;
|
||||||
@@ -72,13 +66,9 @@ export default function useDownloadStream() {
|
|||||||
downloadNotificationRef.current = props.downloadNotification;
|
downloadNotificationRef.current = props.downloadNotification;
|
||||||
const { params, url } = props;
|
const { params, url } = props;
|
||||||
|
|
||||||
downloadNotificationRef.current?.({
|
chunkRequestRef.current?.current?.abort?.();
|
||||||
filename: filename.current
|
|
||||||
});
|
|
||||||
|
|
||||||
chunkRequedtRef.current?.current?.abort?.();
|
chunkRequestRef.current = setChunkFetch({
|
||||||
|
|
||||||
chunkRequedtRef.current = setChunkFetch({
|
|
||||||
url,
|
url,
|
||||||
params,
|
params,
|
||||||
watch: false,
|
watch: false,
|
||||||
@@ -86,6 +76,11 @@ export default function useDownloadStream() {
|
|||||||
errorHandler: handleError,
|
errorHandler: handleError,
|
||||||
handler: updateContent
|
handler: updateContent
|
||||||
});
|
});
|
||||||
|
downloadNotificationRef.current?.({
|
||||||
|
filename: filename.current,
|
||||||
|
duration: null,
|
||||||
|
chunkRequestRef: chunkRequestRef.current
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//
|
//
|
||||||
downloadNotificationRef.current?.({
|
downloadNotificationRef.current?.({
|
||||||
@@ -108,8 +103,24 @@ export default function useDownloadStream() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
logParseWorker.current.onmessage = (event: any) => {
|
logParseWorker.current.onmessage = (event: any) => {
|
||||||
const { result } = event.data;
|
const { result, isComplete, percent } = event.data;
|
||||||
|
|
||||||
|
const isAborted = chunkRequestRef.current?.current?.signal?.aborted;
|
||||||
|
if (!isComplete && !isAborted) {
|
||||||
|
downloadNotificationRef.current?.({
|
||||||
|
percent: percent,
|
||||||
|
duration: null,
|
||||||
|
filename: filename.current,
|
||||||
|
chunkRequestRef: chunkRequestRef.current
|
||||||
|
});
|
||||||
|
} else if (isComplete && !isAborted) {
|
||||||
|
downloadNotificationRef.current?.({
|
||||||
|
duration: 1,
|
||||||
|
percent: 100,
|
||||||
|
filename: filename.current
|
||||||
|
});
|
||||||
downloadFile(result);
|
downloadFile(result);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -115,10 +115,11 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
|||||||
modelData,
|
modelData,
|
||||||
handleChildSelect
|
handleChildSelect
|
||||||
}) => {
|
}) => {
|
||||||
const [api, contextHolder] = notification.useNotification();
|
const [api, contextHolder] = notification.useNotification({
|
||||||
|
stack: { threshold: 1 }
|
||||||
|
});
|
||||||
const { downloadStream } = useDownloadStream();
|
const { downloadStream } = useDownloadStream();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const actionItems = useMemo(() => {
|
const actionItems = useMemo(() => {
|
||||||
return _.filter(childActionList, (action: any) => {
|
return _.filter(childActionList, (action: any) => {
|
||||||
if (action.key === 'viewlog' || action.key === 'download') {
|
if (action.key === 'viewlog' || action.key === 'download') {
|
||||||
@@ -135,12 +136,25 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const downloadNotification = useCallback(
|
const downloadNotification = useCallback(
|
||||||
(data: HandlerOptions & { filename: string; duration?: number }) => {
|
(
|
||||||
|
data: HandlerOptions & {
|
||||||
|
filename: string;
|
||||||
|
duration?: number;
|
||||||
|
chunkRequestRef: any;
|
||||||
|
}
|
||||||
|
) => {
|
||||||
api.open({
|
api.open({
|
||||||
duration: data.duration,
|
duration: data.duration,
|
||||||
message: renderMessage(data.filename),
|
message: renderMessage(data.filename),
|
||||||
key: data.filename,
|
key: data.filename,
|
||||||
description: <Progress percent={data.percent} size="small"></Progress>
|
closeIcon: (
|
||||||
|
<span>{intl.formatMessage({ id: 'common.button.cancel' })}</span>
|
||||||
|
),
|
||||||
|
description: <Progress percent={data.percent} size="small"></Progress>,
|
||||||
|
onClose() {
|
||||||
|
data.chunkRequestRef?.current?.abort();
|
||||||
|
notification.destroy?.(data.filename);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
|
|||||||
@@ -198,10 +198,9 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitMessage = async (current?: { role: string; content: string }) => {
|
const submitMessage = async (current?: { role: string; content: string }) => {
|
||||||
|
try {
|
||||||
await formRef.current?.form.validateFields();
|
await formRef.current?.form.validateFields();
|
||||||
if (!parameters.model) return;
|
if (!parameters.model) return;
|
||||||
|
|
||||||
try {
|
|
||||||
const validTextList = textList.filter((item) => item.text);
|
const validTextList = textList.filter((item) => item.text);
|
||||||
const validFileList = fileList.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" />
|
<FileImageOutlined className="font-size-32 text-secondary" />
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
{intl.formatMessage({ id: 'playground.params.empty.tips' })}
|
{intl.formatMessage({
|
||||||
|
id: 'playground.params.empty.tips'
|
||||||
|
})}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -308,7 +310,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
size="middle"
|
size="small"
|
||||||
type="text"
|
type="text"
|
||||||
icon={<SwapOutlined />}
|
icon={<SwapOutlined />}
|
||||||
onClick={handleToggleParamsStyle}
|
onClick={handleToggleParamsStyle}
|
||||||
|
|||||||
@@ -218,9 +218,9 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitMessage = async () => {
|
const submitMessage = async () => {
|
||||||
|
try {
|
||||||
await formRef.current?.form.validateFields();
|
await formRef.current?.form.validateFields();
|
||||||
if (!parameters.model) return;
|
if (!parameters.model) return;
|
||||||
try {
|
|
||||||
const documentList: any[] = [...textList, ...fileList];
|
const documentList: any[] = [...textList, ...fileList];
|
||||||
|
|
||||||
const validDocus = documentList.filter((item) => item.text);
|
const validDocus = documentList.filter((item) => item.text);
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ interface MessageProps {
|
|||||||
ref?: any;
|
ref?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValues = {
|
|
||||||
language: 'auto'
|
|
||||||
};
|
|
||||||
|
|
||||||
const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { modelList } = props;
|
const { modelList } = props;
|
||||||
@@ -57,8 +53,9 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const selectModel = searchParams.get('model')
|
const selectModel = searchParams.get('model')
|
||||||
? modelType === 'stt' && searchParams.get('model')
|
? modelType === 'stt' && searchParams.get('model')
|
||||||
: '';
|
: '';
|
||||||
|
const defaultModel = selectModel || modelList[0]?.value || '';
|
||||||
const [parameters, setParams] = useState<any>({
|
const [parameters, setParams] = useState<any>({
|
||||||
model: selectModel,
|
model: defaultModel,
|
||||||
language: 'auto'
|
language: 'auto'
|
||||||
});
|
});
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
@@ -112,9 +109,9 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitMessage = async () => {
|
const submitMessage = async () => {
|
||||||
|
try {
|
||||||
await formRef.current?.form.validateFields();
|
await formRef.current?.form.validateFields();
|
||||||
if (!parameters.model) return;
|
if (!parameters.model) return;
|
||||||
try {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMessageId();
|
setMessageId();
|
||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
@@ -181,9 +178,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleClear = () => {
|
const handleClear = () => {
|
||||||
if (!messageList.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setMessageId();
|
setMessageId();
|
||||||
setMessageList([]);
|
setMessageList([]);
|
||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
@@ -243,6 +237,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleOnGenerate = async () => {
|
const handleOnGenerate = async () => {
|
||||||
|
if (loading) {
|
||||||
|
handleStopConversation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
submitMessage();
|
submitMessage();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -340,7 +338,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
title={
|
title={
|
||||||
loading
|
loading
|
||||||
? intl.formatMessage({
|
? intl.formatMessage({
|
||||||
id: 'playground.audio.generating'
|
id: 'common.button.stop'
|
||||||
})
|
})
|
||||||
: intl.formatMessage({
|
: intl.formatMessage({
|
||||||
id: 'playground.audio.button.generate'
|
id: 'playground.audio.button.generate'
|
||||||
@@ -350,12 +348,20 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
{
|
{
|
||||||
<Button
|
<Button
|
||||||
disabled={!audioData}
|
disabled={!audioData}
|
||||||
loading={loading}
|
|
||||||
type="primary"
|
type="primary"
|
||||||
size="middle"
|
size="middle"
|
||||||
shape="circle"
|
shape="circle"
|
||||||
onClick={handleOnGenerate}
|
onClick={handleOnGenerate}
|
||||||
icon={<SendOutlined></SendOutlined>}
|
icon={
|
||||||
|
loading ? (
|
||||||
|
<IconFont
|
||||||
|
type="icon-stop1"
|
||||||
|
className="font-size-14"
|
||||||
|
></IconFont>
|
||||||
|
) : (
|
||||||
|
<SendOutlined></SendOutlined>
|
||||||
|
)
|
||||||
|
}
|
||||||
></Button>
|
></Button>
|
||||||
}
|
}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const defaultModel = useMemo(() => {
|
||||||
|
return selectModel || modelList[0]?.value || '';
|
||||||
|
}, [modelList]);
|
||||||
|
|
||||||
const viewCodeContent = useMemo(() => {
|
const viewCodeContent = useMemo(() => {
|
||||||
return TextToSpeechCode({
|
return TextToSpeechCode({
|
||||||
api: AUDIO_TEXT_TO_SPEECH_API,
|
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 }) => {
|
const submitMessage = async (current?: { role: string; content: string }) => {
|
||||||
|
try {
|
||||||
await formRef.current?.form.validateFields();
|
await formRef.current?.form.validateFields();
|
||||||
if (!parameters.model) return;
|
if (!parameters.model) return;
|
||||||
try {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMessageId();
|
setMessageId();
|
||||||
setTokenResult(null);
|
setTokenResult(null);
|
||||||
@@ -235,14 +239,6 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
const handleSelectModel = useCallback(
|
const handleSelectModel = useCallback(
|
||||||
async (value: string) => {
|
async (value: string) => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
setVoiceList([]);
|
|
||||||
setParams((pre: any) => {
|
|
||||||
return {
|
|
||||||
...pre,
|
|
||||||
voice: ''
|
|
||||||
};
|
|
||||||
});
|
|
||||||
formRef.current?.form.setFieldValue('voice', '');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const model = modelList.find((item) => item.value === value);
|
const model = modelList.find((item) => item.value === value);
|
||||||
@@ -259,10 +255,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
setParams((pre: any) => {
|
setParams((pre: any) => {
|
||||||
return {
|
return {
|
||||||
...pre,
|
...pre,
|
||||||
|
model: value,
|
||||||
voice: newList[0]?.value
|
voice: newList[0]?.value
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
formRef.current?.form.setFieldValue('voice', newList[0]?.value);
|
|
||||||
},
|
},
|
||||||
[modelList]
|
[modelList]
|
||||||
);
|
);
|
||||||
@@ -307,11 +303,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
}, [paramsConfig, intl, voiceList]);
|
}, [paramsConfig, intl, voiceList]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!parameters.model && modelList.length) {
|
if (defaultModel) {
|
||||||
const model = modelList[0]?.value;
|
handleSelectModel(defaultModel);
|
||||||
handleSelectModel(model);
|
|
||||||
}
|
}
|
||||||
}, [modelList, parameters.model, handleSelectModel]);
|
}, [defaultModel]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (scroller.current) {
|
if (scroller.current) {
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
size="middle"
|
size="small"
|
||||||
type="text"
|
type="text"
|
||||||
icon={<SwapOutlined />}
|
icon={<SwapOutlined />}
|
||||||
onClick={handleToggleParamsStyle}
|
onClick={handleToggleParamsStyle}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export const useInitImageMeta = (props: MessageProps) => {
|
|||||||
const { modelList } = props;
|
const { modelList } = props;
|
||||||
const form = useRef<any>(null);
|
const form = useRef<any>(null);
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const selectModel = searchParams.get('model') || '';
|
const defaultModel = searchParams.get('model') || modelList?.[0]?.value || '';
|
||||||
const [modelMeta, setModelMeta] = useState<any>({});
|
const [modelMeta, setModelMeta] = useState<any>({});
|
||||||
const [isOpenaiCompatible, setIsOpenaiCompatible] = useState<boolean>(false);
|
const [isOpenaiCompatible, setIsOpenaiCompatible] = useState<boolean>(false);
|
||||||
const [imageSizeOptions, setImageSizeOptions] = React.useState<
|
const [imageSizeOptions, setImageSizeOptions] = React.useState<
|
||||||
@@ -175,7 +175,7 @@ export const useInitImageMeta = (props: MessageProps) => {
|
|||||||
const [initialValues, setInitialValues] = useState<any>({
|
const [initialValues, setInitialValues] = useState<any>({
|
||||||
...imgInitialValues,
|
...imgInitialValues,
|
||||||
...advancedFieldsDefaultValus,
|
...advancedFieldsDefaultValus,
|
||||||
model: selectModel
|
model: defaultModel
|
||||||
});
|
});
|
||||||
const [paramsConfig, setParamsConfig] = useState<ParamsSchema[]>([
|
const [paramsConfig, setParamsConfig] = useState<ParamsSchema[]>([
|
||||||
...ImageCountConfig,
|
...ImageCountConfig,
|
||||||
@@ -186,7 +186,7 @@ export const useInitImageMeta = (props: MessageProps) => {
|
|||||||
const [parameters, setParams] = useState<any>({
|
const [parameters, setParams] = useState<any>({
|
||||||
...imgInitialValues,
|
...imgInitialValues,
|
||||||
...advancedFieldsDefaultValus,
|
...advancedFieldsDefaultValus,
|
||||||
model: selectModel
|
model: defaultModel
|
||||||
});
|
});
|
||||||
|
|
||||||
const cacheFormData = React.useRef<Record<string, any>>({
|
const cacheFormData = React.useRef<Record<string, any>>({
|
||||||
@@ -410,11 +410,10 @@ export const useInitImageMeta = (props: MessageProps) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!parameters.model && modelList.length) {
|
if (defaultModel) {
|
||||||
const model = modelList[0]?.value;
|
handleOnModelChange(defaultModel);
|
||||||
handleOnModelChange(model);
|
|
||||||
}
|
}
|
||||||
}, [modelList, parameters.model, handleOnModelChange]);
|
}, [defaultModel, handleOnModelChange]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
extractIMGMeta,
|
extractIMGMeta,
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ const Playground: React.FC = () => {
|
|||||||
with_meta: true
|
with_meta: true
|
||||||
};
|
};
|
||||||
const res = await queryModelsList(params);
|
const res = await queryModelsList(params);
|
||||||
|
|
||||||
const list = _.map(res.data || [], (item: any) => {
|
const list = _.map(res.data || [], (item: any) => {
|
||||||
return {
|
return {
|
||||||
value: item.id,
|
value: item.id,
|
||||||
@@ -127,6 +128,7 @@ const Playground: React.FC = () => {
|
|||||||
with_meta: true
|
with_meta: true
|
||||||
};
|
};
|
||||||
const res = await queryModelsList(params);
|
const res = await queryModelsList(params);
|
||||||
|
|
||||||
const list = _.map(res.data || [], (item: any) => {
|
const list = _.map(res.data || [], (item: any) => {
|
||||||
return {
|
return {
|
||||||
value: item.id,
|
value: item.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user