Skip to content
Open
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
28 changes: 27 additions & 1 deletion app/client/src/pages/DataGenerator/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import { usefetchTopics, useFetchDefaultSchema, useFetchDefaultPrompt } from '..
import { MAX_NUM_QUESTION, MIN_SEED_INSTRUCTIONS, MAX_SEED_INSTRUCTIONS } from './constants'
import { Usecases, WorkflowType } from './types';
import { useWizardCtx } from './utils';
import { useDatasetSize, useGetPromptByUseCase } from './hooks';
import { fetchFileContent, useDatasetSize, useGetPromptByUseCase } from './hooks';
import CustomPromptButton from './CustomPromptButton';
import get from 'lodash/get';
import TextArea from 'antd/es/input/TextArea';
import FileSelectorButton from './FileSelectorButton';
import { useMutation } from '@tanstack/react-query';
import first from 'lodash/first';

const { Title } = Typography;

Expand Down Expand Up @@ -97,6 +100,16 @@ const Prompt = () => {
input_value,
output_key
);
const mutation = useMutation({
mutationFn: fetchFileContent
});

useEffect(() => {
if (!isEmpty(mutation.data)) {
setItems(mutation.data)
}
}, [mutation.data]);


useEffect(() => {
if (isError) {
Expand Down Expand Up @@ -193,6 +206,16 @@ const Prompt = () => {
setCustomTopic('');
};

const onAddFiles = (files: File[]) => {
console.log('onAddFiles', files);
if (!isEmpty (files)) {
const file = first(files);
mutation.mutate({
path: get(file, '_path'),
});
};
}

return (
<Row gutter={[50,0]}>
<LeftCol span={17}>
Expand Down Expand Up @@ -302,6 +325,7 @@ const Prompt = () => {
shouldUpdate
// validateTrigger='onBlur'
>
<Flex>
<Select
allowClear
mode="multiple"
Expand Down Expand Up @@ -368,6 +392,8 @@ const Prompt = () => {
disabled: selectedTopics?.length === MAX_SEED_INSTRUCTIONS
}))}
/>
<FileSelectorButton onAddFiles={onAddFiles} workflowType={form.getFieldValue('workflow_type')} />
</Flex>
</StyledFormItem>
<StyledFormItem
name='num_questions'
Expand Down