Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apps/ai-dial-admin/src/utils/deployments/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ export const getIdFormat = (name: string) => {
return name.toLowerCase().replace(/\s+/g, '_');
};

export const getEntityId = (container: Container, route: ApplicationRoute, t: (key: string) => string) => {
return getIdFormat(getEntityName(container, route, t));
export const getEntityId = (container: Container) => {
return getIdFormat(getEntityName(container));
};

export const getEntityName = (container: Container, route: ApplicationRoute, t: (key: string) => string) => {
return `${container.displayName} ${getTranslatedEntity(route, t)}`;
export const getEntityName = (container: Container) => {
return `${container.displayName}`;
};

export const getEntityTemplate = (
Expand All @@ -87,8 +87,8 @@ export const getEntityTemplate = (
transport?: CONTAINER_TRANSPORT,
): DialModel | Toolset | DialInterceptor => {
const template: DialModel | Toolset | DialInterceptor = {
name: getEntityId(container, route, t),
displayName: getEntityName(container, route, t),
name: getEntityId(container),
displayName: getEntityName(container),
description: '',
source: { $type: SOURCE_TYPE.CONTAINER, containerId: container.name },
};
Expand Down Expand Up @@ -119,8 +119,8 @@ export const getAssetTemplate = (
transport: CONTAINER_TRANSPORT,
): Partial<AssetToolset> => {
return {
name: getEntityId(container, route, t),
displayName: getEntityName(container, route, t),
name: getEntityId(container),
displayName: getEntityName(container),
endpoint: container.url,
transport: ENTITY_TRANSPORT[transport],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ describe('entity utils', () => {
describe('getEntityId', () => {
test('generates id based on container name and route', () => {
const container = { displayName: 'MyContainer' } as any;
expect(getEntityId(container, ApplicationRoute.ModelServings, t)).toBe('mycontainer_entities.model');
expect(getEntityId(container)).toBe('mycontainer');
});
});

describe('getEntityName', () => {
test('generates name based on container name and route', () => {
const container = { displayName: 'MyContainer' } as any;
expect(getEntityName(container, ApplicationRoute.ModelServings, t)).toBe(`MyContainer ${EntitiesI18nKey.Model}`);
expect(getEntityName(container)).toBe(`MyContainer`);
});
});

describe('getEntityTemplate', () => {
test('returns basic template', () => {
const container = { displayName: 'MyContainer', name: '123' } as any;
const template = getEntityTemplate(ApplicationRoute.InterceptorContainers, container, t);
expect(template.name).toBe('mycontainer_entities.interceptor');
expect(template.name).toBe('mycontainer');
expect(template.source?.containerId).toBe('123');
});

Expand All @@ -134,7 +134,7 @@ describe('entity utils', () => {
test('returns asset template', () => {
const container = { displayName: 'MyContainer', url: 'http://url' } as any;
const template = getAssetTemplate(ApplicationRoute.McpContainers, container, t, CONTAINER_TRANSPORT.SSE);
expect(template.name).toBe('mycontainer_entities.toolset');
expect(template.name).toBe('mycontainer');
expect(template.endpoint).toBe('http://url');
expect(template.transport).toBe(CONTAINER_TRANSPORT.SSE);
});
Expand Down
Loading