@@ -21,6 +21,8 @@ import CustomResultTable from './CustomResultTable';
2121import SeedResultTable from './SeedResultTable' ;
2222import { getFilesURL } from '../Evaluator/util' ;
2323import FreeFormTable from './FreeFormTable' ;
24+ import forEach from 'lodash/forEach' ;
25+ import isObject from 'lodash/isObject' ;
2426
2527const { Title } = Typography ;
2628
@@ -118,7 +120,7 @@ const isDemoMode = (numQuestions: number, topics: [], form: FormInstance) => {
118120 return true
119121 }
120122 // set dataset size for SFT & CDG
121- if ( workflow_type === WorkflowType . SUPERVISED_FINE_TUNING && ! isEmpty ( doc_paths ) ) {
123+ if ( workflow_type === WorkflowType . FREE_FORM_DATA_GENERATION && ! isEmpty ( doc_paths ) ) {
122124 const dataset_size = form . getFieldValue ( 'num_questions' ) ;
123125 return dataset_size <= DEMO_MODE_THRESHOLD ;
124126 }
@@ -137,10 +139,9 @@ const Finish = () => {
137139
138140 const doc_paths = formValues . doc_paths ;
139141 if ( Array . isArray ( doc_paths ) && ! isEmpty ( doc_paths ) ) {
140- if ( formValues . workflow_type === WorkflowType . SUPERVISED_FINE_TUNING ) {
142+ if ( formValues . workflow_type === WorkflowType . FREE_FORM_DATA_GENERATION && formValues . use_case === 'custom' ) {
141143 formValues . doc_paths = doc_paths . map ( item => item . value ) ;
142144 } else if ( formValues . workflow_type === WorkflowType . CUSTOM_DATA_GENERATION ) {
143-
144145 formValues . input_path = doc_paths . map ( item => item . value ) ;
145146 delete formValues . doc_paths ;
146147 // delete formValues.examples;
@@ -192,6 +193,23 @@ const Finish = () => {
192193 return ! Array . isArray ( genDatasetResp ?. results )
193194 }
194195
196+ const getRawData = ( genDatasetResp : unknown ) => {
197+ if ( genDatasetResp === null || isEmpty ( genDatasetResp ) ) {
198+ return null ;
199+ }
200+ if ( Array . isArray ( genDatasetResp ?. results ) ) {
201+ return genDatasetResp ?. results ;
202+ } else if ( ! isEmpty ( genDatasetResp ?. results ) && isObject ( genDatasetResp ?. results ) ) {
203+ let data : any [ ] = [ ] ;
204+ const values = Object . values ( genDatasetResp ?. results ) ;
205+ forEach ( values , ( value : any [ ] ) => {
206+ data = data . concat ( value ) ;
207+ } ) ;
208+ return data ;
209+ }
210+ return null ;
211+ }
212+
195213
196214 const formValues = form . getFieldsValue ( true ) ;
197215 let hasDocSeeds = false ;
@@ -298,11 +316,9 @@ const Finish = () => {
298316 </ >
299317 )
300318 }
301- console . log ( 'Finish >> ' ) ;
302- console . log ( 'hasTopics' , hasTopics ( genDatasetResp ) ) ;
303- console . log ( 'formValues' , formValues ) ;
304- console . log ( 'isDemo' , isDemo ) ;
305- console . log ( 'topicTabs' , topicTabs ) ;
319+
320+ const rawData = genDatasetResp !== null && hasTopics ( genDatasetResp ) ?
321+ getRawData ( genDatasetResp ) : genDatasetResp ?. results
306322
307323 return (
308324 < div >
@@ -328,6 +344,9 @@ const Finish = () => {
328344 </ StyledButton >
329345 </ Flex >
330346 ) }
347+ { isDemo && ! isEmpty ( rawData ) && formValues . workflow_type === WorkflowType . FREE_FORM_DATA_GENERATION && formValues . use_case === 'custom' &&
348+ < FreeFormTable data = { rawData } /> }
349+
331350 { ( isDemo && formValues . workflow_type === WorkflowType . FREE_FORM_DATA_GENERATION && formValues . use_case !== 'custom' && hasTopics ( genDatasetResp ) && ! hasDocSeeds ) && (
332351 < TabsContainer title = { 'Generated Dataset' } >
333352 < Tabs tabPosition = 'left' items = { topicTabs } />
0 commit comments