Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions app/client/src/pages/DataGenerator/Configure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,28 @@ const Configure: FunctionComponent = () => {
const location = useLocation();
const { template_name, generate_file_name } = useParams();
const [wizardModeType, setWizardModeType] = useState(getWizardModeType(location));
console.log('wizardModeType', wizardModeType);

useEffect(() => {
if (wizardModeType === WizardModeType.DATA_AUGMENTATION) {
setWizardModeType(WizardModeType.DATA_AUGMENTATION);
form.setFieldValue('workflow_type', 'freeform');
form.setFieldValue('workflow_type', 'custom');
} else {
setWizardModeType(WizardModeType.DATA_GENERATION);
form.setFieldValue('workflow_type', 'custom');
form.setFieldValue('workflow_type', 'freeform');
}
}, [location, wizardModeType]);

console.log('wizardModeType', wizardModeType);

useEffect(() => {
console.log('useEffect 2');
if (template_name) {
form.setFieldValue('use_case', template_name);
setTimeout(() => {
console.log('setting template name');
form.setFieldValue('use_case', template_name);
}, 1000);

}
}, [template_name]);

Expand All @@ -85,6 +93,7 @@ const Configure: FunctionComponent = () => {
delete values.doc_paths;
delete values.output_key;
delete values.output_value;
console.log('validateForm', values);

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


useEffect(() => {
console.log('useEffect 1');
if (formData && formData?.inference_type === undefined && isEmpty(generate_file_name)) {
form.setFieldValue('inference_type', ModelProviders.CAII);
setTimeout(() => {
form.setFieldValue('use_case','custom');
form.setFieldValue('use_case', template_name ? template_name : 'custom');
}, 1000);
}
}, [formData]);
Expand Down Expand Up @@ -253,18 +263,31 @@ const Configure: FunctionComponent = () => {
)}
</Select>
</Form.Item>
{(formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) &&
<UseCaseSelector form={form} />}
<UseCaseSelector form={form} hidden={formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION} />

{(
formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION ||
(formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
formData?.use_case === 'custom')) &&
<Form.Item
noStyle
shouldUpdate={(prevValues, currentValues) =>
prevValues.doc_paths !== currentValues.doc_paths ||
prevValues.use_case !== currentValues.use_case
}
>
{({}) => {
const useCase = form.getFieldValue('use_case');
if (useCase === 'custom') {

}
return (

<Form.Item
name='doc_paths'
label='Input File'
label={(useCase === 'custom' && formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) ? 'Context' : 'Input File'}
labelCol={labelCol}
dependencies={['workflow_type']}
dependencies={['workflow_type', 'use_case]']}
shouldUpdate
validateTrigger="['onBlur','onChange']"
tooltip='Select a file from your project that contains the initial data to be augmented.'
Expand Down Expand Up @@ -302,9 +325,9 @@ const Configure: FunctionComponent = () => {
>
<Flex>
<Select placeholder={'Select project files'} mode="multiple" value={selectedFiles || []} onChange={onFilesChange} allowClear/>
<FileSelectorButton onAddFiles={onAddFiles} workflowType={form.getFieldValue('workflow_type')} allowFileTypes={['pdf', 'docx']}/>
<FileSelectorButton onAddFiles={onAddFiles} workflowType={form.getFieldValue('workflow_type')} allowFileTypes={['pdf', 'docx', 'json']}/>
</Flex>
</Form.Item>}
</Form.Item>)}}</Form.Item>}
{formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
<>
<Form.Item
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/pages/DataGenerator/Examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const Examples: FunctionComponent = () => {
</Space>
</StyledTitle>
<Flex align='center' gap={15}>
{workflowType === WorkflowType.FREE_FORM_DATA_GENERATION &&
{(workflowType === WorkflowType.CUSTOM_DATA_GENERATION || workflowType === WorkflowType.FREE_FORM_DATA_GENERATION) &&
<>
<Form.Item
name="example_path"
Expand All @@ -158,7 +158,7 @@ const Examples: FunctionComponent = () => {
style={{ display: 'none' }}
shouldUpdate
rules={[
{ required: true }
{ required: false }
]}
>
<Input disabled />
Expand Down
11 changes: 8 additions & 3 deletions app/client/src/pages/DataGenerator/Finish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ const Finish = () => {
}

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

Expand Down Expand Up @@ -297,6 +298,10 @@ const Finish = () => {
</>
)
}
console.log('Finish >> ');
console.log('hasTopics', hasTopics(genDatasetResp));
console.log('formValues', formValues);
console.log('isDemo', isDemo, topicTabs);

return (
<div>
Expand All @@ -322,12 +327,12 @@ const Finish = () => {
</StyledButton>
</Flex>
)}
{isDemo && formValues.workflow_type !== WorkflowType.CUSTOM_DATA_GENERATION && hasTopics(genDatasetResp && !hasDocSeeds) && (
{(isDemo && formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && formValues.use_case !== 'custom' && hasTopics(genDatasetResp) && !hasDocSeeds) && (
<TabsContainer title={'Generated Dataset'}>
<Tabs tabPosition='left' items={topicTabs}/>
</TabsContainer>
)}
{formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION &&
{formValues.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && formValues.use_case === 'custom' &&
<CustomResultTable results={genDatasetResp?.results || []} />
}
{hasDocSeeds && <SeedResultTable results={genDatasetResp?.results || {}} />}
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/pages/DataGenerator/FreeFormTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ interface Props {
}

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

useEffect(() => {
if (!isEmpty(data)) {
console.log('data', data);
const columnNames = Object.keys(first(data));
const columnDefs = columnNames.map((colName) => ({
field: colName,
Expand Down
9 changes: 8 additions & 1 deletion app/client/src/pages/DataGenerator/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const SeedsFormItem = styled(StyledFormItem)`

const Prompt = () => {
const form = Form.useFormInstance();
console.log('form', form);
const selectedTopics = Form.useWatch('topics');
const numQuestions = Form.useWatch('num_questions');
const datasetSize = Form.useWatch('num_questions');
Expand Down Expand Up @@ -108,6 +109,12 @@ const Prompt = () => {
input_value,
output_key
);

console.log('values', form.getFieldsValue(true));
console.log('values', form);
console.log('workflow_type', workflow_type);
console.log('useCase', useCase);
console.log('dataset_size', dataset_size);
const mutation = useMutation({
mutationFn: fetchSeedList
});
Expand Down Expand Up @@ -176,7 +183,7 @@ const Prompt = () => {
isStepValid = true;
}
setIsStepValid(isStepValid)
} else if(!isEmpty(doc_paths) && workflow_type === WorkflowType.SUPERVISED_FINE_TUNING) {
} else if(!isEmpty(doc_paths) && workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) {
setIsStepValid(isNumber(datasetSize) && datasetSize > 0);
} else {
setIsStepValid(true);
Expand Down
6 changes: 5 additions & 1 deletion app/client/src/pages/DataGenerator/Success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ const TopicsTable: FC<TopicsTableProps> = ({ formData, topic }) => {
render: (_text: QuestionSolution, record: QuestionSolution) => <>{record.solution}</>
},
]
const dataSource = formData.results[topic]
console.log('topic', topic);
const dataSource = formData.results[topic];
console.log('dataSource', dataSource);
return (
<StyledTable
columns={cols}
Expand Down Expand Up @@ -87,12 +89,14 @@ interface SuccessProps {
isDemo?: boolean;
}
const Success: FC<SuccessProps> = ({ formData, isDemo = true }) => {
console.log('Success', formData);
const topicTabs = formData?.results && Object.keys(formData.results).map((topic, i) => ({
key: `tab-${i}`,
label: <Popover content={topic}><Text>{topic}</Text></Popover>,
value: topic.replace(/\n/g, ' '),
children: <TopicsTable formData={formData} topic={topic} />
}));
console.log('topicTabs', topicTabs);
const nextStepsList = [
{
avatar: '',
Expand Down
4 changes: 3 additions & 1 deletion app/client/src/pages/DataGenerator/UseCaseSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import get from "lodash/get";

interface Props {
form: FormInstance<any>;
hidden?: boolean;
}


const UseCaseSelector: FunctionComponent<Props> = ({ form }) => {
const UseCaseSelector: FunctionComponent<Props> = ({ form, hidden }) => {
const [useCases, setUseCases] = useState<UseCase[]>([]);
const useCasesReq = useGetUseCases();

Expand Down Expand Up @@ -45,6 +46,7 @@ const UseCaseSelector: FunctionComponent<Props> = ({ form }) => {
labelCol={{
span: 8
}}
hidden={hidden}
shouldUpdate
>
<Select placeholder={'Select a template'} onChange={onChange}>
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/pages/DataGenerator/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ export const useDatasetSize = (
input_value: string,
output_key: string
) => {
if (workflow_type !== WorkflowType.CUSTOM_DATA_GENERATION || isEmpty(doc_paths)) {
if (workflow_type !== WorkflowType.CUSTOM_DATA_GENERATION && isEmpty(doc_paths)) {
return {
data: 0
}
}
const params = {
input_path: doc_paths.map(item => item.value),
input_path: Array.isArray(doc_paths) ? doc_paths.map(item => item.value) : [],
input_key,
input_value,
output_key
Expand Down
13 changes: 6 additions & 7 deletions app/client/src/pages/DataGenerator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ export const getHttpStatusCodeVerb = (statusCode: number) => {

export const getWizardModeType = (location: any) => {
const pathname = location?.pathname || '';
switch (pathname) {
case '/data-augmentation':
return WizardModeType.DATA_AUGMENTATION;
case '/data-generator':
return WizardModeType.DATA_GENERATION;
default:
return null;
console.log('pathname', pathname);
if (pathname.includes('/data-augmentation')) {
return WizardModeType.DATA_AUGMENTATION;
} else if (pathname.includes('/data-generator')) {
return WizardModeType.DATA_GENERATION;
}
return null;
}