Skip to content

Commit c1d2cd0

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 c1d2cd0

35 files changed

+921
-114
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: 31 additions & 4 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,6 @@ const Configure = () => {
106116
setSelectedFiles([]);
107117
}
108118
}
109-
110119

111120
return (
112121
<StepContainer justify='center'>
@@ -209,7 +218,8 @@ const Configure = () => {
209218
)}
210219
</Select>
211220
</Form.Item>
212-
{formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING &&
221+
{(formData?.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING ||
222+
formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) &&
213223
<Form.Item
214224
name='use_case'
215225
label='Template'
@@ -234,7 +244,7 @@ const Configure = () => {
234244
formData?.workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
235245
<Form.Item
236246
name='doc_paths'
237-
label='Files'
247+
label='Context'
238248
labelCol={labelCol}
239249
dependencies={['workflow_type']}
240250
shouldUpdate
@@ -319,6 +329,23 @@ const Configure = () => {
319329
<Input />
320330
</Form.Item>
321331
</>}
332+
{/* {formData?.workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION ||
333+
<Form.Item
334+
name='example_path'
335+
label='Example File'
336+
labelCol={labelCol}
337+
dependencies={['workflow_type']}
338+
shouldUpdate
339+
validateTrigger="['onBlur','onChange']"
340+
validateFirst
341+
rules={[]}
342+
>
343+
<Flex>
344+
<Select placeholder={'Select example file'} value={selectedFiles || []} onChange={onFilesChange} allowClear/>
345+
<Input placeholder='Select example file' disabled />
346+
<FileSelectorButton onAddFiles={onAddExampleFiles} workflowType={form.getFieldValue('workflow_type')} />
347+
</Flex>
348+
</Form.Item>} */}
322349
</FormContainer>
323350
</StepContainer>
324351
)

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

Lines changed: 29 additions & 6 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);
@@ -39,7 +60,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
3960
setShowModal(false);
4061
}
4162
}, [mutation.error, mutation.isSuccess]);
42-
63+
4364
const onFinish = async () => {
4465
const custom_prompt = form.getFieldValue('custom_prompt_instructions');
4566
try {
@@ -67,7 +88,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
6788
<Button onClick={() => setShowModal(true)} style={{ marginLeft: '8px' }}>Generate Custom Prompt</Button>
6889
{showModal &&
6990
(
70-
<Modal
91+
<StyledModal
7192
visible={showModal}
7293
okText={`Generate`}
7394
title={`Generate Cutom Prompt`}
@@ -80,16 +101,18 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
80101
initialValues={initialValues}
81102
onFinish={onSubmit}
82103
style={{ marginTop: '24px' }}
83-
disabled={mutation.isLoading}
104+
disabled={mutation.isPending}
84105
>
85-
{mutation.isLoading &&
106+
{mutation.isPending &&
86107
<Loading />
87108
}
88109

89110
<Form.Item
90111
name='custom_prompt_instructions'
91112
label='Custom Prompt Instructions'
92113
rules={[{ required: true, message: "This field is required." }]}
114+
labelCol={{ span: 24 }}
115+
wrapperCol={{ span: 24 }}
93116
>
94117
<StyledTextArea
95118
autoSize
@@ -98,7 +121,7 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
98121
</Form.Item>
99122
</Form>
100123

101-
</Modal>
124+
</StyledModal>
102125
)
103126
}
104127
</>

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)