Skip to content

Commit 3b45513

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

File tree

7 files changed

+66
-25
lines changed

7 files changed

+66
-25
lines changed

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

Lines changed: 34 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

@@ -85,6 +92,7 @@ const Configure: FunctionComponent = () => {
8592
delete values.doc_paths;
8693
delete values.output_key;
8794
delete values.output_value;
95+
console.log('validateForm', values);
8896

8997
const allFieldsFilled = Object.values(values).every(value => Boolean(value));
9098
if (allFieldsFilled && isFunction(setIsStepValid)) {
@@ -99,10 +107,11 @@ const Configure: FunctionComponent = () => {
99107

100108

101109
useEffect(() => {
110+
console.log('useEffect 1');
102111
if (formData && formData?.inference_type === undefined && isEmpty(generate_file_name)) {
103112
form.setFieldValue('inference_type', ModelProviders.CAII);
104113
setTimeout(() => {
105-
form.setFieldValue('use_case','custom');
114+
form.setFieldValue('use_case', template_name ? template_name : 'custom');
106115
}, 1000);
107116
}
108117
}, [formData]);
@@ -254,17 +263,32 @@ const Configure: FunctionComponent = () => {
254263
</Select>
255264
</Form.Item>
256265
{(formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
257-
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) &&
266+
formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
258267
<UseCaseSelector form={form} />}
259268

260269
{(
261-
formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
262-
formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
270+
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION ||
271+
(formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
272+
formData?.use_case === 'custom')) &&
273+
<Form.Item
274+
noStyle
275+
shouldUpdate={(prevValues, currentValues) =>
276+
prevValues.doc_paths !== currentValues.doc_paths ||
277+
prevValues.use_case !== currentValues.use_case
278+
}
279+
>
280+
{({}) => {
281+
const useCase = form.getFieldValue('use_case');
282+
if (useCase === 'custom') {
283+
284+
}
285+
return (
286+
263287
<Form.Item
264288
name='doc_paths'
265-
label='Input File'
289+
label={(useCase === 'custom' && formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) ? 'Context' : 'Input File'}
266290
labelCol={labelCol}
267-
dependencies={['workflow_type']}
291+
dependencies={['workflow_type', 'use_case]']}
268292
shouldUpdate
269293
validateTrigger="['onBlur','onChange']"
270294
tooltip='Select a file from your project that contains the initial data to be augmented.'
@@ -302,10 +326,10 @@ const Configure: FunctionComponent = () => {
302326
>
303327
<Flex>
304328
<Select placeholder={'Select project files'} mode="multiple" value={selectedFiles || []} onChange={onFilesChange} allowClear/>
305-
<FileSelectorButton onAddFiles={onAddFiles} workflowType={form.getFieldValue('workflow_type')} allowFileTypes={['pdf', 'docx']}/>
329+
<FileSelectorButton onAddFiles={onAddFiles} workflowType={form.getFieldValue('workflow_type')} allowFileTypes={['pdf', 'docx', 'json']}/>
306330
</Flex>
307-
</Form.Item>}
308-
{formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
331+
</Form.Item>)}}</Form.Item>}
332+
{formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION &&
309333
<>
310334
<Form.Item
311335
name='input_key'

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

Lines changed: 2 additions & 2 deletions
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.CUSTOM_DATA_GENERATION || workflowType === WorkflowType.FREE_FORM_DATA_GENERATION) &&
153153
<>
154154
<Form.Item
155155
name="example_path"
@@ -158,7 +158,7 @@ const Examples: FunctionComponent = () => {
158158
style={{ display: 'none' }}
159159
shouldUpdate
160160
rules={[
161-
{ required: true }
161+
{ required: false }
162162
]}
163163
>
164164
<Input disabled />

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ const Finish = () => {
202202
}
203203

204204
let topicTabs = [];
205-
if (!hasDocSeeds && formValues.workflow_type !== WorkflowType.CUSTOM_DATA_GENERATION &&
205+
console.log('Preparing topics...', formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION)
206+
if (!hasDocSeeds && formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && formValues.use_case !== 'custom' &&
206207
hasTopics(genDatasetResp) && !isEmpty(genDatasetResp?.results)) {
207208
const values = Object.values(genDatasetResp?.results);
208209

@@ -297,6 +298,10 @@ const Finish = () => {
297298
</>
298299
)
299300
}
301+
console.log('Finish >> ');
302+
console.log('hasTopics', hasTopics(genDatasetResp));
303+
console.log('formValues', formValues);
304+
console.log('isDemo', isDemo, topicTabs);
300305

301306
return (
302307
<div>
@@ -322,12 +327,12 @@ const Finish = () => {
322327
</StyledButton>
323328
</Flex>
324329
)}
325-
{isDemo && formValues.workflow_type !== WorkflowType.CUSTOM_DATA_GENERATION && hasTopics(genDatasetResp && !hasDocSeeds) && (
330+
{(isDemo && formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && formValues.use_case !== 'custom' && hasTopics(genDatasetResp) && !hasDocSeeds) && (
326331
<TabsContainer title={'Generated Dataset'}>
327332
<Tabs tabPosition='left' items={topicTabs}/>
328333
</TabsContainer>
329334
)}
330-
{formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
335+
{formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && formValues.use_case === 'custom' &&
331336
<CustomResultTable results={genDatasetResp?.results || []} />
332337
}
333338
{hasDocSeeds && <SeedResultTable results={genDatasetResp?.results || {}} />}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ interface Props {
4545
}
4646

4747
const FreeFormTable: FunctionComponent<Props> = ({ data }) => {
48+
console.log('FreeFormTable', data);
4849
const [colDefs, setColDefs] = useState([]);
4950
const [rowData, setRowData] = useState([]);
5051

5152
useEffect(() => {
5253
if (!isEmpty(data)) {
54+
console.log('data', data);
5355
const columnNames = Object.keys(first(data));
5456
const columnDefs = columnNames.map((colName) => ({
5557
field: colName,

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const SeedsFormItem = styled(StyledFormItem)`
7676

7777
const Prompt = () => {
7878
const form = Form.useFormInstance();
79+
console.log('form', form);
7980
const selectedTopics = Form.useWatch('topics');
8081
const numQuestions = Form.useWatch('num_questions');
8182
const datasetSize = Form.useWatch('num_questions');
@@ -108,6 +109,12 @@ const Prompt = () => {
108109
input_value,
109110
output_key
110111
);
112+
113+
console.log('values', form.getFieldsValue(true));
114+
console.log('values', form);
115+
console.log('workflow_type', workflow_type);
116+
console.log('useCase', useCase);
117+
console.log('dataset_size', dataset_size);
111118
const mutation = useMutation({
112119
mutationFn: fetchSeedList
113120
});
@@ -176,7 +183,7 @@ const Prompt = () => {
176183
isStepValid = true;
177184
}
178185
setIsStepValid(isStepValid)
179-
} else if(!isEmpty(doc_paths) && workflow_type === WorkflowType.SUPERVISED_FINE_TUNING) {
186+
} else if(!isEmpty(doc_paths) && workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) {
180187
setIsStepValid(isNumber(datasetSize) && datasetSize > 0);
181188
} else {
182189
setIsStepValid(true);
@@ -293,7 +300,7 @@ const Prompt = () => {
293300

294301

295302
</div>
296-
{((workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && !isEmpty(doc_paths)) ||
303+
{((workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION && !isEmpty(doc_paths)) ||
297304
(workflow_type === WorkflowType.SUPERVISED_FINE_TUNING && !isEmpty(doc_paths))) &&
298305
<StyledFormItem
299306
name={'num_questions'}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ const TopicsTable: FC<TopicsTableProps> = ({ formData, topic }) => {
5252
render: (_text: QuestionSolution, record: QuestionSolution) => <>{record.solution}</>
5353
},
5454
]
55-
const dataSource = formData.results[topic]
55+
console.log('topic', topic);
56+
const dataSource = formData.results[topic];
57+
console.log('dataSource', dataSource);
5658
return (
5759
<StyledTable
5860
columns={cols}
@@ -87,12 +89,14 @@ interface SuccessProps {
8789
isDemo?: boolean;
8890
}
8991
const Success: FC<SuccessProps> = ({ formData, isDemo = true }) => {
92+
console.log('Success', formData);
9093
const topicTabs = formData?.results && Object.keys(formData.results).map((topic, i) => ({
9194
key: `tab-${i}`,
9295
label: <Popover content={topic}><Text>{topic}</Text></Popover>,
9396
value: topic.replace(/\n/g, ' '),
9497
children: <TopicsTable formData={formData} topic={topic} />
9598
}));
99+
console.log('topicTabs', topicTabs);
96100
const nextStepsList = [
97101
{
98102
avatar: '',

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)