fix: expand rows in models after operating
This commit is contained in:
@@ -44,8 +44,6 @@ const TableRow: React.FC<
|
|||||||
allSubChildren?: any[];
|
allSubChildren?: any[];
|
||||||
}>(TableContext);
|
}>(TableContext);
|
||||||
const { setChunkRequest } = useSetChunkRequest();
|
const { setChunkRequest } = useSetChunkRequest();
|
||||||
const [expanded, setExpanded] = useState(false);
|
|
||||||
// const [checked, setChecked] = useState(false);
|
|
||||||
const [childrenData, setChildrenData] = useState<any[]>([]);
|
const [childrenData, setChildrenData] = useState<any[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [firstLoad, setFirstLoad] = useState(true);
|
const [firstLoad, setFirstLoad] = useState(true);
|
||||||
@@ -73,6 +71,10 @@ const TableRow: React.FC<
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const expanded = useMemo(() => {
|
||||||
|
return expandedRowKeys?.includes(record[rowKey]);
|
||||||
|
}, [expandedRowKeys]);
|
||||||
|
|
||||||
const checked = useMemo(() => {
|
const checked = useMemo(() => {
|
||||||
return rowSelection?.selectedRowKeys?.includes(record[rowKey]);
|
return rowSelection?.selectedRowKeys?.includes(record[rowKey]);
|
||||||
}, [rowSelection?.selectedRowKeys, record, rowKey]);
|
}, [rowSelection?.selectedRowKeys, record, rowKey]);
|
||||||
@@ -160,7 +162,6 @@ const TableRow: React.FC<
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRowExpand = async () => {
|
const handleRowExpand = async () => {
|
||||||
setExpanded(!expanded);
|
|
||||||
onExpand?.(!expanded, record, record[rowKey]);
|
onExpand?.(!expanded, record, record[rowKey]);
|
||||||
|
|
||||||
if (pollTimer.current) {
|
if (pollTimer.current) {
|
||||||
@@ -200,14 +201,6 @@ const TableRow: React.FC<
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (expandedRowKeys?.includes(record[rowKey])) {
|
|
||||||
setExpanded(true);
|
|
||||||
} else {
|
|
||||||
setExpanded(false);
|
|
||||||
}
|
|
||||||
}, [expandedRowKeys]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleVisibilityChange = async () => {
|
const handleVisibilityChange = async () => {
|
||||||
if (document.visibilityState === 'hidden') {
|
if (document.visibilityState === 'hidden') {
|
||||||
|
|||||||
+107
-56
@@ -206,7 +206,11 @@ export default (props: any) => {
|
|||||||
updateCheck.latest_version?.indexOf('0.0.0') === -1 &&
|
updateCheck.latest_version?.indexOf('0.0.0') === -1 &&
|
||||||
updateCheck.latest_version?.indexOf('rc') === -1
|
updateCheck.latest_version?.indexOf('rc') === -1
|
||||||
);
|
);
|
||||||
}, [updateCheck, version, initialState]);
|
}, [
|
||||||
|
updateCheck.latest_version,
|
||||||
|
version.version,
|
||||||
|
initialState?.currentUser?.is_admin
|
||||||
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const body = document.querySelector('body');
|
const body = document.querySelector('body');
|
||||||
@@ -279,9 +283,107 @@ export default (props: any) => {
|
|||||||
|
|
||||||
return dom;
|
return dom;
|
||||||
},
|
},
|
||||||
[intl, version, updateCheck]
|
[intl, showUpgrade]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const itemRender = useCallback((route, _, routes) => {
|
||||||
|
const { breadcrumbName, title, path } = route;
|
||||||
|
const label = title || breadcrumbName;
|
||||||
|
const last = routes[routes.length - 1];
|
||||||
|
if (last) {
|
||||||
|
if (last.path === path || last.linkPath === path) {
|
||||||
|
return <span>{label}</span>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return <Link to={path}>{label}</Link>;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const menuItemRender = useCallback(
|
||||||
|
(menuItemProps, defaultDom) => {
|
||||||
|
if (menuItemProps.isUrl || menuItemProps.children) {
|
||||||
|
return defaultDom;
|
||||||
|
}
|
||||||
|
if (menuItemProps.path && location.pathname !== menuItemProps.path) {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
to={menuItemProps.path.replace('/*', '')}
|
||||||
|
target={menuItemProps.target}
|
||||||
|
>
|
||||||
|
{defaultDom}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <>{defaultDom}</>;
|
||||||
|
},
|
||||||
|
[location.pathname]
|
||||||
|
);
|
||||||
|
|
||||||
|
const onPageChange = useCallback(
|
||||||
|
(route) => {
|
||||||
|
const { location } = history;
|
||||||
|
const { pathname } = location;
|
||||||
|
|
||||||
|
initRouteCacheValue(pathname);
|
||||||
|
dropRouteCache(pathname);
|
||||||
|
|
||||||
|
// if user is not change password, redirect to change password page
|
||||||
|
if (
|
||||||
|
location.pathname !== loginPath &&
|
||||||
|
userInfo?.require_password_change
|
||||||
|
) {
|
||||||
|
history.push(loginPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if user is not logged in, redirect to login page
|
||||||
|
if (!initialState?.currentUser && location.pathname !== loginPath) {
|
||||||
|
history.push(loginPath);
|
||||||
|
} else if (location.pathname === '/') {
|
||||||
|
const pathname = initialState?.currentUser?.is_admin
|
||||||
|
? '/dashboard'
|
||||||
|
: '/playground';
|
||||||
|
history.push(pathname);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[userInfo?.require_password_change, initialState?.currentUser]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// 先清除旧的性能标记
|
||||||
|
performance.clearMarks();
|
||||||
|
performance.clearMeasures();
|
||||||
|
|
||||||
|
// 记录开始时间
|
||||||
|
performance.mark('route-start');
|
||||||
|
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
// 记录结束时间
|
||||||
|
performance.mark('route-end');
|
||||||
|
|
||||||
|
// 确保 `route-start` 存在后再测量
|
||||||
|
if (performance.getEntriesByName('route-start').length > 0) {
|
||||||
|
performance.measure('route-change', 'route-start', 'route-end');
|
||||||
|
|
||||||
|
const measure = performance.getEntriesByName('route-change')[0];
|
||||||
|
console.log(
|
||||||
|
`[Performance] Route change to ${location.pathname} took ${measure.duration.toFixed(2)}ms`
|
||||||
|
);
|
||||||
|
|
||||||
|
// 清理标记
|
||||||
|
performance.clearMarks();
|
||||||
|
performance.clearMeasures();
|
||||||
|
} else {
|
||||||
|
console.warn('Missing performance mark: route-start');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [location.pathname]);
|
||||||
|
|
||||||
|
const onRenderCallback = (id, phase, actualDuration) => {
|
||||||
|
console.log(
|
||||||
|
`[Profiler] Route: ${id} - Phase: ${phase} - Render time: ${actualDuration.toFixed(2)}ms`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="background"></div>
|
<div className="background"></div>
|
||||||
@@ -311,65 +413,14 @@ export default (props: any) => {
|
|||||||
}}
|
}}
|
||||||
menuHeaderRender={renderMenuHeader}
|
menuHeaderRender={renderMenuHeader}
|
||||||
collapsed={collapsed}
|
collapsed={collapsed}
|
||||||
onPageChange={(route) => {
|
onPageChange={onPageChange}
|
||||||
const { location } = history;
|
|
||||||
const { pathname } = location;
|
|
||||||
|
|
||||||
initRouteCacheValue(pathname);
|
|
||||||
dropRouteCache(pathname);
|
|
||||||
|
|
||||||
// if user is not change password, redirect to change password page
|
|
||||||
if (
|
|
||||||
location.pathname !== loginPath &&
|
|
||||||
userInfo?.require_password_change
|
|
||||||
) {
|
|
||||||
history.push(loginPath);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if user is not logged in, redirect to login page
|
|
||||||
if (!initialState?.currentUser && location.pathname !== loginPath) {
|
|
||||||
history.push(loginPath);
|
|
||||||
} else if (location.pathname === '/') {
|
|
||||||
const pathname = initialState?.currentUser?.is_admin
|
|
||||||
? '/dashboard'
|
|
||||||
: '/playground';
|
|
||||||
history.push(pathname);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
formatMessage={formatMessage}
|
formatMessage={formatMessage}
|
||||||
menu={{
|
menu={{
|
||||||
locale: true
|
locale: true
|
||||||
}}
|
}}
|
||||||
logo={collapsed ? SLogoIcon : LogoIcon}
|
logo={collapsed ? SLogoIcon : LogoIcon}
|
||||||
menuItemRender={(menuItemProps, defaultDom) => {
|
menuItemRender={menuItemRender}
|
||||||
if (menuItemProps.isUrl || menuItemProps.children) {
|
itemRender={itemRender}
|
||||||
return defaultDom;
|
|
||||||
}
|
|
||||||
if (menuItemProps.path && location.pathname !== menuItemProps.path) {
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
to={menuItemProps.path.replace('/*', '')}
|
|
||||||
target={menuItemProps.target}
|
|
||||||
>
|
|
||||||
{defaultDom}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <>{defaultDom}</>;
|
|
||||||
}}
|
|
||||||
itemRender={(route, _, routes) => {
|
|
||||||
const { breadcrumbName, title, path } = route;
|
|
||||||
const label = title || breadcrumbName;
|
|
||||||
const last = routes[routes.length - 1];
|
|
||||||
if (last) {
|
|
||||||
if (last.path === path || last.linkPath === path) {
|
|
||||||
return <span>{label}</span>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return <Link to={path}>{label}</Link>;
|
|
||||||
}}
|
|
||||||
disableContentMargin
|
disableContentMargin
|
||||||
fixSiderbar
|
fixSiderbar
|
||||||
fixedHeader
|
fixedHeader
|
||||||
|
|||||||
@@ -600,7 +600,6 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
|
|
||||||
const handleEdit = async (row: ListItem) => {
|
const handleEdit = async (row: ListItem) => {
|
||||||
const initialValues = generateFormValues(row, gpuDeviceList.current);
|
const initialValues = generateFormValues(row, gpuDeviceList.current);
|
||||||
console.log('initialValues:', initialValues, row);
|
|
||||||
setUpdateFormInitials({
|
setUpdateFormInitials({
|
||||||
gpuOptions: gpuDeviceList.current,
|
gpuOptions: gpuDeviceList.current,
|
||||||
data: initialValues,
|
data: initialValues,
|
||||||
@@ -818,7 +817,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}, [sortOrder, intl]);
|
}, [sortOrder, intl, handleSelect]);
|
||||||
|
|
||||||
const handleOnClick = async () => {
|
const handleOnClick = async () => {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import 'overlayscrollbars/overlayscrollbars.css';
|
|||||||
import { Resizable } from 're-resizable';
|
import { Resizable } from 're-resizable';
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
@@ -728,4 +727,4 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default memo(GroundEmbedding);
|
export default GroundEmbedding;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import _ from 'lodash';
|
|||||||
import 'overlayscrollbars/overlayscrollbars.css';
|
import 'overlayscrollbars/overlayscrollbars.css';
|
||||||
import React, {
|
import React, {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
|
||||||
useCallback,
|
useCallback,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
useMemo,
|
useMemo,
|
||||||
@@ -183,8 +182,8 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
form.current?.form?.setFieldValue('seed', params.seed);
|
form.current?.form?.setFieldValue('seed', params.seed);
|
||||||
console.log('params:', params, parameters);
|
console.log('params:', params, parameters);
|
||||||
submitMessage(params);
|
|
||||||
setRouteCache(routeCachekey['/playground/text-to-image'], true);
|
setRouteCache(routeCachekey['/playground/text-to-image'], true);
|
||||||
|
await submitMessage(params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.log('error:', error);
|
// console.log('error:', error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -193,9 +192,9 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloseViewCode = () => {
|
const handleCloseViewCode = useCallback(() => {
|
||||||
setShow(false);
|
setShow(false);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ground-left-wrapper">
|
<div className="ground-left-wrapper">
|
||||||
@@ -343,4 +342,4 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default memo(GroundImages);
|
export default GroundImages;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import classNames from 'classnames';
|
|||||||
import 'overlayscrollbars/overlayscrollbars.css';
|
import 'overlayscrollbars/overlayscrollbars.css';
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
useMemo,
|
useMemo,
|
||||||
@@ -211,4 +210,4 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default memo(GroundLeft);
|
export default GroundLeft;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import _ from 'lodash';
|
|||||||
import 'overlayscrollbars/overlayscrollbars.css';
|
import 'overlayscrollbars/overlayscrollbars.css';
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
@@ -610,4 +609,4 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default memo(GroundReranker);
|
export default GroundReranker;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import classNames from 'classnames';
|
|||||||
import 'overlayscrollbars/overlayscrollbars.css';
|
import 'overlayscrollbars/overlayscrollbars.css';
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
@@ -37,11 +36,10 @@ import ViewCommonCode from './view-common-code';
|
|||||||
|
|
||||||
interface MessageProps {
|
interface MessageProps {
|
||||||
modelList: Global.BaseOption<string>[];
|
modelList: Global.BaseOption<string>[];
|
||||||
loaded?: boolean;
|
|
||||||
ref?: any;
|
ref?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
const GroundSTT: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { modelList } = props;
|
const { modelList } = props;
|
||||||
const messageId = useRef<number>(0);
|
const messageId = useRef<number>(0);
|
||||||
@@ -474,4 +472,4 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default memo(GroundLeft);
|
export default GroundSTT;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import _ from 'lodash';
|
|||||||
import 'overlayscrollbars/overlayscrollbars.css';
|
import 'overlayscrollbars/overlayscrollbars.css';
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
@@ -37,7 +36,7 @@ interface MessageProps {
|
|||||||
ref?: any;
|
ref?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
const GroundTTS: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||||
const { modelList } = props;
|
const { modelList } = props;
|
||||||
const messageId = useRef<number>(0);
|
const messageId = useRef<number>(0);
|
||||||
const [messageList, setMessageList] = useState<
|
const [messageList, setMessageList] = useState<
|
||||||
@@ -423,4 +422,4 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default memo(GroundLeft);
|
export default GroundTTS;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import _ from 'lodash';
|
|||||||
import 'overlayscrollbars/overlayscrollbars.css';
|
import 'overlayscrollbars/overlayscrollbars.css';
|
||||||
import React, {
|
import React, {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
@@ -210,8 +209,8 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
form.current?.form?.setFieldValue('seed', params.seed);
|
form.current?.form?.setFieldValue('seed', params.seed);
|
||||||
console.log('params:', params, parameters);
|
console.log('params:', params, parameters);
|
||||||
submitMessage(params);
|
|
||||||
setRouteCache(routeCachekey['/playground/text-to-image'], true);
|
setRouteCache(routeCachekey['/playground/text-to-image'], true);
|
||||||
|
await submitMessage(params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.log('error:', error);
|
// console.log('error:', error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -566,4 +565,4 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default memo(GroundImages);
|
export default GroundImages;
|
||||||
|
|||||||
@@ -118,19 +118,19 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
|
|||||||
defaultMaxTokens = obj.max_model_len / 2;
|
defaultMaxTokens = obj.max_model_len / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
form.setFieldsValue({
|
const initials = {
|
||||||
..._.omit(obj, ['n_ctx', 'n_slot', 'max_model_len']),
|
..._.omit(obj, ['n_ctx', 'n_slot', 'max_model_len']),
|
||||||
|
seed: obj.seed === -1 ? null : obj.seed,
|
||||||
max_tokens: defaultMaxTokens
|
max_tokens: defaultMaxTokens
|
||||||
});
|
};
|
||||||
|
|
||||||
|
form.setFieldsValue(initials);
|
||||||
|
|
||||||
setMetaData({
|
setMetaData({
|
||||||
...obj,
|
...obj,
|
||||||
max_tokens: obj.max_model_len || _.divide(obj.n_ctx, obj.n_slot)
|
max_tokens: obj.max_model_len || _.divide(obj.n_ctx, obj.n_slot)
|
||||||
});
|
});
|
||||||
return {
|
return initials;
|
||||||
..._.omit(obj, ['n_ctx', 'n_slot', 'max_model_len']),
|
|
||||||
max_tokens: defaultMaxTokens
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ export const IMG_METAKEYS = [
|
|||||||
'schedule_method',
|
'schedule_method',
|
||||||
'cfg_scale',
|
'cfg_scale',
|
||||||
'guidance',
|
'guidance',
|
||||||
'negative_prompt'
|
'negative_prompt',
|
||||||
|
'seed'
|
||||||
];
|
];
|
||||||
|
|
||||||
export const llmInitialValues = {
|
export const llmInitialValues = {
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ export const useInitLLmMeta = (
|
|||||||
} = options;
|
} = options;
|
||||||
const formRef = useRef<any>(null);
|
const formRef = 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 [initialValues, setInitialValues] = useState<any>({
|
const [initialValues, setInitialValues] = useState<any>({
|
||||||
...defaultValues,
|
...defaultValues,
|
||||||
model: selectModel
|
model: defaultModel
|
||||||
});
|
});
|
||||||
const [parameters, setParams] = useState<any>({
|
const [parameters, setParams] = useState<any>({
|
||||||
model: selectModel
|
model: defaultModel
|
||||||
});
|
});
|
||||||
const [paramsConfig, setParamsConfig] =
|
const [paramsConfig, setParamsConfig] =
|
||||||
useState<ParamsSchema[]>(defaultParamsConfig);
|
useState<ParamsSchema[]>(defaultParamsConfig);
|
||||||
@@ -88,6 +88,7 @@ export const useInitLLmMeta = (
|
|||||||
return {
|
return {
|
||||||
form: _.merge({}, defaultValues, {
|
form: _.merge({}, defaultValues, {
|
||||||
..._.omit(obj, ['n_ctx', 'n_slot', 'max_model_len']),
|
..._.omit(obj, ['n_ctx', 'n_slot', 'max_model_len']),
|
||||||
|
seed: obj.seed === -1 ? null : obj.seed,
|
||||||
max_tokens: defaultMaxTokens
|
max_tokens: defaultMaxTokens
|
||||||
}),
|
}),
|
||||||
meta: {
|
meta: {
|
||||||
@@ -128,11 +129,10 @@ export const useInitLLmMeta = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!parameters.model && modelList.length) {
|
if (defaultModel) {
|
||||||
const model = modelList[0]?.value;
|
handleOnModelChange(defaultModel);
|
||||||
handleOnModelChange(model);
|
|
||||||
}
|
}
|
||||||
}, [modelList, parameters.model, handleOnModelChange]);
|
}, [defaultModel, handleOnModelChange]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (paramsRef.current) {
|
if (paramsRef.current) {
|
||||||
@@ -263,6 +263,7 @@ export const useInitImageMeta = (props: MessageProps) => {
|
|||||||
{ ...imgInitialValues, ...advancedFieldsDefaultValus },
|
{ ...imgInitialValues, ...advancedFieldsDefaultValus },
|
||||||
{
|
{
|
||||||
..._.pick(meta, IMG_METAKEYS),
|
..._.pick(meta, IMG_METAKEYS),
|
||||||
|
seed: meta?.seed === -1 ? null : meta?.seed,
|
||||||
size: sizeOptions.length
|
size: sizeOptions.length
|
||||||
? `${meta?.default_width || 512}x${meta?.default_height || 512}`
|
? `${meta?.default_width || 512}x${meta?.default_height || 512}`
|
||||||
: 'custom',
|
: 'custom',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { useIntl } from '@umijs/max';
|
|||||||
import { Button, Segmented, Space, Tabs, TabsProps } from 'antd';
|
import { Button, Segmented, Space, Tabs, TabsProps } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { queryModelsList } from './apis';
|
import { queryModelsList } from './apis';
|
||||||
import GroundImages from './components/ground-images';
|
import GroundImages from './components/ground-images';
|
||||||
@@ -28,20 +28,21 @@ const TextToImages: React.FC = () => {
|
|||||||
const groundTabRef1 = useRef<any>(null);
|
const groundTabRef1 = useRef<any>(null);
|
||||||
const groundTabRef2 = useRef<any>(null);
|
const groundTabRef2 = useRef<any>(null);
|
||||||
const [modelList, setModelList] = useState<Global.BaseOption<string>[]>([]);
|
const [modelList, setModelList] = useState<Global.BaseOption<string>[]>([]);
|
||||||
const [loaded, setLoaded] = useState(false);
|
|
||||||
|
|
||||||
const optionsList = [
|
const optionsList = useMemo(() => {
|
||||||
{
|
return [
|
||||||
label: intl.formatMessage({ id: 'playground.image.generate' }),
|
{
|
||||||
value: TabsValueMap.Tab1,
|
label: intl.formatMessage({ id: 'playground.image.generate' }),
|
||||||
icon: <DiffOutlined />
|
value: TabsValueMap.Tab1,
|
||||||
},
|
icon: <DiffOutlined />
|
||||||
{
|
},
|
||||||
label: intl.formatMessage({ id: 'playground.image.edit' }),
|
{
|
||||||
value: TabsValueMap.Tab2,
|
label: intl.formatMessage({ id: 'playground.image.edit' }),
|
||||||
icon: <HighlightOutlined />
|
value: TabsValueMap.Tab2,
|
||||||
}
|
icon: <HighlightOutlined />
|
||||||
];
|
}
|
||||||
|
];
|
||||||
|
}, [intl]);
|
||||||
|
|
||||||
const handleViewCode = useCallback(() => {
|
const handleViewCode = useCallback(() => {
|
||||||
if (activeKey === TabsValueMap.Tab1) {
|
if (activeKey === TabsValueMap.Tab1) {
|
||||||
@@ -59,26 +60,29 @@ const TextToImages: React.FC = () => {
|
|||||||
groundTabRef2.current?.setCollapse?.();
|
groundTabRef2.current?.setCollapse?.();
|
||||||
}, [activeKey]);
|
}, [activeKey]);
|
||||||
|
|
||||||
const items: TabsProps['items'] = [
|
const items: TabsProps['items'] = useMemo(() => {
|
||||||
{
|
return [
|
||||||
key: TabsValueMap.Tab1,
|
{
|
||||||
label: 'Generate',
|
key: TabsValueMap.Tab1,
|
||||||
children: (
|
label: 'Generate',
|
||||||
<GroundImages ref={groundTabRef1} modelList={modelList}></GroundImages>
|
children: (
|
||||||
)
|
<GroundImages
|
||||||
},
|
ref={groundTabRef1}
|
||||||
{
|
modelList={modelList}
|
||||||
key: TabsValueMap.Tab2,
|
></GroundImages>
|
||||||
label: 'Edit',
|
)
|
||||||
children: <ImageEdit modelList={modelList} ref={groundTabRef2} />
|
},
|
||||||
}
|
{
|
||||||
];
|
key: TabsValueMap.Tab2,
|
||||||
|
label: 'Edit',
|
||||||
|
children: <ImageEdit modelList={modelList} ref={groundTabRef2} />
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}, [modelList]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (size.width < breakpoints.lg) {
|
if (size.width < breakpoints.lg && !groundTabRef1.current?.collapse) {
|
||||||
if (!groundTabRef1.current?.collapse) {
|
groundTabRef1.current?.setCollapse?.();
|
||||||
groundTabRef1.current?.setCollapse?.();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [size.width]);
|
}, [size.width]);
|
||||||
|
|
||||||
@@ -109,13 +113,13 @@ const TextToImages: React.FC = () => {
|
|||||||
const modelist = await getModelList();
|
const modelist = await getModelList();
|
||||||
setModelList(modelist);
|
setModelList(modelist);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoaded(true);
|
// error
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const renderExtra = () => {
|
const renderExtra = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
<Space key="buttons">
|
<Space key="buttons">
|
||||||
<Button
|
<Button
|
||||||
@@ -137,7 +141,31 @@ const TextToImages: React.FC = () => {
|
|||||||
></Button>
|
></Button>
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
};
|
}, [intl, handleViewCode, handleToggleCollapse]);
|
||||||
|
|
||||||
|
const header = useMemo(() => {
|
||||||
|
return {
|
||||||
|
title: (
|
||||||
|
<div className="flex items-center">
|
||||||
|
<span className="font-600">
|
||||||
|
{intl.formatMessage({ id: 'menu.playground.text2images' })}
|
||||||
|
</span>
|
||||||
|
{
|
||||||
|
<Segmented
|
||||||
|
options={optionsList}
|
||||||
|
size="middle"
|
||||||
|
className="m-l-40"
|
||||||
|
onChange={(key) => setActiveKey(key)}
|
||||||
|
></Segmented>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
style: {
|
||||||
|
paddingInline: 'var(--layout-content-header-inlinepadding)'
|
||||||
|
},
|
||||||
|
breadcrumb: {}
|
||||||
|
};
|
||||||
|
}, [optionsList]);
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
HotKeys.RIGHT.join(','),
|
HotKeys.RIGHT.join(','),
|
||||||
@@ -152,28 +180,8 @@ const TextToImages: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<PageContainer
|
<PageContainer
|
||||||
ghost
|
ghost
|
||||||
header={{
|
header={header}
|
||||||
title: (
|
extra={renderExtra}
|
||||||
<div className="flex items-center">
|
|
||||||
<span className="font-600">
|
|
||||||
{intl.formatMessage({ id: 'menu.playground.text2images' })}
|
|
||||||
</span>
|
|
||||||
{
|
|
||||||
<Segmented
|
|
||||||
options={optionsList}
|
|
||||||
size="middle"
|
|
||||||
className="m-l-40"
|
|
||||||
onChange={(key) => setActiveKey(key)}
|
|
||||||
></Segmented>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
style: {
|
|
||||||
paddingInline: 'var(--layout-content-header-inlinepadding)'
|
|
||||||
},
|
|
||||||
breadcrumb: {}
|
|
||||||
}}
|
|
||||||
extra={renderExtra()}
|
|
||||||
className={classNames('playground-container chat')}
|
className={classNames('playground-container chat')}
|
||||||
>
|
>
|
||||||
<div className="play-ground">
|
<div className="play-ground">
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { useIntl } from '@umijs/max';
|
|||||||
import { Button, Segmented, Space, Tabs, TabsProps } from 'antd';
|
import { Button, Segmented, Space, Tabs, TabsProps } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { queryModelsList } from './apis';
|
import { queryModelsList } from './apis';
|
||||||
import GroundLeft from './components/ground-left';
|
import GroundLeft from './components/ground-left';
|
||||||
@@ -24,18 +24,21 @@ const Playground: React.FC = () => {
|
|||||||
const groundRerankerRef = useRef<any>(null);
|
const groundRerankerRef = useRef<any>(null);
|
||||||
const [modelList, setModelList] = useState<Global.BaseOption<string>[]>([]);
|
const [modelList, setModelList] = useState<Global.BaseOption<string>[]>([]);
|
||||||
const [loaded, setLoaded] = useState(false);
|
const [loaded, setLoaded] = useState(false);
|
||||||
const optionsList = [
|
|
||||||
{
|
const optionsList = useMemo(() => {
|
||||||
label: intl.formatMessage({ id: 'menu.playground.chat' }),
|
return [
|
||||||
value: 'chat',
|
{
|
||||||
icon: <MessageOutlined />
|
label: intl.formatMessage({ id: 'menu.playground.chat' }),
|
||||||
},
|
value: 'chat',
|
||||||
{
|
icon: <MessageOutlined />
|
||||||
label: intl.formatMessage({ id: 'menu.compare' }),
|
},
|
||||||
value: 'compare',
|
{
|
||||||
icon: <OneToOneOutlined />
|
label: intl.formatMessage({ id: 'menu.compare' }),
|
||||||
}
|
value: 'compare',
|
||||||
];
|
icon: <OneToOneOutlined />
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}, [intl]);
|
||||||
|
|
||||||
const handleViewCode = useCallback(() => {
|
const handleViewCode = useCallback(() => {
|
||||||
if (activeKey === 'reranker') {
|
if (activeKey === 'reranker') {
|
||||||
@@ -43,7 +46,7 @@ const Playground: React.FC = () => {
|
|||||||
} else if (activeKey === 'chat') {
|
} else if (activeKey === 'chat') {
|
||||||
groundLeftRef.current?.viewCode?.();
|
groundLeftRef.current?.viewCode?.();
|
||||||
}
|
}
|
||||||
}, [groundLeftRef, groundRerankerRef, activeKey]);
|
}, [activeKey]);
|
||||||
|
|
||||||
const handleToggleCollapse = useCallback(() => {
|
const handleToggleCollapse = useCallback(() => {
|
||||||
if (activeKey === 'reranker') {
|
if (activeKey === 'reranker') {
|
||||||
@@ -51,33 +54,33 @@ const Playground: React.FC = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
groundLeftRef.current?.setCollapse?.();
|
groundLeftRef.current?.setCollapse?.();
|
||||||
}, [groundLeftRef, groundRerankerRef, activeKey]);
|
}, [activeKey]);
|
||||||
|
|
||||||
const items: TabsProps['items'] = [
|
const items: TabsProps['items'] = useMemo(() => {
|
||||||
{
|
return [
|
||||||
key: 'chat',
|
{
|
||||||
label: 'Chat',
|
key: 'chat',
|
||||||
children: (
|
label: 'Chat',
|
||||||
<GroundLeft ref={groundLeftRef} modelList={modelList}></GroundLeft>
|
children: (
|
||||||
)
|
<GroundLeft ref={groundLeftRef} modelList={modelList}></GroundLeft>
|
||||||
},
|
)
|
||||||
{
|
},
|
||||||
key: 'compare',
|
{
|
||||||
label: 'Compare',
|
key: 'compare',
|
||||||
children: <MultipleChat modelList={modelList} loaded={loaded} />
|
label: 'Compare',
|
||||||
}
|
children: <MultipleChat modelList={modelList} loaded={loaded} />
|
||||||
];
|
}
|
||||||
|
];
|
||||||
|
}, [modelList, loaded]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (size.width < breakpoints.lg) {
|
if (size.width < breakpoints.lg && !groundLeftRef.current?.collapse) {
|
||||||
if (!groundLeftRef.current?.collapse) {
|
groundLeftRef.current?.setCollapse?.();
|
||||||
groundLeftRef.current?.setCollapse?.();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [size.width]);
|
}, [size.width]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getModelList = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
categories: modelCategoriesMap.llm,
|
categories: modelCategoriesMap.llm,
|
||||||
@@ -91,25 +94,18 @@ const Playground: React.FC = () => {
|
|||||||
meta: item.meta
|
meta: item.meta
|
||||||
};
|
};
|
||||||
}) as Global.BaseOption<string>[];
|
}) as Global.BaseOption<string>[];
|
||||||
return list;
|
setModelList(list);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return [];
|
} finally {
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchData = async () => {
|
|
||||||
try {
|
|
||||||
const modelist = await getModelList();
|
|
||||||
setModelList(modelist);
|
|
||||||
} catch (error) {
|
|
||||||
setLoaded(true);
|
setLoaded(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const renderExtra = () => {
|
const renderExtra = useMemo(() => {
|
||||||
if (activeKey === 'compare') {
|
if (activeKey === 'compare') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -134,12 +130,38 @@ const Playground: React.FC = () => {
|
|||||||
></Button>
|
></Button>
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
};
|
}, [activeKey, intl, handleViewCode, handleToggleCollapse]);
|
||||||
|
|
||||||
|
const header = useMemo(() => {
|
||||||
|
return {
|
||||||
|
title: (
|
||||||
|
<div className="flex items-center">
|
||||||
|
<span className="font-600">
|
||||||
|
{intl.formatMessage({ id: 'menu.playground.chat' })}
|
||||||
|
</span>
|
||||||
|
{
|
||||||
|
<Segmented
|
||||||
|
options={optionsList}
|
||||||
|
size="middle"
|
||||||
|
className="m-l-40"
|
||||||
|
onChange={(key) => setActiveKey(key)}
|
||||||
|
></Segmented>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
style: {
|
||||||
|
paddingInline: 'var(--layout-content-header-inlinepadding)'
|
||||||
|
},
|
||||||
|
breadcrumb: {}
|
||||||
|
};
|
||||||
|
}, [optionsList]);
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
HotKeys.RIGHT.join(','),
|
HotKeys.RIGHT.join(','),
|
||||||
() => {
|
() => {
|
||||||
groundLeftRef.current?.setCollapse?.();
|
if (activeKey === 'chat') {
|
||||||
|
groundLeftRef.current?.setCollapse?.();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
preventDefault: true
|
preventDefault: true
|
||||||
@@ -149,28 +171,8 @@ const Playground: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<PageContainer
|
<PageContainer
|
||||||
ghost
|
ghost
|
||||||
header={{
|
header={header}
|
||||||
title: (
|
extra={renderExtra}
|
||||||
<div className="flex items-center">
|
|
||||||
<span className="font-600">
|
|
||||||
{intl.formatMessage({ id: 'menu.playground.chat' })}
|
|
||||||
</span>
|
|
||||||
{
|
|
||||||
<Segmented
|
|
||||||
options={optionsList}
|
|
||||||
size="middle"
|
|
||||||
className="m-l-40"
|
|
||||||
onChange={(key) => setActiveKey(key)}
|
|
||||||
></Segmented>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
style: {
|
|
||||||
paddingInline: 'var(--layout-content-header-inlinepadding)'
|
|
||||||
},
|
|
||||||
breadcrumb: {}
|
|
||||||
}}
|
|
||||||
extra={renderExtra()}
|
|
||||||
className={classNames('playground-container', {
|
className={classNames('playground-container', {
|
||||||
compare: activeKey === 'compare',
|
compare: activeKey === 'compare',
|
||||||
chat: activeKey !== 'compare'
|
chat: activeKey !== 'compare'
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { useIntl, useSearchParams } from '@umijs/max';
|
|||||||
import { Button, Segmented, Space, Tabs, TabsProps } from 'antd';
|
import { Button, Segmented, Space, Tabs, TabsProps } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { queryModelsList } from './apis';
|
import { queryModelsList } from './apis';
|
||||||
import GroundSTT from './components/ground-stt';
|
import GroundSTT from './components/ground-stt';
|
||||||
@@ -37,19 +37,21 @@ const Playground: React.FC = () => {
|
|||||||
const [speechModelList, setSpeechModelList] = useState<
|
const [speechModelList, setSpeechModelList] = useState<
|
||||||
Global.BaseOption<string>[]
|
Global.BaseOption<string>[]
|
||||||
>([]);
|
>([]);
|
||||||
const [loaded, setLoaded] = useState(false);
|
|
||||||
const optionsList = [
|
const optionsList = useMemo(() => {
|
||||||
{
|
return [
|
||||||
label: intl.formatMessage({ id: 'playground.audio.texttospeech' }),
|
{
|
||||||
value: TabsValueMap.Tab1,
|
label: intl.formatMessage({ id: 'playground.audio.texttospeech' }),
|
||||||
icon: <IconFont type={'icon-audio'}></IconFont>
|
value: TabsValueMap.Tab1,
|
||||||
},
|
icon: <IconFont type={'icon-audio'}></IconFont>
|
||||||
{
|
},
|
||||||
label: intl.formatMessage({ id: 'playground.audio.speechtotext' }),
|
{
|
||||||
value: TabsValueMap.Tab2,
|
label: intl.formatMessage({ id: 'playground.audio.speechtotext' }),
|
||||||
icon: <AudioOutlined />
|
value: TabsValueMap.Tab2,
|
||||||
}
|
icon: <AudioOutlined />
|
||||||
];
|
}
|
||||||
|
];
|
||||||
|
}, [intl]);
|
||||||
|
|
||||||
const handleViewCode = useCallback(() => {
|
const handleViewCode = useCallback(() => {
|
||||||
if (activeKey === TabsValueMap.Tab1) {
|
if (activeKey === TabsValueMap.Tab1) {
|
||||||
@@ -67,29 +69,25 @@ const Playground: React.FC = () => {
|
|||||||
groundTabRef2.current?.setCollapse?.();
|
groundTabRef2.current?.setCollapse?.();
|
||||||
}, [activeKey]);
|
}, [activeKey]);
|
||||||
|
|
||||||
const items: TabsProps['items'] = [
|
const items: TabsProps['items'] = useMemo(() => {
|
||||||
{
|
return [
|
||||||
key: 'tts',
|
{
|
||||||
label: 'TTS',
|
key: 'tts',
|
||||||
children: (
|
label: 'TTS',
|
||||||
<GroundTTS
|
children: (
|
||||||
ref={groundTabRef1}
|
<GroundTTS
|
||||||
modelList={textToSpeechModels}
|
ref={groundTabRef1}
|
||||||
></GroundTTS>
|
modelList={textToSpeechModels}
|
||||||
)
|
></GroundTTS>
|
||||||
},
|
)
|
||||||
{
|
},
|
||||||
key: 'stt',
|
{
|
||||||
label: 'Realtime',
|
key: 'stt',
|
||||||
children: (
|
label: 'Realtime',
|
||||||
<GroundSTT
|
children: <GroundSTT modelList={speechModelList} ref={groundTabRef2} />
|
||||||
modelList={speechModelList}
|
}
|
||||||
loaded={loaded}
|
];
|
||||||
ref={groundTabRef2}
|
}, [textToSpeechModels, speechModelList]);
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (size.width < breakpoints.lg) {
|
if (size.width < breakpoints.lg) {
|
||||||
@@ -153,13 +151,13 @@ const Playground: React.FC = () => {
|
|||||||
setTextToSpeechModels(textToSpeechModels);
|
setTextToSpeechModels(textToSpeechModels);
|
||||||
setSpeechModelList(speechToTextModels);
|
setSpeechModelList(speechToTextModels);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoaded(true);
|
// error
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const renderExtra = () => {
|
const renderExtra = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
<Space key="buttons">
|
<Space key="buttons">
|
||||||
<Button
|
<Button
|
||||||
@@ -181,7 +179,32 @@ const Playground: React.FC = () => {
|
|||||||
></Button>
|
></Button>
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
};
|
}, [handleToggleCollapse, handleViewCode, intl]);
|
||||||
|
|
||||||
|
const header = useMemo(() => {
|
||||||
|
return {
|
||||||
|
title: (
|
||||||
|
<div className="flex items-center">
|
||||||
|
<span className="font-600">
|
||||||
|
{intl.formatMessage({ id: 'menu.playground.speech' })}
|
||||||
|
</span>
|
||||||
|
{
|
||||||
|
<Segmented
|
||||||
|
options={optionsList}
|
||||||
|
size="middle"
|
||||||
|
className="m-l-40"
|
||||||
|
value={activeKey}
|
||||||
|
onChange={(key) => setActiveKey(key)}
|
||||||
|
></Segmented>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
style: {
|
||||||
|
paddingInline: 'var(--layout-content-header-inlinepadding)'
|
||||||
|
},
|
||||||
|
breadcrumb: {}
|
||||||
|
};
|
||||||
|
}, [activeKey, optionsList]);
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
HotKeys.RIGHT.join(','),
|
HotKeys.RIGHT.join(','),
|
||||||
@@ -196,29 +219,8 @@ const Playground: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<PageContainer
|
<PageContainer
|
||||||
ghost
|
ghost
|
||||||
header={{
|
header={header}
|
||||||
title: (
|
extra={renderExtra}
|
||||||
<div className="flex items-center">
|
|
||||||
<span className="font-600">
|
|
||||||
{intl.formatMessage({ id: 'menu.playground.speech' })}
|
|
||||||
</span>
|
|
||||||
{
|
|
||||||
<Segmented
|
|
||||||
options={optionsList}
|
|
||||||
size="middle"
|
|
||||||
className="m-l-40"
|
|
||||||
value={activeKey}
|
|
||||||
onChange={(key) => setActiveKey(key)}
|
|
||||||
></Segmented>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
style: {
|
|
||||||
paddingInline: 'var(--layout-content-header-inlinepadding)'
|
|
||||||
},
|
|
||||||
breadcrumb: {}
|
|
||||||
}}
|
|
||||||
extra={renderExtra()}
|
|
||||||
className={classNames('playground-container', {
|
className={classNames('playground-container', {
|
||||||
compare: activeKey === 'compare',
|
compare: activeKey === 'compare',
|
||||||
chat: activeKey !== 'compare'
|
chat: activeKey !== 'compare'
|
||||||
|
|||||||
Reference in New Issue
Block a user