@@ -2,14 +2,15 @@ import { SUPPORTED_CHART_LIST } from '../../common/vizDataToSpec/constants';
2
2
import { DataItem , GPTChartAdvisorResult , ILLMOptions , LOCATION , SimpleFieldInfo , VizSchema } from '../../typings' ;
3
3
import { checkChartTypeAndCell , vizDataToSpec } from '../../common/vizDataToSpec' ;
4
4
import { parseGPTResponse , requestGPT } from '../utils' ;
5
- import { patchChartTypeAndCell , patchUserInput } from './utils' ;
5
+ import { patchUserInput } from './utils' ;
6
6
import { ChartAdvisorPromptEnglish } from './prompts' ;
7
7
import { chartAdvisorHandler } from '../../common/chartAdvisor' ;
8
8
import { estimateVideoTime } from '../../common/vizDataToSpec/utils' ;
9
9
import { getSchemaFromFieldInfo } from '../../common/schema' ;
10
10
import { queryDatasetWithGPT } from '../dataProcess/query/queryDataset' ;
11
11
import { calculateTokenUsage } from '../..//common/utils' ;
12
12
import { pick } from 'lodash' ;
13
+ import { patchChartTypeAndCell } from './patch' ;
13
14
14
15
export const generateChartWithGPT = async (
15
16
userPrompt : string , //user's intent of visualization, usually aspect in data that they want to visualize
@@ -53,10 +54,11 @@ export const generateChartWithGPT = async (
53
54
const chartTypeRes = resJson [ 'CHART_TYPE' ] . toUpperCase ( ) ;
54
55
const cellRes = resJson [ 'FIELD_MAP' ] ;
55
56
advisorUsage = resJson [ 'usage' ] ;
56
- const patchResult = patchChartTypeAndCell ( chartTypeRes , cellRes , dataset ) ;
57
+ const patchResult = patchChartTypeAndCell ( chartTypeRes , cellRes , dataset , fieldInfo ) ;
57
58
if ( checkChartTypeAndCell ( patchResult . chartTypeNew , patchResult . cellNew , fieldInfo ) ) {
58
59
chartType = patchResult . chartTypeNew ;
59
60
cell = patchResult . cellNew ;
61
+ dataset = patchResult . datasetNew ;
60
62
}
61
63
} catch ( err ) {
62
64
console . warn ( err ) ;
0 commit comments