test-chat-sdk 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/.prettierrc.js +24 -0
  2. package/README.md +46 -0
  3. package/config/env.js +104 -0
  4. package/config/getHttpsConfig.js +66 -0
  5. package/config/jest/babelTransform.js +29 -0
  6. package/config/jest/cssTransform.js +14 -0
  7. package/config/jest/fileTransform.js +40 -0
  8. package/config/modules.js +134 -0
  9. package/config/paths.js +77 -0
  10. package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
  11. package/config/webpack.config.js +785 -0
  12. package/config/webpackDevServer.config.js +127 -0
  13. package/dist/Chat/AgentList/index.d.ts +9 -0
  14. package/dist/Chat/ChatFooter/index.d.ts +17 -0
  15. package/dist/Chat/Conversation/index.d.ts +11 -0
  16. package/dist/Chat/MessageContainer/index.d.ts +19 -0
  17. package/dist/Chat/MobileAgents/index.d.ts +11 -0
  18. package/dist/Chat/components/AgentTip/index.d.ts +8 -0
  19. package/dist/Chat/components/ConversationModal/index.d.ts +10 -0
  20. package/dist/Chat/components/CopilotAvatar/index.d.ts +2 -0
  21. package/dist/Chat/components/Message.d.ts +10 -0
  22. package/dist/Chat/components/RecommendQuestions/index.d.ts +6 -0
  23. package/dist/Chat/components/Text.d.ts +9 -0
  24. package/dist/Chat/constants.d.ts +19 -0
  25. package/dist/Chat/index.d.ts +17 -0
  26. package/dist/Chat/service.d.ts +11 -0
  27. package/dist/Chat/type.d.ts +97 -0
  28. package/dist/Copilot/constants.d.ts +11 -0
  29. package/dist/Copilot/index.d.ts +13 -0
  30. package/dist/ShowCase/index.d.ts +8 -0
  31. package/dist/ShowCase/service.d.ts +2 -0
  32. package/dist/ShowCase/type.d.ts +11 -0
  33. package/dist/common/constants.d.ts +58 -0
  34. package/dist/common/env.d.ts +3 -0
  35. package/dist/common/type.d.ts +247 -0
  36. package/dist/components/ChatItem/ExecuteItem.d.ts +25 -0
  37. package/dist/components/ChatItem/ExpandParseTip.d.ts +20 -0
  38. package/dist/components/ChatItem/FilterItem.d.ts +17 -0
  39. package/dist/components/ChatItem/Loading.d.ts +2 -0
  40. package/dist/components/ChatItem/ParseTip.d.ts +26 -0
  41. package/dist/components/ChatItem/ParseTipUtils.d.ts +10 -0
  42. package/dist/components/ChatItem/SimilarQuestionItem.d.ts +10 -0
  43. package/dist/components/ChatItem/SqlItem.d.ts +17 -0
  44. package/dist/components/ChatItem/SwitchEntity.d.ts +9 -0
  45. package/dist/components/ChatItem/Text.d.ts +6 -0
  46. package/dist/components/ChatItem/Typing.d.ts +2 -0
  47. package/dist/components/ChatItem/index.d.ts +33 -0
  48. package/dist/components/ChatMsg/ApplyAuth/index.d.ts +7 -0
  49. package/dist/components/ChatMsg/Bar/index.d.ts +13 -0
  50. package/dist/components/ChatMsg/DateOptions/index.d.ts +9 -0
  51. package/dist/components/ChatMsg/FilterSection/index.d.ts +8 -0
  52. package/dist/components/ChatMsg/MarkDown/index.d.ts +10 -0
  53. package/dist/components/ChatMsg/Message/index.d.ts +18 -0
  54. package/dist/components/ChatMsg/MetricCard/PeriodCompareItem.d.ts +7 -0
  55. package/dist/components/ChatMsg/MetricCard/index.d.ts +10 -0
  56. package/dist/components/ChatMsg/MetricTrend/MetricInfo.d.ts +8 -0
  57. package/dist/components/ChatMsg/MetricTrend/MetricTrendChart.d.ts +14 -0
  58. package/dist/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.d.ts +12 -0
  59. package/dist/components/ChatMsg/MetricTrend/index.d.ts +16 -0
  60. package/dist/components/ChatMsg/NoPermissionChart/index.d.ts +8 -0
  61. package/dist/components/ChatMsg/Pie/PieChart.d.ts +11 -0
  62. package/dist/components/ChatMsg/Pie/index.d.ts +14 -0
  63. package/dist/components/ChatMsg/Table/index.d.ts +12 -0
  64. package/dist/components/ChatMsg/Text/index.d.ts +9 -0
  65. package/dist/components/ChatMsg/WebPage/index.d.ts +8 -0
  66. package/dist/components/ChatMsg/index.d.ts +15 -0
  67. package/dist/components/DrillDownDimensions/DimensionSection.d.ts +11 -0
  68. package/dist/components/DrillDownDimensions/index.d.ts +13 -0
  69. package/dist/components/IconFont/index.d.ts +3 -0
  70. package/dist/components/MetricOptions/index.d.ts +11 -0
  71. package/dist/components/RecommendOptions/index.d.ts +9 -0
  72. package/dist/components/Tools/FeedbackModal.d.ts +9 -0
  73. package/dist/components/Tools/index.d.ts +12 -0
  74. package/dist/demo/Chat.d.ts +2 -0
  75. package/dist/demo/ChatDemo.d.ts +4 -0
  76. package/dist/demo/CopilotDemo.d.ts +2 -0
  77. package/dist/hooks/index.d.ts +3 -0
  78. package/dist/hooks/useComposing.d.ts +5 -0
  79. package/dist/hooks/useExportByEcharts.d.ts +10 -0
  80. package/dist/hooks/useMethodRegister.d.ts +4 -0
  81. package/dist/index.d.ts +10 -0
  82. package/dist/index.es.js +1 -0
  83. package/dist/service/axiosInstance.d.ts +3 -0
  84. package/dist/service/index.d.ts +25 -0
  85. package/dist/utils/utils.d.ts +45 -0
  86. package/package.json +214 -0
  87. package/public/favicon.ico +0 -0
  88. package/public/index.html +43 -0
  89. package/public/manifest.json +15 -0
  90. package/public/robots.txt +3 -0
  91. package/rollup/rollup.config.mjs +37 -0
  92. package/rollup/rollup.esm.config.mjs +21 -0
  93. package/rollup/rollup.umd.config.mjs +30 -0
  94. package/scripts/build.js +217 -0
  95. package/scripts/start.js +154 -0
  96. package/scripts/test.js +52 -0
  97. package/src/Chat/AgentList/index.tsx +52 -0
  98. package/src/Chat/AgentList/style.module.less +83 -0
  99. package/src/Chat/ChatFooter/index.tsx +423 -0
  100. package/src/Chat/ChatFooter/style.module.less +225 -0
  101. package/src/Chat/Conversation/index.tsx +236 -0
  102. package/src/Chat/Conversation/style.module.less +171 -0
  103. package/src/Chat/MessageContainer/index.tsx +145 -0
  104. package/src/Chat/MessageContainer/style.module.less +53 -0
  105. package/src/Chat/MobileAgents/index.tsx +62 -0
  106. package/src/Chat/MobileAgents/style.module.less +55 -0
  107. package/src/Chat/components/AgentTip/index.tsx +48 -0
  108. package/src/Chat/components/AgentTip/style.module.less +44 -0
  109. package/src/Chat/components/ConversationModal/index.tsx +65 -0
  110. package/src/Chat/components/CopilotAvatar/index.tsx +8 -0
  111. package/src/Chat/components/CopilotAvatar/style.module.less +13 -0
  112. package/src/Chat/components/Message.tsx +38 -0
  113. package/src/Chat/components/RecommendQuestions/index.tsx +64 -0
  114. package/src/Chat/components/RecommendQuestions/style.module.less +36 -0
  115. package/src/Chat/components/Text.tsx +42 -0
  116. package/src/Chat/components/style.module.less +311 -0
  117. package/src/Chat/constants.ts +37 -0
  118. package/src/Chat/index.tsx +526 -0
  119. package/src/Chat/service.ts +49 -0
  120. package/src/Chat/style.module.less +119 -0
  121. package/src/Chat/type.ts +107 -0
  122. package/src/Copilot/constants.ts +11 -0
  123. package/src/Copilot/index.tsx +149 -0
  124. package/src/Copilot/style.module.less +151 -0
  125. package/src/ShowCase/index.tsx +120 -0
  126. package/src/ShowCase/service.ts +12 -0
  127. package/src/ShowCase/style.module.less +46 -0
  128. package/src/ShowCase/type.ts +14 -0
  129. package/src/common/constants.ts +93 -0
  130. package/src/common/env.ts +5 -0
  131. package/src/common/type.ts +270 -0
  132. package/src/components/ChatItem/ExecuteItem.tsx +210 -0
  133. package/src/components/ChatItem/ExpandParseTip.tsx +333 -0
  134. package/src/components/ChatItem/FilterItem.tsx +209 -0
  135. package/src/components/ChatItem/Loading.tsx +14 -0
  136. package/src/components/ChatItem/ParseTip.tsx +322 -0
  137. package/src/components/ChatItem/ParseTipUtils.tsx +205 -0
  138. package/src/components/ChatItem/SimilarQuestionItem.tsx +84 -0
  139. package/src/components/ChatItem/SqlItem.tsx +410 -0
  140. package/src/components/ChatItem/SwitchEntity.tsx +52 -0
  141. package/src/components/ChatItem/Text.tsx +17 -0
  142. package/src/components/ChatItem/Typing.tsx +19 -0
  143. package/src/components/ChatItem/index.tsx +843 -0
  144. package/src/components/ChatItem/style.less +670 -0
  145. package/src/components/ChatMsg/ApplyAuth/index.tsx +30 -0
  146. package/src/components/ChatMsg/ApplyAuth/style.less +13 -0
  147. package/src/components/ChatMsg/Bar/index.tsx +208 -0
  148. package/src/components/ChatMsg/Bar/style.less +60 -0
  149. package/src/components/ChatMsg/DateOptions/index.tsx +46 -0
  150. package/src/components/ChatMsg/DateOptions/style.less +43 -0
  151. package/src/components/ChatMsg/FilterSection/index.tsx +42 -0
  152. package/src/components/ChatMsg/FilterSection/style.less +37 -0
  153. package/src/components/ChatMsg/MarkDown/index.tsx +26 -0
  154. package/src/components/ChatMsg/MarkDown/style.less +9 -0
  155. package/src/components/ChatMsg/Message/index.tsx +105 -0
  156. package/src/components/ChatMsg/Message/style.less +119 -0
  157. package/src/components/ChatMsg/MetricCard/PeriodCompareItem.tsx +29 -0
  158. package/src/components/ChatMsg/MetricCard/index.tsx +80 -0
  159. package/src/components/ChatMsg/MetricCard/style.less +126 -0
  160. package/src/components/ChatMsg/MetricTrend/MetricInfo.tsx +60 -0
  161. package/src/components/ChatMsg/MetricTrend/MetricTrendChart.tsx +235 -0
  162. package/src/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.tsx +162 -0
  163. package/src/components/ChatMsg/MetricTrend/index.tsx +127 -0
  164. package/src/components/ChatMsg/MetricTrend/style.less +195 -0
  165. package/src/components/ChatMsg/NoPermissionChart/index.tsx +28 -0
  166. package/src/components/ChatMsg/NoPermissionChart/style.less +26 -0
  167. package/src/components/ChatMsg/Pie/PieChart.tsx +120 -0
  168. package/src/components/ChatMsg/Pie/index.tsx +88 -0
  169. package/src/components/ChatMsg/Pie/style.less +43 -0
  170. package/src/components/ChatMsg/Table/index.tsx +103 -0
  171. package/src/components/ChatMsg/Table/style.less +131 -0
  172. package/src/components/ChatMsg/Text/index.tsx +70 -0
  173. package/src/components/ChatMsg/Text/style.less +38 -0
  174. package/src/components/ChatMsg/WebPage/index.tsx +125 -0
  175. package/src/components/ChatMsg/index.tsx +428 -0
  176. package/src/components/ChatMsg/style.less +28 -0
  177. package/src/components/DrillDownDimensions/DimensionSection.tsx +99 -0
  178. package/src/components/DrillDownDimensions/index.tsx +76 -0
  179. package/src/components/DrillDownDimensions/style.less +64 -0
  180. package/src/components/IconFont/index.tsx +7 -0
  181. package/src/components/MetricOptions/index.tsx +75 -0
  182. package/src/components/MetricOptions/style.less +69 -0
  183. package/src/components/RecommendOptions/index.tsx +126 -0
  184. package/src/components/RecommendOptions/style.less +24 -0
  185. package/src/components/Tools/FeedbackModal.tsx +55 -0
  186. package/src/components/Tools/index.tsx +126 -0
  187. package/src/components/Tools/style.less +67 -0
  188. package/src/demo/Chat.tsx +73 -0
  189. package/src/demo/ChatDemo.tsx +14 -0
  190. package/src/demo/CopilotDemo.tsx +43 -0
  191. package/src/demo/style.module.less +19 -0
  192. package/src/hooks/index.ts +3 -0
  193. package/src/hooks/useComposing.ts +31 -0
  194. package/src/hooks/useExportByEcharts.ts +41 -0
  195. package/src/hooks/useMethodRegister.ts +25 -0
  196. package/src/index.tsx +44 -0
  197. package/src/service/axiosInstance.ts +58 -0
  198. package/src/service/index.ts +174 -0
  199. package/src/setupProxy.js +18 -0
  200. package/src/setupTests.ts +5 -0
  201. package/src/styles/global.less +52 -0
  202. package/src/styles/index.less +39 -0
  203. package/src/styles/reboot.less +14 -0
  204. package/src/styles/variables.less +80 -0
  205. package/src/typings.d.ts +179 -0
  206. package/src/utils/utils.ts +346 -0
  207. package/tsconfig.build.json +20 -0
  208. package/tsconfig.json +27 -0
