diff --git a/packages/backend/src/managers/modelsManager.ts b/packages/backend/src/managers/modelsManager.ts index 32ac7d3bf..b46327bb9 100644 --- a/packages/backend/src/managers/modelsManager.ts +++ b/packages/backend/src/managers/modelsManager.ts @@ -19,9 +19,13 @@ export class ModelsManager { // we support models with one file only for now continue; } + const modelFile = modelEntries[0]; + const info = fs.statSync(path.resolve(d.path, d.name, modelFile)); result.push({ id: d.name, - file: modelEntries[0], + file: modelFile, + size: info.size, + creation: info.mtime, }); } return result; diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index 9347ab04f..4aacdbdba 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -30,6 +30,7 @@ import type { CatalogManager } from './managers/catalogManager'; import type { Catalog } from '@shared/src/models/ICatalog'; import type { PlaygroundState } from '@shared/src/models/IPlaygroundState'; import type { ModelsManager } from './managers/modelsManager'; +import { LocalModelInfo } from '@shared/src/models/ILocalModelInfo'; export class StudioApiImpl implements StudioAPI { constructor( @@ -39,7 +40,7 @@ export class StudioApiImpl implements StudioAPI { private playgroundManager: PlayGroundManager, private catalogManager: CatalogManager, private modelsManager: ModelsManager, - ) {} + ) { } async ping(): Promise { return 'pong'; @@ -81,8 +82,14 @@ export class StudioApiImpl implements StudioAPI { async getLocalModels(): Promise { const local = this.modelsManager.getLocalModels(); + const localMap = new Map(); + for (const l of local) { + localMap.set(l.id, l); + } const localIds = local.map(l => l.id); - return this.catalogManager.getModels().filter(m => localIds.includes(m.id)); + return this.catalogManager.getModels() + .filter(m => localIds.includes(m.id)) + .map(m => ({ ...m, file: localMap.get(m.id) })); } async startPlayground(modelId: string): Promise { diff --git a/packages/shared/src/models/ILocalModelInfo.ts b/packages/shared/src/models/ILocalModelInfo.ts index 9509d7ab8..9179c318b 100644 --- a/packages/shared/src/models/ILocalModelInfo.ts +++ b/packages/shared/src/models/ILocalModelInfo.ts @@ -1,4 +1,6 @@ export interface LocalModelInfo { id: string; file: string; + size: number; + creation: Date; } diff --git a/packages/shared/src/models/IModelInfo.ts b/packages/shared/src/models/IModelInfo.ts index 5fb64808c..c1ada857c 100644 --- a/packages/shared/src/models/IModelInfo.ts +++ b/packages/shared/src/models/IModelInfo.ts @@ -1,3 +1,5 @@ +import type { LocalModelInfo } from "./ILocalModelInfo"; + export interface ModelInfo { id: string; name: string; @@ -7,4 +9,5 @@ export interface ModelInfo { popularity: number; license: string; url: string; + file?: LocalModelInfo; }