@@ -56,6 +56,58 @@ import * as fs from 'node:fs';
56
56
import * as path from 'node:path' ;
57
57
import { fileURLToPath } from 'node:url' ;
58
58
import type { AILabTryInstructLabPage } from './model/ai-lab-try-instructlab-page' ;
59
+ import type { ApplicationCatalog } from '../../../packages/shared/src/models/IApplicationCatalog' ;
60
+
61
+ const __filename = fileURLToPath ( import . meta. url ) ;
62
+ const __dirname = path . dirname ( __filename ) ;
63
+ const TEST_AUDIO_FILE_PATH : string = path . resolve (
64
+ __dirname ,
65
+ '..' ,
66
+ '..' ,
67
+ 'playwright' ,
68
+ 'resources' ,
69
+ `test-audio-to-text.wav` ,
70
+ ) ;
71
+ const AI_JSON_FILE_PATH : string = path . resolve (
72
+ __dirname ,
73
+ '..' ,
74
+ '..' ,
75
+ '..' ,
76
+ 'packages' ,
77
+ 'backend' ,
78
+ 'src' ,
79
+ 'assets' ,
80
+ 'ai.json' ,
81
+ ) ;
82
+
83
+ const aiJSONFile = fs . readFileSync ( AI_JSON_FILE_PATH , 'utf8' ) ;
84
+ const AI_JSON : ApplicationCatalog = JSON . parse ( aiJSONFile ) as ApplicationCatalog ;
85
+ const AI_APP_MODELS : Set < string > = new Set ( ) ;
86
+ AI_JSON . recipes . forEach ( recipe => {
87
+ recipe . recommended ?. forEach ( model => {
88
+ AI_APP_MODELS . add ( model ) ;
89
+ } ) ;
90
+ } ) ;
91
+ // Create a set of AI models that are not the first recommended model for any app
92
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
93
+ const _AI_APP_UNUSED_MODELS : string [ ] = [
94
+ ...AI_APP_MODELS . values ( ) . filter ( model => {
95
+ // Check if the model is not the first recommended model for any app
96
+ return ! Array . from ( AI_JSON . recipes ) . some ( recipe => {
97
+ return recipe . recommended ?. at ( 0 ) === model ;
98
+ } ) ;
99
+ } ) ,
100
+ ] ;
101
+ const AI_APP_MODEL_AND_NAMES : Map < string , string [ ] > = new Map ( ) ;
102
+ AI_JSON . recipes . forEach ( recipe => {
103
+ const recommendedModel = recipe . recommended ?. at ( 0 ) ;
104
+ if ( recommendedModel ) {
105
+ if ( ! AI_APP_MODEL_AND_NAMES . has ( recommendedModel ) ) {
106
+ AI_APP_MODEL_AND_NAMES . set ( recommendedModel , [ ] ) ;
107
+ }
108
+ AI_APP_MODEL_AND_NAMES . get ( recommendedModel ) ?. push ( recipe . name ) ;
109
+ }
110
+ } ) ;
59
111
60
112
const AI_LAB_EXTENSION_OCI_IMAGE =
61
113
process . env . EXTENSION_OCI_IMAGE ?? 'ghcr.io/containers/podman-desktop-extension-ai-lab:nightly' ;
@@ -83,17 +135,6 @@ const AI_APPS: AiApp[] = [
83
135
{ appName : 'Object Detection' , appModel : 'facebook/detr-resnet-101' } ,
84
136
] ;
85
137
86
- const __filename = fileURLToPath ( import . meta. url ) ;
87
- const __dirname = path . dirname ( __filename ) ;
88
- const TEST_AUDIO_FILE_PATH : string = path . resolve (
89
- __dirname ,
90
- '..' ,
91
- '..' ,
92
- 'playwright' ,
93
- 'resources' ,
94
- `test-audio-to-text.wav` ,
95
- ) ;
96
-
97
138
test . use ( {
98
139
runnerOptions : new RunnerOptions ( runnerOptions ) ,
99
140
} ) ;
0 commit comments