11import endsWith from 'lodash/endsWith' ;
22import isEmpty from 'lodash/isEmpty' ;
3+ import isFunction from 'lodash/isFunction' ;
34import { useEffect , useState } from 'react' ;
45import { Flex , Form , Input , Select , Typography } from 'antd' ;
56import styled from 'styled-components' ;
@@ -10,6 +11,7 @@ import { ModelProviders, ModelProvidersDropdownOpts } from './types';
1011import { useWizardCtx } from './utils' ;
1112import FileSelectorButton from './FileSelectorButton' ;
1213
14+
1315const StepContainer = styled ( Flex ) `
1416 background: white;
1517 padding: 40px 0px;
@@ -31,7 +33,8 @@ export const USECASE_OPTIONS = [
3133
3234export const WORKFLOW_OPTIONS = [
3335 { label : 'Supervised Fine-Tuning' , value : 'supervised-fine-tuning' } ,
34- { label : 'Custom Data Generation' , value : 'custom' }
36+ { label : 'Custom Data Generation' , value : 'custom' } ,
37+ { label : 'Freefrom Data Generation' , value : 'freeform' }
3538] ;
3639
3740export const MODEL_TYPE_OPTIONS : ModelProvidersDropdownOpts = [
@@ -55,16 +58,23 @@ const Configure = () => {
5558 delete values . output_value ;
5659
5760 const allFieldsFilled = Object . values ( values ) . every ( value => Boolean ( value ) ) ;
58- if ( allFieldsFilled ) {
59- setIsStepValid && setIsStepValid ( true )
60- } else {
61- setIsStepValid && setIsStepValid ( false )
61+ if ( allFieldsFilled && isFunction ( setIsStepValid ) ) {
62+ setIsStepValid ( true )
63+ } else if ( isFunction ( setIsStepValid ) ) {
64+ setIsStepValid ( false )
6265 }
6366 }
6467 useEffect ( ( ) => {
6568 validateForm ( )
6669 } , [ form , formData ] )
6770
71+ // keivan
72+ useEffect ( ( ) => {
73+ if ( formData && formData ?. inference_type === undefined ) {
74+ form . setFieldValue ( 'inference_type' , ModelProviders . CAII ) ;
75+ }
76+ } , [ formData ] ) ;
77+
6878 const labelCol = {
6979 span : 8
7080 } ;
@@ -83,7 +93,7 @@ const Configure = () => {
8393 form . setFieldValue ( 'doc_paths' , paths ) ;
8494 }
8595
86- const onFilesChange = ( selections : any ) => {
96+ const onFilesChange = ( selections : unknown ) => {
8797 if ( Array . isArray ( selections ) && ! isEmpty ( selections ) ) {
8898 const paths = selections . map ( ( file : File ) => (
8999 {
@@ -106,7 +116,6 @@ const Configure = () => {
106116 setSelectedFiles ( [ ] ) ;
107117 }
108118 }
109-
110119
111120 return (
112121 < StepContainer justify = 'center' >
@@ -209,7 +218,8 @@ const Configure = () => {
209218 ) }
210219 </ Select >
211220 </ Form . Item >
212- { formData ?. workflow_type === WorkflowType . SUPERVISED_FINE_TUNING &&
221+ { ( formData ?. workflow_type === WorkflowType . SUPERVISED_FINE_TUNING ||
222+ formData ?. workflow_type === WorkflowType . FREE_FORM_DATA_GENERATION ) &&
213223 < Form . Item
214224 name = 'use_case'
215225 label = 'Template'
@@ -234,7 +244,7 @@ const Configure = () => {
234244 formData ?. workflow_type === WorkflowType . CUSTOM_DATA_GENERATION ) &&
235245 < Form . Item
236246 name = 'doc_paths'
237- label = 'Files '
247+ label = 'Context '
238248 labelCol = { labelCol }
239249 dependencies = { [ 'workflow_type' ] }
240250 shouldUpdate
@@ -319,6 +329,23 @@ const Configure = () => {
319329 < Input />
320330 </ Form . Item >
321331 </ > }
332+ { /* {formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION ||
333+ <Form.Item
334+ name='example_path'
335+ label='Example File'
336+ labelCol={labelCol}
337+ dependencies={['workflow_type']}
338+ shouldUpdate
339+ validateTrigger="['onBlur','onChange']"
340+ validateFirst
341+ rules={[]}
342+ >
343+ <Flex>
344+ <Select placeholder={'Select example file'} value={selectedFiles || []} onChange={onFilesChange} allowClear/>
345+ <Input placeholder='Select example file' disabled />
346+ <FileSelectorButton onAddFiles={onAddExampleFiles} workflowType={form.getFieldValue('workflow_type')} />
347+ </Flex>
348+ </Form.Item>} */ }
322349 </ FormContainer >
323350 </ StepContainer >
324351 )
0 commit comments