From 6462dfb5e1e0b7d58105c812f0d28d6d1ae65abf Mon Sep 17 00:00:00 2001 From: Keivan Vosoughi Date: Thu, 24 Jul 2025 22:49:33 -0700 Subject: [PATCH] fix: minor update to DataGenerator Configure component for consistency before PR creation --- .../src/pages/DataGenerator/Configure.tsx | 14 +++-- .../DataGenerator/CustomPromptButton.tsx | 2 +- .../src/pages/DataGenerator/Examples.tsx | 45 ++++++++++------ app/client/src/pages/DataGenerator/hooks.ts | 1 + app/client/src/pages/Home/EvaluateSection.tsx | 25 ++++++--- app/client/src/pages/Home/HomePage.tsx | 51 ++++++++++++++++--- 6 files changed, 103 insertions(+), 35 deletions(-) diff --git a/app/client/src/pages/DataGenerator/Configure.tsx b/app/client/src/pages/DataGenerator/Configure.tsx index e1494352..0bb50ce8 100644 --- a/app/client/src/pages/DataGenerator/Configure.tsx +++ b/app/client/src/pages/DataGenerator/Configure.tsx @@ -13,7 +13,6 @@ import FileSelectorButton from './FileSelectorButton'; import UseCaseSelector from './UseCaseSelector'; import { useLocation, useParams } from 'react-router-dom'; import { WizardModeType } from '../../types'; -import { get } from 'lodash'; const StepContainer = styled(Flex)` @@ -96,10 +95,13 @@ const Configure = () => { validateForm() }, [form, formData]) - // keivan + useEffect(() => { if (formData && formData?.inference_type === undefined && isEmpty(generate_file_name)) { form.setFieldValue('inference_type', ModelProviders.CAII); + setTimeout(() => { + form.setFieldValue('use_case','custom'); + }, 1000); } }, [formData]); @@ -251,18 +253,19 @@ const Configure = () => { {(formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING || formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) && - } + } {( formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING || formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) && ({ @@ -307,6 +310,7 @@ const Configure = () => { label='Input Key' labelCol={labelCol} validateTrigger={['workflow_type', 'onChange']} + tooltip='Choose the key or column from your uploaded file that will be used as the input for data generation.' shouldUpdate rules={[ () => ({ @@ -330,6 +334,7 @@ const Configure = () => { name='output_key' label='Output Key' labelCol={labelCol} + tooltip='Name the value or column where the prompts will be saved. If left blank, this will default to “Prompt".' shouldUpdate > @@ -338,6 +343,7 @@ const Configure = () => { name='output_value' label='Output Value' labelCol={labelCol} + tooltip='Enter the name for the generated values corresponding to each input. If left blank, this will default to “Completion”.' shouldUpdate > diff --git a/app/client/src/pages/DataGenerator/CustomPromptButton.tsx b/app/client/src/pages/DataGenerator/CustomPromptButton.tsx index e3fe10c4..7a725129 100644 --- a/app/client/src/pages/DataGenerator/CustomPromptButton.tsx +++ b/app/client/src/pages/DataGenerator/CustomPromptButton.tsx @@ -157,7 +157,7 @@ const CustomPromptButton: React.FC = ({ model_id, inference_type, caii_en disabled={mutation.isPending} rows={15} autoSize - placeholder={'Enter instructions for a custom prompt'} + placeholder={'Generate prompt from the example data'} /> diff --git a/app/client/src/pages/DataGenerator/Examples.tsx b/app/client/src/pages/DataGenerator/Examples.tsx index 2fc519ff..d0ffe6c3 100644 --- a/app/client/src/pages/DataGenerator/Examples.tsx +++ b/app/client/src/pages/DataGenerator/Examples.tsx @@ -12,7 +12,7 @@ import PCModalContent from './PCModalContent'; import { ExampleType, File, QuestionSolution, WorkflowType } from './types'; import FileSelectorButton from './FileSelectorButton'; -import { fetchFileContent, getExampleType, useGetExamplesByUseCase } from './hooks'; +import { fetchExamplesByUseCase, fetchFileContent, getExampleType, useGetExamplesByUseCase } from './hooks'; import { useState } from 'react'; import FreeFormExampleTable from './FreeFormExampleTable'; import { L } from 'vitest/dist/chunks/reporters.DTtkbAtP.js'; @@ -54,13 +54,21 @@ const Examples: FunctionComponent = () => { const form = Form.useFormInstance(); const [records, setRecords] = useState[]>([]); const workflowType = form.getFieldValue('workflow_type'); - const { examples, isLoading: examplesLoading, refetch } = - useGetExamplesByUseCase(form.getFieldValue('use_case')); const mutation = useMutation({ mutationFn: fetchFileContent }); + const restore_mutation = useMutation({ + mutationFn: fetchExamplesByUseCase + }); + + useEffect(() => { + const useCase = form.getFieldValue('use_case'); + restore_mutation.mutate(useCase); + }, [form.getFieldValue('use_case')]); + + useEffect(() => { const example_path = form.getFieldValue('example_path'); if (!isEmpty(example_path)) { @@ -70,21 +78,28 @@ const Examples: FunctionComponent = () => { } }, [form.getFieldValue('example_path'), form.getFieldValue('workflow_type')]); - useEffect(() => { - console.log('------------------> useEffect') + useEffect(() => { if (!isEmpty(mutation.data)) { form.setFieldValue('examples', mutation.data); if (!isEqual(mutation.data, records)) { setRecords(mutation.data); } - } else if (Array.isArray(examples) && !isEqual(examples, records)) { + } + }, [mutation.data]); + + useEffect(() => { + if (!isEmpty(restore_mutation.data)) { + const examples = get(restore_mutation.data, 'examples', []); form.setFieldValue('examples', examples); setRecords(examples); } - }, [mutation.data, examples]); - + }, [restore_mutation.data]); + const onRestoreDefaults = async() => { + const useCase = form.getFieldValue('use_case'); + restore_mutation.mutate(useCase); + } const onAddFiles = (files: File[]) => { if (!isEmpty (files)) { @@ -104,16 +119,16 @@ const Examples: FunctionComponent = () => { span: 10 }; - const showEmptyState = workflowType === WorkflowType.FREE_FORM_DATA_GENERATION && + const showEmptyState = (workflowType === WorkflowType.FREE_FORM_DATA_GENERATION && isEmpty(mutation.data) && - records.length === 0; + records.length === 0) || + (form.getFieldValue('use_case') === 'custom' && + isEmpty(form.getFieldValue('examples'))); - console.log('examples', form.getFieldValue('examples')); - console.log('records', records); return ( - {examplesLoading && } + {mutation?.isPending || restore_mutation.isPending && }
@@ -149,8 +164,8 @@ const Examples: FunctionComponent = () => { diff --git a/app/client/src/pages/Home/HomePage.tsx b/app/client/src/pages/Home/HomePage.tsx index 7dccb7cd..61385f1c 100644 --- a/app/client/src/pages/Home/HomePage.tsx +++ b/app/client/src/pages/Home/HomePage.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import styled from 'styled-components'; -import { Card, Col, Flex, Layout, Row, Tabs } from 'antd' +import { Button, Card, Col, Flex, Layout, Row, Tabs } from 'antd' import type { TabsProps } from 'antd'; import DatasetsTab from './DatasetsTab'; import EvaluationsTab from './EvaluationsTab'; @@ -10,6 +10,7 @@ import ExportsTab from './ExportsTab'; import TemplatesSection from './TemplatesSection'; import { useNavigate } from 'react-router-dom'; import EvaluateSection from './EvaluateSection'; +import ArrowRightIcon from '../../assets/ic-arrow-right.svg'; const { Content } = Layout; @@ -21,12 +22,23 @@ const StyledContent = styled(Content)` export const HeaderSection = styled.div` display: flex; + flex-direction: column; margin-bottom: 1rem; - height: 100px; + height: 150px; width: 50%; padding: 16px; background-color: #ffffff; cursor: pointer; + .top-section { + display: flex; + flex-direction: row; + } + .bottom-section { + display: flex; + flex-direction: row; + justify-content: flex-end; + margin-top: 8px; + } .left-section { width: 66px; height: 46px; @@ -66,6 +78,7 @@ export const HeaderSection = styled.div` letter-spacing: normal; text-align: left; color: #1b2329; + min-height: 50px; } } .right-section { @@ -114,6 +127,7 @@ const HomePage: React.FC = () => { navigate('/data-generator')}> +
Datasets
@@ -123,16 +137,37 @@ const HomePage: React.FC = () => { Create synthetic data from scratch using examples, documents, seed instructions and AI assisted prompts.
+ + +
+
+ +
+
navigate('/data-augmentation')}> -
- augmentation +
+
+ augmentation +
+
+
Augmentation
+
+ Add synthetic rows or field to existing data to fill gaps or balance datasets such as language translations. +
+
-
-
Augmentation
-
- Add synthetic rows or field to existing data to fill gaps or balance datasets such as language translations. + +
+
+