Skip to content

Commit b1bd7fe

Browse files
author
Keivan Vosoughi
committed
Initial Checkin for free form data generation
Add Free Form Workflow Type Add Free From Prompt Add use case for free form workflow type Usecase fix for freeform Show Seed Instructions for FreeForm Ftech File Content Add AG Grid Add Modules Add Themes Adding FreeFormTable Fix Examples Table for Freeform Dataset Fix Dataset Details Page for Freeforms Add Dataset Viewer Hide Exmaples Buttons for Freeforms Fix for Examples in Dataset Details Page (freeform) Update Examples Message Fix for very long seeds Fix for Dataset Details Page Fix for Freeform Table in Results Page Adding Re-generate Dataset Changes Add Evaluation for Freeforms
1 parent f883e3a commit b1bd7fe

34 files changed

+960
-98
lines changed

app/client/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default tseslint.config(
2323
'warn',
2424
{ allowConstantExport: true },
2525
],
26+
'@typescript-eslint/no-explicit-any': ['warn', { 'fixToUnknown': true, 'ignoreRestArgs': false }]
2627
},
2728
},
2829
)

app/client/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"@mui/icons-material": "6.1.7",
1717
"@mui/material": "6.1.7",
1818
"@tanstack/react-query": "5.66.0",
19+
"ag-grid-community": "33.2.4",
20+
"ag-grid-react":"33.2.4",
1921
"antd": "5.22.1",
2022
"axios": "1.6.7",
2123
"lodash": "4.17.21",

app/client/src/api/api.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ export const useFetchModels = (): UseFetchApiReturn<FetchModelsResp> => {
2727
return useFetch(url);
2828
}
2929

30-
export const useFetchDefaultPrompt = (useCase: string): UseFetchApiReturn<FetchDefaultPromptResp> => {
31-
const url = `${baseUrl}/${isEmpty(useCase) ? 'custom' : useCase}/gen_prompt`;
30+
export const useFetchDefaultPrompt = (useCase: string, workflowType?: WorkerType): UseFetchApiReturn<FetchDefaultPromptResp> => {
31+
let url = `${baseUrl}/${isEmpty(useCase) ? 'custom' : useCase}/gen_prompt`;
32+
if (workflowType && workflowType === 'freeform') {
33+
url = `${baseUrl}/${isEmpty(useCase) ? 'custom' : useCase}/gen_freeform_prompt`;
34+
}
3235
return useFetch(url);
3336
}
3437

@@ -42,7 +45,7 @@ export const useFetchDefaultModelParams = (): UseFetchApiReturn<FetchDefaultPara
4245
return useFetch(url);
4346
}
4447

