diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index c63c13a5b..1ae2fec62 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -11,6 +11,7 @@ import { Task } from '@shared/models/ITask'; import { Studio } from './studio'; import * as path from 'node:path'; import { ModelResponse } from '@shared/models/IModelResponse'; +import { PlayGroundManager } from './playground'; export const RECENT_CATEGORY_ID = 'recent-category'; @@ -19,6 +20,7 @@ export class StudioApiImpl implements StudioAPI { private applicationManager: ApplicationManager, private recipeStatusRegistry: RecipeStatusRegistry, private taskRegistry: TaskRegistry, + private playgroundManager: PlayGroundManager, ) {} async openURL(url: string): Promise { @@ -93,9 +95,10 @@ export class StudioApiImpl implements StudioAPI { if (localModelInfo.length !== 1) { throw new Error('model not found'); } - const destDir = path.join(); + const modelPath = path.resolve(this.applicationManager.homeDirectory, AI_STUDIO_FOLDER, 'models', modelId, localModelInfo[0].file); - this.studio.playgroundManager.startPlayground(modelId, modelPath); + + await this.playgroundManager.startPlayground(modelId, modelPath); } askPlayground(modelId: string, prompt: string): Promise { @@ -103,6 +106,6 @@ export class StudioApiImpl implements StudioAPI { if (localModelInfo.length !== 1) { throw new Error('model not found'); } - return this.studio.playgroundManager.askPlayground(localModelInfo[0], prompt); + return this.playgroundManager.askPlayground(localModelInfo[0], prompt); } } diff --git a/packages/backend/src/studio.ts b/packages/backend/src/studio.ts index 0b160b293..eb13c103b 100644 --- a/packages/backend/src/studio.ts +++ b/packages/backend/src/studio.ts @@ -103,7 +103,8 @@ export class Studio { this.studioApi = new StudioApiImpl( applicationManager, recipeStatusRegistry, - taskRegistry + taskRegistry, + this.playgroundManager, ); // Register the instance this.rpcExtension.registerInstance(StudioApiImpl, this.studioApi); diff --git a/packages/shared/StudioAPI.ts b/packages/shared/StudioAPI.ts index c2cb51523..b76fa4f1c 100644 --- a/packages/shared/StudioAPI.ts +++ b/packages/shared/StudioAPI.ts @@ -3,6 +3,7 @@ import type { Category } from '@shared/models/ICategory'; import { RecipeStatus } from '@shared/models/IRecipeStatus'; import { ModelInfo } from '@shared/models/IModelInfo'; import { ModelResponse } from '@shared/models/IModelResponse'; +import { Task } from './models/ITask'; export abstract class StudioAPI { abstract ping(): Promise;