fix: playground model id alignment across org boundaries
Two QA-reported bugs on the "Open in Playground" path. Both come
down to the model id the playground submits not matching what
``/v1/models`` / the dispatcher key off:
* Routes page (OSS UI) emitted ``default/<name>`` for routes in the
platform Org and 404'd. ``use-open-playground`` keyed off the
``is_platform`` flag alone; stale caches that drop the flag
slipped through. Also accept the well-known ``name === 'default'``
(``PLATFORM_PRINCIPAL_NAME`` on the backend) as a fallback signal.
* My Models page (enterprise UI, non-admin) emitted bare ``<name>``
with no Org prefix for non-platform routes. Use ``model.name``
from ``/v2/my-models`` verbatim — the backend ("fix: principal
prefix in my-models") now rewrites that field to the OpenAI-style
id server-side, which also closes the cross-Org grant gap a
client-side cache lookup can't (the granting Org isn't in the
caller's member list). Card title now shows the prefixed id, so
users can tell apart same-named models from different Orgs.
Routes page keeps ``useOpenPlayground`` — that surface is always
scoped to the caller's own Org, the local cache is sufficient, and
``/model-routes`` still returns the raw ``name``.
Also drops the now-unused ``onClick`` prop on ``ModelItem``: the
card had ``clickable={false}`` so the parent-passed handler was
already dead code; the Button drives the playground navigation.
This commit is contained in:
@@ -8,8 +8,15 @@ const useOpenPlayground = () => {
|
||||
|
||||
const generateModelName = (row: any) => {
|
||||
const org = getOrgById(row.owner_principal_id) ?? getCurrentOrg();
|
||||
// The platform Org is always named ``default`` (backend constant
|
||||
// ``PLATFORM_PRINCIPAL_NAME``); its models are reported by
|
||||
// ``/v1/models`` without a prefix. Match by name too, not just the
|
||||
// ``is_platform`` flag — pre-multi-tenancy OSS caches and any other
|
||||
// path that drops the flag would otherwise emit ``default/<name>``
|
||||
// and 404 against the unprefixed model id.
|
||||
const isPlatformOrg = org?.is_platform || org?.name === 'default';
|
||||
const rawModel =
|
||||
org?.name && !org.is_platform ? `${org.name}/${row.name}` : row.name;
|
||||
org?.name && !isPlatformOrg ? `${org.name}/${row.name}` : row.name;
|
||||
return rawModel;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user