fix: orgname not be shown in playground

This commit is contained in:
jialin
2026-05-29 13:35:22 +08:00
committed by jialin
parent faf0d4d605
commit 34098e8950
5 changed files with 29 additions and 5 deletions
-1
View File
@@ -4,7 +4,6 @@
export type AccessPredicates = { export type AccessPredicates = {
canSeeAdmin: boolean; canSeeAdmin: boolean;
canSeeOrgAdmin: boolean; canSeeOrgAdmin: boolean;
canSeeGpuService: boolean;
canManageCurrentOrg: boolean; canManageCurrentOrg: boolean;
canSeeUser: boolean; canSeeUser: boolean;
canDelete: boolean; canDelete: boolean;
+15
View File
@@ -110,3 +110,18 @@ const lookupOrgNamespace = (id: number | null): string | null => {
} }
return null; return null;
}; };
export const getAllOrganizations = (): Array<{ id: number; name?: string }> => {
const allOrganizations = localStorage.getItem('allOrganizations');
if (!allOrganizations) return [];
try {
const list = JSON.parse(allOrganizations) as Array<{
id: number;
name?: string;
}>;
if (!Array.isArray(list)) return [];
return list;
} catch {
return [];
}
};
+2 -1
View File
@@ -415,7 +415,8 @@ const Models: React.FC<ModelsProps> = ({
handleOpenPlayGround({ handleOpenPlayGround({
categories: row.categories || [], categories: row.categories || [],
name: targetRoute?.route_name || '' name: targetRoute?.route_name || '',
owner_principal_id: row.owner_principal_id
}); });
} }
if (val === 'metrics') { if (val === 'metrics') {
+1
View File
@@ -28,6 +28,7 @@ export interface ListItem {
path: string; path: string;
source: string; source: string;
}>; }>;
owner_principal_id?: number;
name: string; name: string;
description: string; description: string;
id: number; id: number;
@@ -1,3 +1,4 @@
import { getAllOrganizations } from '@/atoms/user';
import { useNavigate } from '@umijs/max'; import { useNavigate } from '@umijs/max';
import { modelCategoriesMap } from '../../llmodels/config'; import { modelCategoriesMap } from '../../llmodels/config';
import { categoryToPathMap } from '../../llmodels/config/button-actions'; import { categoryToPathMap } from '../../llmodels/config/button-actions';
@@ -6,6 +7,13 @@ const useOpenPlayground = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const handleOpenPlayGround = (row: any) => { const handleOpenPlayGround = (row: any) => {
const allOrganizations = getAllOrganizations();
const orgName = allOrganizations.find(
(org) => org.id === row.owner_principal_id
)?.name;
const rawModel = orgName ? `${orgName}/${row.name}` : row.name;
const modelName = encodeURIComponent(rawModel);
for (const [category, path] of Object.entries(categoryToPathMap)) { for (const [category, path] of Object.entries(categoryToPathMap)) {
if ( if (
row.categories?.includes(category) && row.categories?.includes(category) &&
@@ -14,15 +22,15 @@ const useOpenPlayground = () => {
modelCategoriesMap.speech_to_text modelCategoriesMap.speech_to_text
].includes(category) ].includes(category)
) { ) {
navigate(`${path}&model=${row.name}`); navigate(`${path}&model=${modelName}`);
return; return;
} }
if (row.categories?.includes(category)) { if (row.categories?.includes(category)) {
navigate(`${path}?model=${row.name}`); navigate(`${path}?model=${modelName}`);
return; return;
} }
} }
navigate(`/playground/chat?model=${row.name}`); navigate(`/playground/chat?model=${modelName}`);
}; };
return { return {
handleOpenPlayGround handleOpenPlayGround