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 = {
canSeeAdmin: boolean;
canSeeOrgAdmin: boolean;
canSeeGpuService: boolean;
canManageCurrentOrg: boolean;
canSeeUser: boolean;
canDelete: boolean;
+15
View File
@@ -110,3 +110,18 @@ const lookupOrgNamespace = (id: number | null): string | 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({
categories: row.categories || [],
name: targetRoute?.route_name || ''
name: targetRoute?.route_name || '',
owner_principal_id: row.owner_principal_id
});
}
if (val === 'metrics') {
+1
View File
@@ -28,6 +28,7 @@ export interface ListItem {
path: string;
source: string;
}>;
owner_principal_id?: number;
name: string;
description: string;
id: number;
@@ -1,3 +1,4 @@
import { getAllOrganizations } from '@/atoms/user';
import { useNavigate } from '@umijs/max';
import { modelCategoriesMap } from '../../llmodels/config';
import { categoryToPathMap } from '../../llmodels/config/button-actions';
@@ -6,6 +7,13 @@ const useOpenPlayground = () => {
const navigate = useNavigate();
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)) {
if (
row.categories?.includes(category) &&
@@ -14,15 +22,15 @@ const useOpenPlayground = () => {
modelCategoriesMap.speech_to_text
].includes(category)
) {
navigate(`${path}&model=${row.name}`);
navigate(`${path}&model=${modelName}`);
return;
}
if (row.categories?.includes(category)) {
navigate(`${path}?model=${row.name}`);
navigate(`${path}?model=${modelName}`);
return;
}
}
navigate(`/playground/chat?model=${row.name}`);
navigate(`/playground/chat?model=${modelName}`);
};
return {
handleOpenPlayGround