45-
export const useTriggerDatagen = <T>() => {
46-
const genDatasetUrl = `${import.meta.env.VITE_AMP_URL}/synthesis/generate`;
48+
export const useTriggerDatagen = <T>(workflow_type: string) => {
49+
const genDatasetUrl = `${import.meta.env.VITE_AMP_URL}/synthesis/${workflow_type === 'freeform' ? 'freeform' : 'generate'}`;
4750
return usePostApi<T>(genDatasetUrl);
4851
}

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

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { MODEL_PROVIDER_LABELS } from './constants';
99
import { ModelProviders, ModelProvidersDropdownOpts } from './types';
1010
import { useWizardCtx } from './utils';
1111
import FileSelectorButton from './FileSelectorButton';
12+
import first from 'lodash/first';
13+
import get from 'lodash/get';
1214

1315
const StepContainer = styled(Flex)`
1416
background: white;
@@ -31,7 +33,8 @@ export const USECASE_OPTIONS = [
3133

3234
export const WORKFLOW_OPTIONS = [
3335
{ label: 'Supervised Fine-Tuning', value: 'supervised-fine-tuning' },
34-
{ label: 'Custom Data Generation', value: 'custom' }
36+
{ label: 'Custom Data Generation', value: 'custom' },
37+
{ label: 'Freefrom Data Generation', value: 'freeform' }
3538
];
3639

3740
export const MODEL_TYPE_OPTIONS: ModelProvidersDropdownOpts = [
@@ -65,6 +68,13 @@ const Configure = () => {
6568
validateForm()
6669
}, [form, formData])
6770

71+
// keivan
72+
useEffect(() => {
73+
if (formData && formData?.inference_type === undefined) {
74+
form.setFieldValue('inference_type', ModelProviders.CAII);
75+
}
76+
}, [formData]);
77+
6878
const labelCol = {
6979
span: 8
7080
};
@@ -106,7 +116,16 @@ const Configure = () => {
106116
setSelectedFiles([]);
107117
}
108118
}
119+
120+
const onAddExampleFiles = (files: File[]) => {
121+
console.log('onAddExampleFiles', files);
122+
if (!isEmpty(files)) {
123+
const file = first(files);
124+
form.setFieldValue('example_path', get(file, '_path'));
125+
}
126+
}
109127

128+
console.log('formData', formData);
110129

111130
return (
112131
<StepContainer justify='center'>
@@ -209,7 +228,8 @@ const Configure = () => {
209228
)}
210229
</Select>
211230
</Form.Item>
212-
{formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING &&
231+
{(formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
232+
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) &&
213233
<Form.Item
214234
name='use_case'
215235
label='Template'
@@ -234,7 +254,7 @@ const Configure = () => {
234254
formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
235255
<Form.Item
236256
name='doc_paths'
237-
label='Files'
257+
label='Context'
238258
labelCol={labelCol}
239259
dependencies={['workflow_type']}
240260
shouldUpdate
@@ -319,6 +339,23 @@ const Configure = () => {
319339
<Input />
320340
</Form.Item>
321341
</>}
342+
{/* {formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION ||
343+
<Form.Item
344+
name='example_path'
345+
label='Example File'
346+
labelCol={labelCol}
347+
dependencies={['workflow_type']}
348+
shouldUpdate
349+
validateTrigger="['onBlur','onChange']"
350+
validateFirst
351+
rules={[]}
352+
>
353+
<Flex>
354+
<Select placeholder={'Select example file'} value={selectedFiles || []} onChange={onFilesChange} allowClear/>
355+
<Input placeholder='Select example file' disabled />
356+
<FileSelectorButton onAddFiles={onAddExampleFiles} workflowType={form.getFieldValue('workflow_type')} />
357+
</Flex>
358+
</Form.Item>} */}
322359
</FormContainer>
323360
</StepContainer>
324361
)

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ export const StyledTextArea = styled(Input.TextArea)`
1919
min-height: 175px !important;
2020
`;
2121

22+
const StyledModal = styled(Modal)`
23+
.ant-modal-content {
24+
max-height: 90vh;
25+
// height: 760px;
26+
height: 85vh;
27+
width: 750px;
28+
.ant-modal-body {
29+
padding-top: 0;
30+
min-height: 70vh;
31+
}
32+
}
33+
// .ant-modal-content {
34+
// border-radius: 8px;
35+
// box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.1);
36+
// background-color: #ffffff;
37+
// padding: 24px;
38+
// }
39+
`
40+
2241
const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_endpoint, use_case, setPrompt }) => {
2342
const [form] = Form.useForm();
2443
const [showModal, setShowModal] = useState(false);
@@ -40,6 +59,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
4059
}
4160
}, [mutation.error, mutation.isSuccess]);
4261

62+
console.log('mutation', mutation);
4363
const onFinish = async () => {
4464
const custom_prompt = form.getFieldValue('custom_prompt_instructions');
4565
try {
@@ -67,7 +87,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
6787
<Button onClick={() => setShowModal(true)} style={{ marginLeft: '8px' }}>Generate Custom Prompt</Button>
6888
{showModal &&
6989
(
70-
<Modal
90+
<StyledModal
7191
visible={showModal}
7292
okText={`Generate`}
7393
title={`Generate Cutom Prompt`}
@@ -98,7 +118,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
98118
</Form.Item>
99119
</Form>
100120

101-
</Modal>
121+
</StyledModal>
102122
)
103123
}
104124
</>

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Finish from './Finish';
1717

1818
import { DataGenWizardSteps, WizardStepConfig, WorkflowType } from './types';
1919
import { WizardCtx } from './utils';
20+
import { useGetDatasetDetails } from '../DatasetDetails/hooks';
2021

2122
const { Content } = Layout;
2223
// const { Title } = Typography;
@@ -98,10 +99,14 @@ const DataGenerator = () => {
9899
const [isStepValid, setIsStepValid] = useState<boolean>(false);
99100
// Data passed from listing table to prepopulate form
100101
const location = useLocation();
101-
console.log('DatGenerator >> location?.state?.data:', location?.state?.data);
102+
console.log('location?.state?.data:', location?.state?.data);
102103
const initialData = location?.state?.data;
104+
105+
const datasetDetailsReq = location?.state?.data && useGetDatasetDetails(location?.state?.data?.generate_file_name)
103106
if (initialData?.technique) {
104-
initialData.workflow_type = initialData?.technique === 'sft' ? WorkflowType.SUPERVISED_FINE_TUNING :
107+
initialData.workflow_type = initialData?.technique === 'sft' ?
108+
WorkflowType.SUPERVISED_FINE_TUNING :
109+
initialData?.technique === 'freeform' ? WorkflowType.FREE_FORM_DATA_GENERATION :
105110
WorkflowType.CUSTOM_DATA_GENERATION;
106111
}
107112
if (Array.isArray(initialData?.doc_paths) && !isEmpty(initialData?.doc_paths) ) {
@@ -111,6 +116,12 @@ const DataGenerator = () => {
111116
}));
112117

113118
}
119+
120+
if (datasetDetailsReq && datasetDetailsReq.data &&
121+
!isEmpty(datasetDetailsReq?.data?.generate_file_name)) {
122+
initialData.example_path = initialData?.example_path;
123+
}
124+
114125
if (Array.isArray(initialData?.input_paths) && !isEmpty(initialData?.input_paths) ) {
115126
initialData.doc_paths = initialData?.input_paths.map((path: string) => ({
116127
value: path,

0 commit comments

Comments
 (0)