Skip to content

Commit 0cca5de

Browse files
author
Keivan Vosoughi
committed
Regenerate Issues using PDF Files
1 parent 17d811b commit 0cca5de

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

app/client/src/pages/DataGenerator/Configure.tsx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,16 @@ const Configure: FunctionComponent = () => {
6666
}
6767
}, [location, wizardModeType]);
6868

69+
console.log('wizardModeType', wizardModeType);
70+
6971
useEffect(() => {
72+
console.log('useEffect 2');
7073
if (template_name) {
71-
form.setFieldValue('use_case', template_name);
74+
setTimeout(() => {
75+
console.log('setting template name');
76+
form.setFieldValue('use_case', template_name);
77+
}, 1000);
78+
7279
}
7380
}, [template_name]);
7481

@@ -99,10 +106,11 @@ const Configure: FunctionComponent = () => {
99106

100107

101108
useEffect(() => {
109+
console.log('useEffect 1');
102110
if (formData && formData?.inference_type === undefined && isEmpty(generate_file_name)) {
103111
form.setFieldValue('inference_type', ModelProviders.CAII);
104112
setTimeout(() => {
105-
form.setFieldValue('use_case','custom');
113+
form.setFieldValue('use_case', template_name ? template_name : 'custom');
106114
}, 1000);
107115
}
108116
}, [formData]);
@@ -254,17 +262,32 @@ const Configure: FunctionComponent = () => {
254262
</Select>
255263
</Form.Item>
256264
{(formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
257-
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) &&
265+
formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
258266
<UseCaseSelector form={form} />}
259267

260268
{(
261-
formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
262-
formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
269+
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION ||
270+
(formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
271+
formData?.use_case === 'custom')) &&
272+
<Form.Item
273+
noStyle
274+
shouldUpdate={(prevValues, currentValues) =>
275+
prevValues.doc_paths !== currentValues.doc_paths ||
276+
prevValues.use_case !== currentValues.use_case
277+
}
278+
>
279+
{({}) => {
280+
const useCase = form.getFieldValue('use_case');
281+
if (useCase === 'custom') {
282+
283+
}
284+
return (
285+
263286
<Form.Item
264287
name='doc_paths'
265-
label='Input File'
288+
label={(useCase === 'custom' && formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) ? 'Context' : 'Input File'}
266289
labelCol={labelCol}
267-
dependencies={['workflow_type']}
290+
dependencies={['workflow_type', 'use_case]']}
268291
shouldUpdate
269292
validateTrigger="['onBlur','onChange']"
270293
tooltip='Select a file from your project that contains the initial data to be augmented.'
@@ -302,10 +325,10 @@ const Configure: FunctionComponent = () => {
302325
>
303326
<Flex>
304327
<Select placeholder={'Select project files'} mode="multiple" value={selectedFiles || []} onChange={onFilesChange} allowClear/>
305-
<FileSelectorButton onAddFiles={onAddFiles} workflowType={form.getFieldValue('workflow_type')} allowFileTypes={['pdf', 'docx']}/>
328+
<FileSelectorButton onAddFiles={onAddFiles} workflowType={form.getFieldValue('workflow_type')} allowFileTypes={['pdf', 'docx', 'json']}/>
306329
</Flex>
307-
</Form.Item>}
308-
{formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
330+
</Form.Item>)}}</Form.Item>}
331+
{formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION &&
309332
<>
310333
<Form.Item
311334
name='input_key'

app/client/src/pages/DataGenerator/Examples.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const Examples: FunctionComponent = () => {
149149
</Space>
150150
</StyledTitle>
151151
<Flex align='center' gap={15}>
152-
{workflowType === WorkflowType.FREE_FORM_DATA_GENERATION &&
152+
{(workflowType === WorkflowType.FREE_FORM_DATA_GENERATION || workflowType === WorkflowType.CUSTOM_DATA_GENERATION) &&
153153
<>
154154
<Form.Item
155155
name="example_path"

app/client/src/pages/DataGenerator/Prompt.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ const Prompt = () => {
293293

294294

295295
</div>
296-
{((workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && !isEmpty(doc_paths)) ||
296+
{((workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION && !isEmpty(doc_paths)) ||
297297
(workflow_type === WorkflowType.SUPERVISED_FINE_TUNING && !isEmpty(doc_paths))) &&
298298
<StyledFormItem
299299
name={'num_questions'}

app/client/src/pages/DataGenerator/utils.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ export const getHttpStatusCodeVerb = (statusCode: number) => {
109109

110110
export const getWizardModeType = (location: any) => {
111111
const pathname = location?.pathname || '';
112-
switch (pathname) {
113-
case '/data-augmentation':
114-
return WizardModeType.DATA_AUGMENTATION;
115-
case '/data-generator':
116-
return WizardModeType.DATA_GENERATION;
117-
default:
118-
return null;
112+
console.log('pathname', pathname);
113+
if (pathname.includes('/data-augmentation')) {
114+
return WizardModeType.DATA_AUGMENTATION;
115+
} else if (pathname.includes('/data-generator')) {
116+
return WizardModeType.DATA_GENERATION;
119117
}
118+
return null;
120119
}

0 commit comments

Comments
 (0)