Skip to content

Commit 3442ba3

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 Fix for custom prompt modal
1 parent f883e3a commit 3442ba3

34 files changed

+967
-101
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: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,30 @@ interface Props {
1616

1717
export const StyledTextArea = styled(Input.TextArea)`
1818
margin-bottom: 10px !important;
19-
min-height: 175px !important;
19+
min-height: 275px !important;
20+
margin-bottom: 10px !important;
21+
padding: 15px 20px !important;
2022
`;
2123

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

64+
console.log('mutation', mutation);
4365
const onFinish = async () => {
4466
const custom_prompt = form.getFieldValue('custom_prompt_instructions');
4567
try {
@@ -67,7 +89,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
6789
<Button onClick={() => setShowModal(true)} style={{ marginLeft: '8px' }}>Generate Custom Prompt</Button>
6890
{showModal &&
6991
(
70-
<Modal
92+
<StyledModal
7193
visible={showModal}
7294
okText={`Generate`}
7395
title={`Generate Cutom Prompt`}
@@ -80,16 +102,18 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
80102
initialValues={initialValues}
81103
onFinish={onSubmit}
82104
style={{ marginTop: '24px' }}
83-
disabled={mutation.isLoading}
105+
disabled={mutation.isPending}
84106
>
85-
{mutation.isLoading &&
107+
{mutation.isPending &&
86108
<Loading />
87109
}
88110

89111
<Form.Item
90112
name='custom_prompt_instructions'
91113
label='Custom Prompt Instructions'
92114
rules={[{ required: true, message: "This field is required." }]}
115+
labelCol={{ span: 24 }}
116+
wrapperCol={{ span: 24 }}
93117
>
94118
<StyledTextArea
95119
autoSize
@@ -98,7 +122,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
98122
</Form.Item>
99123
</Form>
100124

101-
</Modal>
125+
</StyledModal>
102126
)
103127
}
104128
</>

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)