@@ -11,9 +11,12 @@ import { Service } from "typedi";
11
11
import { getLocalizedString } from "../../../common/localizeUtils" ;
12
12
import { InvalidActionInputError , assembleError } from "../../../error/common" ;
13
13
import {
14
+ azureOpenAIAssistantIdQuestion ,
14
15
azureOpenAIDeploymentNameQuestion ,
16
+ azureOpenAIEmbeddingDeploymentNameQuestion ,
15
17
azureOpenAIEndpointQuestion ,
16
18
azureOpenAIKeyQuestion ,
19
+ openAIAssistantIdQuestion ,
17
20
openAIKeyQuestion ,
18
21
} from "../../../question" ;
19
22
import { OpenAIEnvironmentVariables } from "../../constants" ;
@@ -206,6 +209,32 @@ export class CreateOrUpdateEnvironmentFileDriver implements StepDriver {
206
209
}
207
210
}
208
211
212
+ if ( args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_MODEL_DEPLOYMENT_NAME ] ) {
213
+ const matches = placeHolderReg . exec (
214
+ args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_MODEL_DEPLOYMENT_NAME ]
215
+ ) ;
216
+ if ( matches != null && matches . length > 1 ) {
217
+ const result = await ctx . ui ! . inputText ( {
218
+ name : azureOpenAIDeploymentNameQuestion ( ) . name ,
219
+ title : azureOpenAIDeploymentNameQuestion ( ) . title as string ,
220
+ validation : ( input : string ) : string | undefined => {
221
+ if ( input . length < 1 ) {
222
+ return getLocalizedString (
223
+ "driver.file.createOrUpdateEnvironmentFile.OpenAIDeploymentName.validation"
224
+ ) ;
225
+ }
226
+ } ,
227
+ } ) ;
228
+ if ( result . isErr ( ) ) {
229
+ return result ;
230
+ } else {
231
+ envOutput . set ( matches [ 1 ] , result . value . result ! ) ;
232
+ args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_MODEL_DEPLOYMENT_NAME ] =
233
+ result . value . result ! ;
234
+ }
235
+ }
236
+ }
237
+
209
238
if ( args . envs [ OpenAIEnvironmentVariables . OPENAI_API_KEY ] ) {
210
239
const matches = placeHolderReg . exec ( args . envs [ OpenAIEnvironmentVariables . OPENAI_API_KEY ] ) ;
211
240
if ( matches != null && matches . length > 1 ) {
@@ -229,6 +258,82 @@ export class CreateOrUpdateEnvironmentFileDriver implements StepDriver {
229
258
}
230
259
}
231
260
}
261
+
262
+ if ( args . envs [ OpenAIEnvironmentVariables . OPENAI_ASSISTANT_ID ] ) {
263
+ const matches = placeHolderReg . exec (
264
+ args . envs [ OpenAIEnvironmentVariables . OPENAI_ASSISTANT_ID ]
265
+ ) ;
266
+ if ( matches != null && matches . length > 1 ) {
267
+ const result = await ctx . ui ! . inputText ( {
268
+ name : openAIAssistantIdQuestion ( ) . name ,
269
+ title : openAIAssistantIdQuestion ( ) . title as string ,
270
+ validation : ( input : string ) : string | undefined => {
271
+ if ( input . length < 1 ) {
272
+ return getLocalizedString (
273
+ "driver.file.createOrUpdateEnvironmentFile.OpenAIAssistantID.validation"
274
+ ) ;
275
+ }
276
+ } ,
277
+ } ) ;
278
+ if ( result . isErr ( ) ) {
279
+ return result ;
280
+ } else {
281
+ envOutput . set ( matches [ 1 ] , result . value . result ! ) ;
282
+ args . envs [ OpenAIEnvironmentVariables . OPENAI_ASSISTANT_ID ] = result . value . result ! ;
283
+ }
284
+ }
285
+ }
286
+
287
+ if ( args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_ASSISTANT_ID ] ) {
288
+ const matches = placeHolderReg . exec (
289
+ args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_ASSISTANT_ID ]
290
+ ) ;
291
+ if ( matches != null && matches . length > 1 ) {
292
+ const result = await ctx . ui ! . inputText ( {
293
+ name : azureOpenAIAssistantIdQuestion ( ) . name ,
294
+ title : azureOpenAIAssistantIdQuestion ( ) . title as string ,
295
+ validation : ( input : string ) : string | undefined => {
296
+ if ( input . length < 1 ) {
297
+ return getLocalizedString (
298
+ "driver.file.createOrUpdateEnvironmentFile.OpenAIAssistantID.validation"
299
+ ) ;
300
+ }
301
+ } ,
302
+ } ) ;
303
+ if ( result . isErr ( ) ) {
304
+ return result ;
305
+ } else {
306
+ envOutput . set ( matches [ 1 ] , result . value . result ! ) ;
307
+ args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_ASSISTANT_ID ] = result . value . result ! ;
308
+ }
309
+ }
310
+ }
311
+
312
+ if ( args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_EMBEDDING_DEPLOYMENT ] ) {
313
+ const matches = placeHolderReg . exec (
314
+ args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_EMBEDDING_DEPLOYMENT ]
315
+ ) ;
316
+ if ( matches != null && matches . length > 1 ) {
317
+ const result = await ctx . ui ! . inputText ( {
318
+ name : azureOpenAIEmbeddingDeploymentNameQuestion ( ) . name ,
319
+ title : azureOpenAIEmbeddingDeploymentNameQuestion ( ) . title as string ,
320
+ validation : ( input : string ) : string | undefined => {
321
+ if ( input . length < 1 ) {
322
+ return getLocalizedString (
323
+ "driver.file.createOrUpdateEnvironmentFile.OpenAIEmbeddingDeploymentName.validation"
324
+ ) ;
325
+ }
326
+ } ,
327
+ } ) ;
328
+ if ( result . isErr ( ) ) {
329
+ return result ;
330
+ } else {
331
+ envOutput . set ( matches [ 1 ] , result . value . result ! ) ;
332
+ args . envs [ OpenAIEnvironmentVariables . AZURE_OPENAI_EMBEDDING_DEPLOYMENT ] =
333
+ result . value . result ! ;
334
+ }
335
+ }
336
+ }
232
337
return ok ( Void ) ;
233
338
}
234
339
0 commit comments