fix: api acccess info model name
This commit is contained in:
@@ -6,6 +6,13 @@ import { categoryToPathMap } from '../../llmodels/config/button-actions';
|
||||
const useOpenPlayground = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const generateModelName = (row: any) => {
|
||||
const org = getOrgById(row.owner_principal_id) ?? getCurrentOrg();
|
||||
const rawModel =
|
||||
org?.name && !org.is_platform ? `${org.name}/${row.name}` : row.name;
|
||||
return rawModel;
|
||||
};
|
||||
|
||||
const handleOpenPlayGround = (row: any) => {
|
||||
// Match the id format the OpenAI ``/v1/models`` endpoint reports: an
|
||||
// org's models are namespaced as ``{org}/{name}``, while the platform
|
||||
@@ -13,9 +20,7 @@ const useOpenPlayground = () => {
|
||||
// ``owner_principal_id`` (an org principal id); fall back to the Org the
|
||||
// caller is currently acting under for the admin "All" view, where the
|
||||
// row's owner still resolves via the platform-wide org cache.
|
||||
const org = getOrgById(row.owner_principal_id) ?? getCurrentOrg();
|
||||
const rawModel =
|
||||
org?.name && !org.is_platform ? `${org.name}/${row.name}` : row.name;
|
||||
const rawModel = generateModelName(row);
|
||||
const modelName = encodeURIComponent(rawModel);
|
||||
|
||||
for (const [category, path] of Object.entries(categoryToPathMap)) {
|
||||
@@ -37,7 +42,8 @@ const useOpenPlayground = () => {
|
||||
navigate(`/playground/chat?model=${modelName}`);
|
||||
};
|
||||
return {
|
||||
handleOpenPlayGround
|
||||
handleOpenPlayGround,
|
||||
generateModelName
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -9,9 +9,10 @@ import {
|
||||
type TableColumnProps
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { useMemoizedFn } from 'ahooks';
|
||||
import { MenuProps } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import { RouteItem } from '../config/types';
|
||||
import type { ModelRouteConfigAction } from '../plugin';
|
||||
|
||||
@@ -128,10 +129,8 @@ const useAccessColumns = ({
|
||||
});
|
||||
}, [configActions, onConfigAction]);
|
||||
|
||||
const filterActions = useCallback(
|
||||
(record: RouteItem) =>
|
||||
sortedActions.filter((a) => (a.show ? a.show(record) : true)),
|
||||
[sortedActions]
|
||||
const filterActions = useMemoizedFn((record: RouteItem) =>
|
||||
sortedActions.filter((a) => (a.show ? a.show(record) : true))
|
||||
);
|
||||
|
||||
// Plugin entries carry their own `onClick` (wired to `onConfigAction`
|
||||
@@ -139,15 +138,14 @@ const useAccessColumns = ({
|
||||
// when present. Built-ins fall through to the page's `handleSelect`
|
||||
// dispatcher keyed by `val`. Mirrors the api-keys page's onSelect
|
||||
// path — no key lookup needed.
|
||||
const onSelectAction = useCallback(
|
||||
const onSelectAction = useMemoizedFn(
|
||||
(val: string, record: RouteItem, item?: RankedAction) => {
|
||||
if (item?.onClick) {
|
||||
item.onClick(record);
|
||||
return;
|
||||
}
|
||||
handleSelect(val, record);
|
||||
},
|
||||
[handleSelect]
|
||||
}
|
||||
);
|
||||
|
||||
return useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user