@@ -31,6 +31,8 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
3131 const [ selectedModel , setSelectedModel ] = useState ( null ) ;
3232 const [ textareaValue , setTextareaValue ] = useState ( '' ) ;
3333 const [ modelKey , setModelKey ] = useState ( '' ) ;
34+ const [ bedrockAccessKeyId , setBedrockAccessKeyId ] = useState ( '' ) ;
35+ const [ bedrockSecretAccessKey , setBedrockSecretAccessKey ] = useState ( '' ) ;
3436
3537 const [ flowtestName , setFlowtestName ] = useState ( '' ) ;
3638 const [ selectedCollection , setSelectionCollection ] = useState (
@@ -44,6 +46,8 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
4446 const [ showSelectedModelError , setSelectedModelError ] = useState ( false ) ;
4547 const [ showModelKeyError , setShowModelKeyError ] = useState ( false ) ;
4648 const [ showDescribeFlowError , setShowDescribeFlowError ] = useState ( false ) ;
49+ const [ showBedrockAccessKeyIdError , setShowBedrockAccessKeyIdError ] = useState ( false ) ;
50+ const [ showBedrockSecretAccessKeyError , setShowBedrockSecretAccessKeyError ] = useState ( false ) ;
4751 //const [showFolderSelectionError, setShowFolderSelectionError] = useState(false);
4852
4953 const resetFields = ( ) => {
@@ -60,7 +64,8 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
6064 setShowModelKeyError ( false ) ;
6165 setShowDescribeFlowError ( false ) ;
6266 setSelectedModelError ( false ) ;
63- //setShowFolderSelectionError(false);
67+ setShowBedrockAccessKeyIdError ( false ) ;
68+ setShowBedrockSecretAccessKeyError ( false ) ;
6469 } ;
6570
6671 const containsFolder = ( collection ) => {
@@ -133,7 +138,7 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
133138 { ! collectionId && (
134139 < >
135140 < div >
136- < div className = 'flex justify-between gap-2 transition border rounded bg-background-light hover:bg-background whitespace-nowrap border-cyan-900 text-cyan-900' >
141+ < div className = 'flex justify-between gap-2 transition border rounded whitespace-nowrap border-cyan-900 bg-background-light text-cyan-900 hover:bg-background ' >
137142 < Listbox
138143 value = { selectedCollection }
139144 onChange = { ( value ) => {
@@ -196,7 +201,7 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
196201 </ div >
197202 { ! isEmpty ( selectedCollection ) && containsFolder ( selectedCollection ) ? (
198203 < div >
199- < div className = 'justify-between gap-2 transition border rounded bg-background-light hover:bg-background whitespace-nowrap border-cyan-900 text-cyan-900' >
204+ < div className = 'justify-between gap-2 transition border rounded whitespace-nowrap border-cyan-900 bg-background-light text-cyan-900 hover:bg-background ' >
200205 < Listbox
201206 value = { selectedFolder }
202207 onChange = { ( value ) => {
@@ -270,20 +275,42 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
270275 < div >
271276 { ! isEmpty ( selectedCollection ) && (
272277 < div >
273- < div className = 'justify-between gap-2 transition border rounded bg-background-light hover:bg-background whitespace-nowrap border-cyan-900 text-cyan-900' >
278+ < div className = 'justify-between gap-2 transition border rounded whitespace-nowrap border-cyan-900 bg-background-light text-cyan-900 hover:bg-background ' >
274279 < Listbox
275280 value = { selectedModel }
276281 onChange = { ( m ) => {
277- if ( GENAI_MODELS . openai ) {
278- if (
279- selectedCollection &&
280- selectedCollection . dotEnvVariables &&
281- Object . prototype . hasOwnProperty . call (
282- selectedCollection . dotEnvVariables ,
283- 'OPENAI_APIKEY' ,
284- )
285- ) {
286- setModelKey ( selectedCollection . dotEnvVariables [ 'OPENAI_APIKEY' ] ) ;
282+ if ( selectedCollection && selectedCollection . dotEnvVariables ) {
283+ if ( GENAI_MODELS . openai ) {
284+ if (
285+ Object . prototype . hasOwnProperty . call (
286+ selectedCollection . dotEnvVariables ,
287+ 'OPENAI_APIKEY' ,
288+ )
289+ ) {
290+ setModelKey ( selectedCollection . dotEnvVariables [ 'OPENAI_APIKEY' ] ) ;
291+ }
292+ }
293+
294+ if ( GENAI_MODELS . bedrock_claude ) {
295+ if (
296+ Object . prototype . hasOwnProperty . call (
297+ selectedCollection . dotEnvVariables ,
298+ 'BEDROCK_ACCESS_KEYID' ,
299+ )
300+ ) {
301+ setBedrockAccessKeyId ( selectedCollection . dotEnvVariables [ 'BEDROCK_ACCESS_KEYID' ] ) ;
302+ }
303+
304+ if (
305+ Object . prototype . hasOwnProperty . call (
306+ selectedCollection . dotEnvVariables ,
307+ 'BEDROCK_SECRET_ACCESSKEY' ,
308+ )
309+ ) {
310+ setBedrockSecretAccessKey (
311+ selectedCollection . dotEnvVariables [ 'BEDROCK_SECRET_ACCESSKEY' ] ,
312+ ) ;
313+ }
287314 }
288315 }
289316 setSelectedModel ( m ) ;
@@ -339,12 +366,12 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
339366 ) }
340367 { selectedModel === GENAI_MODELS . openai ? (
341368 < div >
342- < div className = 'flex items-center justify-center w-full h-12 mt-6 text-sm border rounded bg-background-light hover: bg-background border-cyan-900 text-cyan-900' >
369+ < div className = 'flex items-center justify-center w-full h-12 mt-6 text-sm border rounded border-cyan-900 bg-background-light text-cyan-900 hover:bg-background ' >
343370 < label
344371 className = 'flex items-center w-32 h-full px-4 bg-transparent border-r border-cyan-900'
345372 htmlFor = 'openAIkey'
346373 >
347- OpenAI Key
374+ API_KEY
348375 </ label >
349376 < input
350377 id = 'openAIkey'
@@ -366,6 +393,64 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
366393 ) : (
367394 ''
368395 ) }
396+ { selectedModel === GENAI_MODELS . bedrock_claude ? (
397+ < div >
398+ < div className = 'flex items-center justify-center w-full h-12 mt-6 text-sm border rounded border-cyan-900 bg-background-light text-cyan-900 hover:bg-background' >
399+ < label
400+ className = 'flex items-center w-32 h-full px-4 bg-transparent border-r border-cyan-900'
401+ htmlFor = 'bedrockAccessKeyId'
402+ >
403+ ACCESS_KEYID
404+ </ label >
405+ < input
406+ id = 'bedrockAccessKeyId'
407+ type = 'text'
408+ className = 'nodrag nowheel block w-full bg-transparent p-2.5 outline-none'
409+ name = 'keyId'
410+ placeholder = 'Enter your BEDROCK access key id'
411+ value = {
412+ bedrockAccessKeyId . trim ( ) != '' ? bedrockAccessKeyId : 'Enter your BEDROCK access key id'
413+ }
414+ //readOnly='readonly'
415+ onChange = { ( e ) => setBedrockAccessKeyId ( e . target . value ) }
416+ />
417+ </ div >
418+ { bedrockAccessKeyId . trim ( ) === '' && showBedrockAccessKeyIdError ? (
419+ < div className = 'py-2 text-red-600' > { `Please enter ${ selectedModel } access key id` } </ div >
420+ ) : (
421+ ''
422+ ) }
423+ < div className = 'flex items-center justify-center w-full h-12 mt-6 text-sm border rounded border-cyan-900 bg-background-light text-cyan-900 hover:bg-background' >
424+ < label
425+ className = 'flex items-center w-32 h-full px-4 bg-transparent border-r border-cyan-900'
426+ htmlFor = 'bedrockSecretAccessKey'
427+ >
428+ SECRET_ACCESSKEY
429+ </ label >
430+ < input
431+ id = 'bedrockSecretAccessKey'
432+ type = 'text'
433+ className = 'nodrag nowheel block w-full bg-transparent p-2.5 outline-none'
434+ name = 'keyName'
435+ placeholder = 'Enter your BEDROCK secret access key'
436+ value = {
437+ bedrockSecretAccessKey . trim ( ) != ''
438+ ? bedrockSecretAccessKey
439+ : 'Enter your BEDROCK secret access key'
440+ }
441+ //readOnly='readonly'
442+ onChange = { ( e ) => setBedrockSecretAccessKey ( e . target . value ) }
443+ />
444+ </ div >
445+ { bedrockSecretAccessKey . trim ( ) === '' && showBedrockSecretAccessKeyError ? (
446+ < div className = 'py-2 text-red-600' > { `Please enter ${ selectedModel } secret access key` } </ div >
447+ ) : (
448+ ''
449+ ) }
450+ </ div >
451+ ) : (
452+ ''
453+ ) }
369454 < div >
370455 < div className = 'mt-6' >
371456 < Textarea
@@ -425,28 +510,49 @@ const GenerateFlowTestModal = ({ closeFn = () => null, open = false, collectionI
425510 return ;
426511 }
427512
428- if ( ! modelKey || modelKey . trim ( ) === '' ) {
513+ if ( selectedModel === GENAI_MODELS . openai && ( ! modelKey || modelKey . trim ( ) === '' ) ) {
429514 setShowModelKeyError ( true ) ;
430515 return ;
431516 }
432517
518+ if (
519+ selectedModel === GENAI_MODELS . bedrock_claude &&
520+ ( ! bedrockAccessKeyId || bedrockAccessKeyId . trim ( ) === '' )
521+ ) {
522+ setShowBedrockAccessKeyIdError ( true ) ;
523+ return ;
524+ }
525+
526+ if (
527+ selectedModel === GENAI_MODELS . bedrock_claude &&
528+ ( ! bedrockSecretAccessKey || bedrockSecretAccessKey . trim ( ) === '' )
529+ ) {
530+ setShowBedrockSecretAccessKeyError ( true ) ;
531+ return ;
532+ }
533+
433534 if ( ! textareaValue || textareaValue . trim ( ) === '' ) {
434535 setShowDescribeFlowError ( true ) ;
435536 return ;
436537 }
437538
438539 setShowFlowtestNameError ( false ) ;
439540 setShowCollectionSelectionError ( false ) ;
440- //setShowFolderSelectionError(false);
441541 setShowModelKeyError ( false ) ;
542+ setShowBedrockAccessKeyIdError ( false ) ;
543+ setShowBedrockSecretAccessKeyError ( false ) ;
442544 setShowDescribeFlowError ( false ) ;
443545 setSelectedModelError ( false ) ;
444546
547+ const creds =
548+ selectedModel === GENAI_MODELS . openai
549+ ? modelKey
550+ : { accessKeyId : bedrockAccessKeyId , secretAccessKey : bedrockSecretAccessKey } ;
445551 function gen ( ) {
446552 setShowLoader ( true ) ;
447553 promiseWithTimeout (
448- generateFlowData ( textareaValue , selectedModel , modelKey , selectedCollection . id ) ,
449- 30000 ,
554+ generateFlowData ( textareaValue , selectedModel , creds , selectedCollection . id ) ,
555+ 60000 ,
450556 )
451557 . then ( ( flowData ) => {
452558 setShowLoader ( false ) ;
0 commit comments