Skip to content

Commit 3162a1e

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

File tree

7 files changed

+57
-24
lines changed

7 files changed

+57
-24
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: 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.CUSTOM_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: 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/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)