|
1 | 1 | /* eslint-disable no-console */
|
2 | 2 | import React, { useState, useCallback, useEffect } from 'react';
|
3 | 3 | import '../index.scss';
|
4 |
| -import { Avatar, Input, Divider, Button, InputNumber, Select, Radio, Modal } from '@arco-design/web-react'; |
| 4 | +import { Avatar, Input, Divider, Button, InputNumber, Select, Radio, Modal, Checkbox } from '@arco-design/web-react'; |
5 | 5 | import VMind from '../../../../../src/index';
|
6 | 6 | import { Model } from '../../../../../src/index';
|
7 | 7 | import {
|
@@ -67,6 +67,7 @@ export function DataInput(props: IPropsType) {
|
67 | 67 | const [visible, setVisible] = React.useState(false);
|
68 | 68 | const [url, setUrl] = React.useState(ModelConfigMap[model]?.url ?? OPENAI_API_URL);
|
69 | 69 | const [apiKey, setApiKey] = React.useState(ModelConfigMap[model]?.key);
|
| 70 | + const [enableAnnotation, setEnableAnnotation] = React.useState(false); |
70 | 71 |
|
71 | 72 | const [loading, setLoading] = useState<boolean>(false);
|
72 | 73 |
|
@@ -102,24 +103,29 @@ export function DataInput(props: IPropsType) {
|
102 | 103 | lofOutlier: { threshold: 2 },
|
103 | 104 | statisticsBase: { defaultLeftAxisName: '左轴', defaultRightAxisName: '右轴' }
|
104 | 105 | },
|
| 106 | + // usePolish: false, |
105 | 107 | detailMaxNum: [
|
106 | 108 | { types: ['outlier', 'pair_outlier', 'extreme_value', 'turning_point', 'majority_value'], maxNum: 3 },
|
107 | 109 | { types: ['abnormal_band'], maxNum: 3 },
|
108 | 110 | { types: ['correlation'], maxNum: 2 },
|
109 | 111 | { types: ['overall_trend'], maxNum: 2 },
|
110 | 112 | { types: ['abnormal_trend'], maxNum: 3 }
|
111 |
| - ] as any |
112 |
| - }); |
| 113 | + ] |
| 114 | + } as any); |
113 | 115 | const endTime = new Date().getTime();
|
114 | 116 | const costTime = endTime - startTime;
|
115 |
| - |
116 |
| - props.onInsightGenerate(insights, specJson, costTime); |
| 117 | + let newSpec = null; |
| 118 | + if (enableAnnotation) { |
| 119 | + newSpec = (await vmind.current.updateSpecByInsights(specJson, insights)).newSpec; |
| 120 | + console.log(newSpec); |
| 121 | + } |
| 122 | + props.onInsightGenerate(insights, enableAnnotation ? newSpec : specJson, costTime); |
117 | 123 |
|
118 | 124 | console.log(costTime);
|
119 | 125 | console.log(insights);
|
120 | 126 |
|
121 | 127 | setLoading(false);
|
122 |
| - }, [numLimits, props, spec]); |
| 128 | + }, [numLimits, props, spec, enableAnnotation]); |
123 | 129 |
|
124 | 130 | return (
|
125 | 131 | <div className="left-sider">
|
@@ -216,6 +222,11 @@ export function DataInput(props: IPropsType) {
|
216 | 222 | <Radio value={globalVariables.VITE_CUSTOM_MODEL}>Your Custom Model</Radio>
|
217 | 223 | </RadioGroup>
|
218 | 224 | </div>
|
| 225 | + <div style={{ width: '90%', marginBottom: 10 }}> |
| 226 | + <Checkbox checked={enableAnnotation} onChange={v => setEnableAnnotation(v)}> |
| 227 | + Enable Insights Annotation |
| 228 | + </Checkbox> |
| 229 | + </div> |
219 | 230 | <div className="generate-botton">
|
220 | 231 | <Button
|
221 | 232 | loading={loading}
|
|
0 commit comments