@@ -0,0 +1,270 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { ChatContextTypeQueryTypeEnum } from './constants';
3
+
4
+ export type SearchRecommendItem = {
5
+ complete: boolean;
6
+ modelId: number;
7
+ modelName: string;
8
+ recommend: string;
9
+ subRecommend: string;
10
+ schemaElementType: string;
11
+ };
12
+
13
+ export type FieldType = {
14
+ bizName: string;
15
+ itemId: number;
16
+ id: number;
17
+ name: string;
18
+ status: number;
19
+ model: number;
20
+ type: string;
21
+ value: string;
22
+ };
23
+
24
+ export type ModelInfoType = {
25
+ bizName: string;
26
+ itemId: number;
27
+ name: string;
28
+ primaryEntityBizName: string;
29
+ value: string;
30
+ words: string[];
31
+ };
32
+
33
+ export type EntityInfoType = {
34
+ dataSetInfo: ModelInfoType;
35
+ dimensions: FieldType[];
36
+ metrics: FieldType[];
37
+ entityId: number;
38
+ };
39
+
40
+ export type DateInfoType = {
41
+ dateList: any[];
42
+ dateMode: string;
43
+ period: string;
44
+ startDate: string;
45
+ endDate: string;
46
+ text: string;
47
+ unit: number;
48
+ };
49
+
50
+ export type FilterItemType = {
51
+ elementID: number;
52
+ name: string;
53
+ bizName: string;
54
+ operator?: string;
55
+ type?: string;
56
+ value: any;
57
+ entityName?: string;
58
+ };
59
+
60
+ export type ModelType = {
61
+ alias: string;
62
+ bizName: string;
63
+ id: number;
64
+ model: number;
65
+ name: string;
66
+ modelNames: string[];
67
+ type: string;
68
+ useCnt: number;
69
+ };
70
+
71
+ export type EntityDimensionType = {
72
+ bizName: string;
73
+ itemId: number;
74
+ name: string;
75
+ value: string;
76
+ };
77
+
78
+ export type SqlInfoType = {
79
+ parsedS2SQL: string;
80
+ correctedS2SQL: string;
81
+ querySQL: string;
82
+ correctedQuerySQL?: string;
83
+ };
84
+
85
+ export type ChatContextType = {
86
+ id: number;
87
+ queryId?: number;
88
+ aggType: string;
89
+ modelId: number;
90
+ modelName: string;
91
+ dataSet: ModelType;
92
+ dataSetIds?: number[];
93
+ dateInfo: DateInfoType;
94
+ dimensions: FieldType[];
95
+ metrics: FieldType[];
96
+ entity: { alias: string[]; id: number };
97
+ entityInfo: EntityInfoType;
98
+ elementMatches: any[];
99
+ nativeQuery: boolean;
100
+ queryMode: string;
101
+ queryType: ChatContextTypeQueryTypeEnum;
102
+ dimensionFilters: FilterItemType[];
103
+ properties: any;
104
+ sqlInfo: SqlInfoType;
105
+ textInfo: string;
106
+ };
107
+
108
+ export enum MsgValidTypeEnum {
109
+ NORMAL = 0,
110
+ SEARCH_EXCEPTION = 1,
111
+ EMPTY = 2,
112
+ INVALID = 3,
113
+ }
114
+
115
+ export type PluginResonseType = {
116
+ description: string;
117
+ webPage: { url: string; paramOptions: any; params: any; valueParams: any };
118
+ pluginId: number;
119
+ pluginType: string;
120
+ name: string;
121
+ };
122
+
123
+ export type MetricInfoType = {
124
+ date: string;
125
+ name: string;
126
+ statistics: any;
127
+ value: string;
128
+ };
129
+
130
+ export type AggregateInfoType = {
131
+ metricInfos: MetricInfoType[];
132
+ };
133
+
134
+ export type MsgDataType = {
135
+ id: number;
136
+ question: string;
137
+ aggregateInfo: AggregateInfoType;
138
+ chatContext: ChatContextType;
139
+ entityInfo: EntityInfoType;
140
+ queryAuthorization: any;
141
+ queryColumns: ColumnType[];
142
+ queryResults: any[];
143
+ queryId: number;
144
+ queryMode: string;
145
+ queryState: string;
146
+ queryText: string;
147
+ response: PluginResonseType;
148
+ parseInfos?: ChatContextType[];
149
+ queryTimeCost?: number;
150
+ similarQueries: SimilarQuestionType[];
151
+ recommendedDimensions: DrillDownDimensionType[];
152
+ textResult: string;
153
+ errorMsg: string;
154
+ textSummary: string;
155
+ };
156
+
157
+ export enum ParseStateEnum {
158
+ COMPLETED = 'COMPLETED',
159
+ PENDING = 'PENDING',
160
+ FAILED = 'FAILED',
161
+ }
162
+
163
+ export type ParseDataType = {
164
+ chatId: number;
165
+ queryId: number;
166
+ queryText: string;
167
+ state: ParseStateEnum;
168
+ selectedParses: ChatContextType[];
169
+ candidateParses: ChatContextType[];
170
+ similarSolvedQuery: SimilarQuestionType[];
171
+ };
172
+
173
+ export type QueryDataType = {
174
+ chatContext: ChatContextType;
175
+ aggregateInfo: AggregateInfoType;
176
+ queryColumns: ColumnType[];
177
+ queryResults: any[];
178
+ };
179
+
180
+ export type ColumnType = {
181
+ authorized: boolean;
182
+ name: string;
183
+ nameEn: string;
184
+ bizName: string;
185
+ showType: string;
186
+ type: string;
187
+ dataFormatType: string;
188
+ dataFormat: {
189
+ decimalPlaces: number;
190
+ needMultiply100: boolean;
191
+ };
192
+ };
193
+
194
+ export enum SemanticTypeEnum {
195
+ DOMAIN = 'DOMAIN',
196
+ DIMENSION = 'DIMENSION',
197
+ METRIC = 'METRIC',
198
+ VALUE = 'VALUE',
199
+ }
200
+
201
+ export const SEMANTIC_TYPE_MAP = {
202
+ [SemanticTypeEnum.DOMAIN]: '数据模型',
203
+ [SemanticTypeEnum.DIMENSION]: '维度',
204
+ [SemanticTypeEnum.METRIC]: '指标',
205
+ [SemanticTypeEnum.VALUE]: '维度值',
206
+ };
207
+
208
+ export type SuggestionItemType = {
209
+ model: number;
210
+ name: string;
211
+ bizName: string;
212
+ };
213
+
214
+ export type SuggestionType = {
215
+ dimensions: SuggestionItemType[];
216
+ metrics: SuggestionItemType[];
217
+ };
218
+
219
+ export type SuggestionDataType = {
220
+ currentAggregateType: string;
221
+ columns: ColumnType[];
222
+ mainEntity: EntityInfoType;
223
+ suggestions: SuggestionType;
224
+ };
225
+
226
+ export type HistoryMsgItemType = {
227
+ questionId: number;
228
+ queryText: string;
229
+ parseInfos: ChatContextType[];
230
+ parseTimeCost: ParseTimeCostType;
231
+ queryResult: MsgDataType;
232
+ chatId: number;
233
+ createTime: string;
234
+ feedback: string;
235
+ score: number;
236
+ similarQueries: SimilarQuestionType[];
237
+ };
238
+
239
+ export type HistoryType = {
240
+ hasNextPage: boolean;
241
+ list: HistoryMsgItemType[];
242
+ };
243
+
244
+ export type DrillDownDimensionType = {
245
+ id: number;
246
+ model: number;
247
+ name: string;
248
+ bizName: string;
249
+ };
250
+
251
+ export type SendMsgParamsType = {
252
+ msg: string;
253
+ agentId: number;
254
+ modelId: number;
255
+ filters?: FilterItemType[];
256
+ };
257
+
258
+ export type SimilarQuestionType = {
259
+ queryId: number;
260
+ parseId: number;
261
+ queryText: string;
262
+ };
263
+
264
+ export type ParseTimeCostType = {
265
+ parseStartTime: number;
266
+ parseTime: number;
267
+ sqlTime: number;
268
+ };
269
+
270
+ export type RangeValue = [Dayjs, Dayjs];
@@ -0,0 +1,210 @@
1
+ import { Space, Spin, Switch, Tooltip, message } from 'antd';
2
+ import { CheckCircleFilled, InfoCircleOutlined } from '@ant-design/icons';
3
+ import { PREFIX_CLS, MsgContentTypeEnum } from '../../common/constants';
4
+ import { MsgDataType } from '../../common/type';
5
+ import ChatMsg from '../ChatMsg';
6
+ import WebPage from '../ChatMsg/WebPage';
7
+ import Loading from './Loading';
8
+ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
9
+ import { solarizedlight } from 'react-syntax-highlighter/dist/esm/styles/prism';
10
+ import React, { ReactNode, useState, useEffect } from 'react';
11
+ import ReactMarkdown from 'react-markdown';
12
+
13
+ type Props = {
14
+ queryId?: number;
15
+ parseId?: number;
16
+ question: string;
17
+ queryMode?: string;
18
+ executeLoading: boolean;
19
+ entitySwitchLoading?: boolean;
20
+ chartIndex: number;
21
+ executeTip?: string;
22
+ executeErrorMsg?: string;
23
+ executeItemNode?: ReactNode;
24
+ renderCustomExecuteNode?: boolean;
25
+ data?: MsgDataType;
26
+ triggerResize?: boolean;
27
+ isDeveloper?: boolean;
28
+ isSimpleMode?: boolean;
29
+ enableStreamingSummary?: boolean;
30
+ onStreamingSummaryUpdate?: (summary: string) => void;
31
+ agentId?: number;
32
+ dataSetIds?: number[];
33
+ };
34
+
35
+ const ExecuteItem: React.FC<Props> = ({
36
+ queryId,
37
+ parseId,
38
+ question,
39
+ queryMode,
40
+ executeLoading,
41
+ entitySwitchLoading = false,
42
+ chartIndex,
43
+ executeTip,
44
+ executeErrorMsg,
45
+ executeItemNode,
46
+ renderCustomExecuteNode,
47
+ data,
48
+ triggerResize,
49
+ isDeveloper,
50
+ isSimpleMode,
51
+ enableStreamingSummary,
52
+ onStreamingSummaryUpdate,
53
+ agentId,
54
+ dataSetIds,
55
+ }) => {
56
+ const prefixCls = `${PREFIX_CLS}-item`;
57
+ const [showMsgContentTable, setShowMsgContentTable] = useState<boolean>(false);
58
+ const [msgContentType, setMsgContentType] = useState<MsgContentTypeEnum>();
59
+ const [showErrMsg, setShowErrMsg] = useState<boolean>(false);
60
+ const [isStreaming, setIsStreaming] = useState(false);
61
+ const [summaryBuilder, setSummaryBuilder] = useState('');
62
+ const titlePrefix = queryMode === 'PLAIN_TEXT' || queryMode === 'WEB_SERVICE' ? '问答' : '数据';
63
+
64
+ const getNodeTip = (title: ReactNode, tip?: string | ReactNode) => {
65
+ return (
66
+ <>
67
+ <div className={`${prefixCls}-title-bar`}>
68
+ <CheckCircleFilled className={`${prefixCls}-step-icon`} />
69
+ <div className={`${prefixCls}-step-title`}>
70
+ {title}
71
+ {!tip && <Loading />}
72
+ </div>
73
+ </div>
74
+ {tip && <div className={`${prefixCls}-content-container`}>{tip}</div>}
75
+ </>
76
+ );
77
+ };
78
+
79
+ // 流式总结功能已移除
80
+ useEffect(() => {
81
+ // 流式总结功能已移除,不再处理
82
+ }, [enableStreamingSummary, queryId, parseId, agentId]);
83
+
84
+ if (executeLoading) {
85
+ return getNodeTip(`${titlePrefix}查询中`);
86
+ }
87
+
88
+ const handleCopy = (_: string, result: any) => {
89
+ result ? message.success('复制SQL成功', 1) : message.error('复制SQL失败', 1);
90
+ };
91
+
92
+ if (executeTip) {
93
+ return getNodeTip(
94
+ <>
95
+ <span>{titlePrefix}查询失败</span>
96
+ {executeErrorMsg && (
97
+ <Space>
98
+ <InfoCircleOutlined style={{ marginLeft: 5, color: 'red' }} />
99
+ <a
100
+ onClick={() => {
101
+ setShowErrMsg(!showErrMsg);
102
+ }}
103
+ >
104
+ {!showErrMsg ? '查看' : '收起'}
105
+ </a>
106
+ </Space>
107
+ )}
108
+ {!!data?.queryTimeCost && isDeveloper && (
109
+ <span className={`${prefixCls}-title-tip`}>(耗时: {data.queryTimeCost}ms)</span>
110
+ )}
111
+ </>,
112
+
113
+ <>
114
+ {showErrMsg && (
115
+ <SyntaxHighlighter className={`${prefixCls}-code`} language="sql" style={solarizedlight}>
116
+ {executeErrorMsg}
117
+ </SyntaxHighlighter>
118
+ )}
119
+ </>
120
+ );
121
+ }
122
+
123
+ if (!data) {
124
+ return null;
125
+ }
126
+
127
+ const getSummaryNode = () => {
128
+ // 流式总结功能已移除,直接显示最终的总结
129
+ if (data.textSummary) {
130
+ return (
131
+ <div className={`${prefixCls}-summary`}>
132
+ <ReactMarkdown>{data.textSummary}</ReactMarkdown>
133
+ </div>
134
+ );
135
+ }
136
+
137
+ return null;
138
+ };
139
+
140
+ return (
141
+ <>
142
+ {!isSimpleMode && (
143
+ <div className={`${prefixCls}-title-bar`}>
144
+ <CheckCircleFilled className={`${prefixCls}-step-icon`} />
145
+ <div
146
+ className={`${prefixCls}-step-title ${prefixCls}-execute-title-bar`}
147
+ style={{ width: '100%' }}
148
+ >
149
+ <div>
150
+ {titlePrefix}查询
151
+ {!!data?.queryTimeCost && isDeveloper && (
152
+ <span className={`${prefixCls}-title-tip`}>(耗时: {data.queryTimeCost}ms)</span>
153
+ )}
154
+ </div>
155
+ <div>
156
+ {[
157
+ MsgContentTypeEnum.METRIC_TREND,
158
+ MsgContentTypeEnum.METRIC_BAR,
159
+ MsgContentTypeEnum.METRIC_PIE,
160
+ ].includes(msgContentType as MsgContentTypeEnum) && (
161
+ <Switch
162
+ checkedChildren="表格"
163
+ unCheckedChildren="表格"
164
+ onChange={checked => {
165
+ setShowMsgContentTable(checked);
166
+ }}
167
+ />
168
+ )}
169
+ </div>
170
+ </div>
171
+ </div>
172
+ )}
173
+
174
+ <div
175
+ className={`${prefixCls}-content-container ${
176
+ isSimpleMode ? `${prefixCls}-content-container-simple` : ''
177
+ }`}
178
+ style={{ borderLeft: queryMode === 'PLAIN_TEXT' ? 'none' : undefined }}
179
+ >
180
+ <Spin spinning={entitySwitchLoading}>
181
+ {data.queryAuthorization?.message && (
182
+ <div className={`${prefixCls}-auth-tip`}>提示:{data.queryAuthorization.message}</div>
183
+ )}
184
+ {getSummaryNode()}
185
+
186
+ {renderCustomExecuteNode && executeItemNode ? (
187
+ executeItemNode
188
+ ) : data?.queryMode === 'PLAIN_TEXT' || data?.queryMode === 'WEB_SERVICE' ? (
189
+ data?.textResult
190
+ ) : data?.queryMode === 'WEB_PAGE' ? (
191
+ <WebPage id={queryId!} data={data} />
192
+ ) : (
193
+ <ChatMsg
194
+ isSimpleMode={isSimpleMode}
195
+ forceShowTable={showMsgContentTable}
196
+ queryId={queryId}
197
+ question={question}
198
+ data={data}
199
+ chartIndex={chartIndex}
200
+ triggerResize={triggerResize}
201
+ onMsgContentTypeChange={setMsgContentType}
202
+ />
203
+ )}
204
+ </Spin>
205
+ </div>
206
+ </>
207
+ );
208
+ };
209
+
210
+ export default ExecuteItem;