fix: open model in playground
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { useNavigate } from '@umijs/max';
|
||||
import { modelCategoriesMap } from '../../llmodels/config';
|
||||
import { categoryToPathMap } from '../../llmodels/config/button-actions';
|
||||
|
||||
const useOpenPlayground = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleOpenPlayGround = (row: any) => {
|
||||
for (const [category, path] of Object.entries(categoryToPathMap)) {
|
||||
if (
|
||||
row.categories?.includes(category) &&
|
||||
[
|
||||
modelCategoriesMap.text_to_speech,
|
||||
modelCategoriesMap.speech_to_text
|
||||
].includes(category)
|
||||
) {
|
||||
navigate(`${path}&model=${row.name}`);
|
||||
return;
|
||||
}
|
||||
if (row.categories?.includes(category)) {
|
||||
navigate(`${path}?model=${row.name}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
navigate(`/playground/chat?model=${row.name}`);
|
||||
};
|
||||
return {
|
||||
handleOpenPlayGround
|
||||
};
|
||||
};
|
||||
|
||||
export default useOpenPlayground;
|
||||
@@ -16,6 +16,15 @@ const useAccessColumns = (
|
||||
): SealColumnProps[] => {
|
||||
const intl = useIntl();
|
||||
|
||||
const filterActions = (record: RouteItem) => {
|
||||
return rowActionList.filter((action) => {
|
||||
if (action.key === 'chat') {
|
||||
return record.ready_targets > 0;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
return useMemo(() => {
|
||||
return [
|
||||
{
|
||||
@@ -59,7 +68,7 @@ const useAccessColumns = (
|
||||
span: 4,
|
||||
render: (value: string, record: RouteItem) => (
|
||||
<DropdownButtons
|
||||
items={rowActionList}
|
||||
items={filterActions(record)}
|
||||
onSelect={(val) => handleSelect(val, record)}
|
||||
></DropdownButtons>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user