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,75 @@
1
+ import { CLS_PREFIX } from '../../common/constants';
2
+ import { FieldType } from '../../common/type';
3
+ import classNames from 'classnames';
4
+ import { isMobile } from '../../utils/utils';
5
+
6
+ type Props = {
7
+ metrics: FieldType[];
8
+ defaultMetric?: FieldType;
9
+ currentMetric?: FieldType;
10
+ isMetricCard?: boolean;
11
+ onSelectMetric: (metric?: FieldType) => void;
12
+ };
13
+
14
+ const MetricOptions: React.FC<Props> = ({
15
+ metrics,
16
+ defaultMetric,
17
+ currentMetric,
18
+ isMetricCard,
19
+ onSelectMetric,
20
+ }) => {
21
+ const DEFAULT_DIMENSION_COUNT = isMobile ? 2 : 5;
22
+ const prefixCls = `${CLS_PREFIX}-metric-options`;
23
+
24
+ const defaultMetrics = metrics
25
+ .filter(metric => metric.id !== defaultMetric?.id)
26
+ .slice(0, DEFAULT_DIMENSION_COUNT);
27
+
28
+ const sectionClass = classNames(`${prefixCls}-section`, {
29
+ [`${prefixCls}-metric-card`]: isMetricCard,
30
+ });
31
+
32
+ if (!defaultMetrics.length) {
33
+ return null;
34
+ }
35
+
36
+ return (
37
+ <div className={prefixCls}>
38
+ <div className={sectionClass}>
39
+ <div className={`${prefixCls}-title`}>推荐相关指标:</div>
40
+ <div className={`${prefixCls}-content`}>
41
+ {defaultMetrics.map((metric, index) => {
42
+ const itemNameClass = classNames(`${prefixCls}-content-item-name`, {
43
+ [`${prefixCls}-content-item-active`]: currentMetric?.id === metric.id,
44
+ });
45
+ return (
46
+ <div>
47
+ <span
48
+ className={itemNameClass}
49
+ onClick={() => {
50
+ onSelectMetric(currentMetric?.id === metric.id ? defaultMetric : metric);
51
+ }}
52
+ >
53
+ {metric.name}
54
+ </span>
55
+ {index !== defaultMetrics.length - 1 && <span>、</span>}
56
+ </div>
57
+ );
58
+ })}
59
+ </div>
60
+ {currentMetric?.id !== defaultMetric?.id && (
61
+ <div
62
+ className={`${prefixCls}-cancel-select`}
63
+ onClick={() => {
64
+ onSelectMetric(defaultMetric);
65
+ }}
66
+ >
67
+ 取消
68
+ </div>
69
+ )}
70
+ </div>
71
+ </div>
72
+ );
73
+ };
74
+
75
+ export default MetricOptions;
@@ -0,0 +1,69 @@
1
+ @import '../../styles/index.less';
2
+
3
+ @metric-options-prefix-cls: ~'@{supersonic-chat-prefix}-metric-options';
4
+
5
+ .@{metric-options-prefix-cls} {
6
+ display: flex;
7
+ flex-direction: column;
8
+
9
+ &-section {
10
+ width: 100%;
11
+ display: flex;
12
+ align-items: center;
13
+ flex-wrap: wrap;
14
+ column-gap: 6px;
15
+ row-gap: 4px;
16
+ }
17
+
18
+ &-metric-card {
19
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12);
20
+ border-radius: 8px;
21
+ background-color: #fff;
22
+ width: fit-content;
23
+ padding: 2px 4px;
24
+ font-size: 12px;
25
+ }
26
+
27
+ &-title {
28
+ color: var(--text-color-third);
29
+ }
30
+
31
+ &-content {
32
+ display: flex;
33
+ align-items: center;
34
+ }
35
+
36
+ &-content-item-name {
37
+ color: var(--chat-blue);
38
+ font-weight: 500;
39
+ border-bottom: 1px solid var(--chat-blue);
40
+ padding: 1px;
41
+ cursor: pointer;
42
+ }
43
+
44
+ &-content-item-active {
45
+ color: #fff;
46
+ border-bottom: none;
47
+ background-color: var(--chat-blue);
48
+ border-radius: 2px;
49
+ }
50
+
51
+ &-menu-item-active {
52
+ color: var(--chat-blue);
53
+ }
54
+
55
+ &-cancel-select {
56
+ margin-left: 12px;
57
+ color: var(--text-color-third);
58
+ cursor: pointer;
59
+ padding: 0 4px;
60
+ border: 1px solid var(--text-color-third);
61
+ border-radius: 4px;
62
+ font-size: 12px;
63
+
64
+ &:hover {
65
+ color: var(--chat-blue);
66
+ border-color: var(--chat-blue);
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,126 @@
1
+ import { getFormattedValue, isMobile } from '../../utils/utils';
2
+ import { Table, Avatar } from 'antd';
3
+ import moment from 'moment';
4
+ import { useEffect, useState } from 'react';
5
+ import { queryEntities } from '../../service';
6
+ import { CLS_PREFIX } from '../../common/constants';
7
+ import IconFont from '../IconFont';
8
+ import classNames from 'classnames';
9
+
10
+ type Props = {
11
+ entityId: string | number;
12
+ modelId: number;
13
+ modelName: string;
14
+ onSelect: (option: string) => void;
15
+ };
16
+
17
+ const RecommendOptions: React.FC<Props> = ({ entityId, modelId, modelName, onSelect }) => {
18
+ const [data, setData] = useState<any[]>([]);
19
+ const [loading, setLoading] = useState(false);
20
+
21
+ const prefixCls = `${CLS_PREFIX}-recommend-options`;
22
+
23
+ const initData = async () => {
24
+ setLoading(true);
25
+ const res = await queryEntities(entityId, modelId);
26
+ setLoading(false);
27
+ setData(res.data);
28
+ };
29
+
30
+ useEffect(() => {
31
+ if (entityId) {
32
+ initData();
33
+ }
34
+ }, [entityId]);
35
+
36
+ const getSectionOptions = () => {
37
+ const basicColumn = {
38
+ dataIndex: 'name',
39
+ key: 'name',
40
+ title: '基本信息',
41
+ render: (name: string, record: any) => {
42
+ return (
43
+ <div className={`${prefixCls}-item-name-column`}>
44
+ <Avatar
45
+ shape="square"
46
+ icon={<IconFont type={modelName === '艺人库' ? 'icon-geshou' : 'icon-zhuanji'} />}
47
+ src={record.url}
48
+ />
49
+ <div className={`${prefixCls}-entity-name`}>
50
+ {name}
51
+ {record.ver && record.ver !== '完整版' && record.ver !== '-' && `(${record.ver})`}
52
+ {record.singerName && ` - ${record.singerName}`}
53
+ </div>
54
+ </div>
55
+ );
56
+ },
57
+ };
58
+
59
+ const playCntColumnIdex = modelName.includes('歌曲')
60
+ ? 'tme3platAvgLogYyPlayCnt'
61
+ : 'tme3platJsPlayCnt';
62
+
63
+ const columns = isMobile
64
+ ? [basicColumn]
65
+ : [
66
+ basicColumn,
67
+ modelName.includes('艺人')
68
+ ? {
69
+ dataIndex: 'onlineSongCnt',
70
+ key: 'onlineSongCnt',
71
+ title: '在架歌曲数',
72
+ align: 'center',
73
+ render: (onlineSongCnt: string) => {
74
+ return onlineSongCnt ? getFormattedValue(+onlineSongCnt) : '-';
75
+ },
76
+ }
77
+ : {
78
+ dataIndex: 'publishTime',
79
+ key: 'publishTime',
80
+ title: '发布时间',
81
+ align: 'center',
82
+ render: (publishTime: string) => {
83
+ return publishTime ? moment(publishTime).format('YYYY-MM-DD') : '-';
84
+ },
85
+ },
86
+ {
87
+ dataIndex: playCntColumnIdex,
88
+ key: playCntColumnIdex,
89
+ align: 'center',
90
+ title: modelName.includes('歌曲') ? '近7天日均运营播放量' : '昨日结算播放量',
91
+ render: (value: string) => {
92
+ return value ? getFormattedValue(+value) : '-';
93
+ },
94
+ },
95
+ ];
96
+
97
+ return (
98
+ <Table
99
+ rowKey="id"
100
+ columns={columns as any}
101
+ dataSource={data}
102
+ showHeader={!isMobile}
103
+ size="small"
104
+ pagination={false}
105
+ loading={loading}
106
+ className={`${prefixCls}-table`}
107
+ rowClassName={`${prefixCls}-table-row`}
108
+ onRow={record => {
109
+ return {
110
+ onClick: () => {
111
+ onSelect(record.id);
112
+ },
113
+ };
114
+ }}
115
+ />
116
+ );
117
+ };
118
+
119
+ const recommendOptionsClass = classNames(prefixCls, {
120
+ [`${prefixCls}-mobile-mode`]: isMobile,
121
+ });
122
+
123
+ return <div className={recommendOptionsClass}>{getSectionOptions()}</div>;
124
+ };
125
+
126
+ export default RecommendOptions;
@@ -0,0 +1,24 @@
1
+ @import '../../styles/index.less';
2
+
3
+ @recommend-options-prefix-cls: ~'@{supersonic-chat-prefix}-recommend-options';
4
+
5
+ .@{recommend-options-prefix-cls} {
6
+ padding: 8px 0 12px;
7
+
8
+ &-item-name-column {
9
+ display: flex;
10
+ align-items: center;
11
+ column-gap: 6px;
12
+ }
13
+
14
+ &-entity-name {
15
+ &:hover {
16
+ color: var(--primary-color);
17
+ }
18
+ }
19
+
20
+ &-table-row {
21
+ cursor: pointer;
22
+ }
23
+ }
24
+
@@ -0,0 +1,55 @@
1
+ import { Modal, Input, message } from 'antd';
2
+ import { CLS_PREFIX } from '../../common/constants';
3
+ import { useState } from 'react';
4
+
5
+ const { TextArea } = Input;
6
+
7
+ type Props = {
8
+ visible: boolean;
9
+ feedbackValue: string;
10
+ onSubmit: (feedback: string) => void;
11
+ onClose: () => void;
12
+ };
13
+
14
+ const FeedbackModal: React.FC<Props> = ({ visible, feedbackValue, onSubmit, onClose }) => {
15
+ const [feedback, setFeedback] = useState(feedbackValue);
16
+ const prefixCls = `${CLS_PREFIX}-tools`;
17
+
18
+ const onOk = () => {
19
+ if (feedback.trim() === '') {
20
+ message.warning('请输入点评内容');
21
+ return;
22
+ }
23
+ onSubmit(feedback);
24
+ };
25
+
26
+ const onFeedbackChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
27
+ setFeedback(e.target.value);
28
+ };
29
+
30
+ return (
31
+ <Modal
32
+ open={visible}
33
+ title="点评一下~"
34
+ onOk={onOk}
35
+ onCancel={onClose}
36
+ okText="提交"
37
+ cancelText="取消"
38
+ >
39
+ <div className={`${prefixCls}-feedback-item`}>
40
+ <div className={`${prefixCls}-feedback-item-title`}>评价</div>
41
+ <TextArea
42
+ placeholder="请输入评价"
43
+ rows={3}
44
+ value={feedback}
45
+ onChange={onFeedbackChange}
46
+ onClick={e => {
47
+ e.stopPropagation();
48
+ }}
49
+ />
50
+ </div>
51
+ </Modal>
52
+ );
53
+ };
54
+
55
+ export default FeedbackModal;
@@ -0,0 +1,126 @@
1
+ import { isMobile } from '../../utils/utils';
2
+ import {
3
+ DislikeOutlined,
4
+ LikeOutlined,
5
+ DownloadOutlined,
6
+ RedoOutlined,
7
+ FileJpgOutlined,
8
+ } from '@ant-design/icons';
9
+ import { Button } from 'antd';
10
+ import { CLS_PREFIX } from '../../common/constants';
11
+ import { useContext, useState } from 'react';
12
+ import classNames from 'classnames';
13
+ import { updateQAFeedback } from '../../service';
14
+ import { useMethodRegister } from '../../hooks';
15
+ import { ChartItemContext } from '../ChatItem';
16
+
17
+ type Props = {
18
+ queryId: number;
19
+ scoreValue?: number;
20
+ isLastMessage?: boolean;
21
+ isParserError?: boolean;
22
+ isSimpleMode?: boolean;
23
+ onExportData?: () => void;
24
+ onReExecute?: (queryId: number) => void;
25
+ };
26
+
27
+ const Tools: React.FC<Props> = ({
28
+ queryId,
29
+ scoreValue,
30
+ isLastMessage,
31
+ isParserError = false,
32
+ isSimpleMode = false,
33
+ onExportData,
34
+ onReExecute,
35
+ }) => {
36
+ const [score, setScore] = useState(scoreValue || 0);
37
+ const [exportLoading, setExportLoading] = useState<boolean>(false);
38
+ const prefixCls = `${CLS_PREFIX}-tools`;
39
+
40
+ const like = () => {
41
+ setScore(5);
42
+ updateQAFeedback(queryId, 5);
43
+ };
44
+
45
+ const dislike = () => {
46
+ setScore(1);
47
+ updateQAFeedback(queryId, 1);
48
+ };
49
+
50
+ const likeClass = classNames(`${prefixCls}-like`, {
51
+ [`${prefixCls}-feedback-active`]: score === 5,
52
+ });
53
+ const dislikeClass = classNames(`${prefixCls}-dislike`, {
54
+ [`${prefixCls}-feedback-active`]: score === 1,
55
+ });
56
+
57
+ const { call } = useContext(ChartItemContext);
58
+
59
+ return (
60
+ <div className={prefixCls}>
61
+ {!isMobile && (
62
+ <div className={`${prefixCls}-feedback`}>
63
+ {/* <div>这个回答正确吗?</div> */}
64
+
65
+ <div className={`${prefixCls}-feedback-left`}>
66
+ {!isParserError && (
67
+ <>
68
+ <Button
69
+ size="small"
70
+ onClick={() => {
71
+ setExportLoading(true);
72
+ onExportData?.();
73
+ setTimeout(() => {
74
+ setExportLoading(false);
75
+ }, 1000);
76
+ }}
77
+ type="text"
78
+ loading={exportLoading}
79
+ >
80
+ <DownloadOutlined />
81
+ <span className={`${prefixCls}-font-style`}>导出数据</span>
82
+ </Button>
83
+ {!isSimpleMode && (
84
+ <Button
85
+ size="small"
86
+ onClick={() => {
87
+ call('downloadChartAsImage');
88
+ }}
89
+ type="text"
90
+ >
91
+ <FileJpgOutlined />
92
+ <span className={`${prefixCls}-font-style`}>导出图片</span>
93
+ </Button>
94
+ )}
95
+ {isLastMessage && (
96
+ <Button
97
+ size="small"
98
+ onClick={() => {
99
+ onReExecute?.(queryId);
100
+ }}
101
+ type="text"
102
+ >
103
+ <RedoOutlined />
104
+ <span className={`${prefixCls}-font-style`}>再试一次</span>
105
+ </Button>
106
+ )}
107
+ </>
108
+ )}
109
+ </div>
110
+ <div className={`${prefixCls}-feedback-left`}>
111
+ <LikeOutlined className={likeClass} onClick={like} style={{ marginRight: 10 }} />
112
+ <DislikeOutlined
113
+ className={dislikeClass}
114
+ onClick={e => {
115
+ e.stopPropagation();
116
+ dislike();
117
+ }}
118
+ />
119
+ </div>
120
+ </div>
121
+ )}
122
+ </div>
123
+ );
124
+ };
125
+
126
+ export default Tools;
@@ -0,0 +1,67 @@
1
+ @import '../../styles/index.less';
2
+
3
+ @tools-cls: ~'@{supersonic-chat-prefix}-tools';
4
+
5
+ .@{tools-cls} {
6
+ display: flex;
7
+ align-items: center;
8
+ margin-top: 12px;
9
+ column-gap: 6px;
10
+
11
+ &-feedback {
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: space-between;
15
+ width: 100%;
16
+ padding: 0 10px 0 10px;
17
+ color: var(--text-color-third);
18
+ column-gap: 20px;
19
+ }
20
+
21
+
22
+ &-like {
23
+ margin-right: 4px;
24
+ }
25
+
26
+ &-feedback-active {
27
+ color: rgb(234, 197, 79);
28
+ }
29
+
30
+ &-mobile-tools {
31
+ display: flex;
32
+ flex-direction: column;
33
+ margin-top: 12px;
34
+ row-gap: 10px;
35
+ }
36
+
37
+ &-tools {
38
+ margin-top: 0;
39
+ }
40
+
41
+ &-feedback {
42
+ margin-left: 2px;
43
+ }
44
+
45
+ &-feedback-item {
46
+ display: flex;
47
+ align-items: flex-start;
48
+ margin-top: 20px;
49
+ margin-bottom: 20px;
50
+ }
51
+
52
+ &-feedback-item-title {
53
+ width: 40px;
54
+ margin-right: 20px;
55
+ text-align: right;
56
+ font-size: 14px;
57
+ font-weight: 500;
58
+ color: var(--text-color);
59
+ }
60
+
61
+ &-font-style {
62
+ font-size: 12px;
63
+ color: grey;
64
+ font-style: italic;
65
+ text-align: center;
66
+ }
67
+ }
@@ -0,0 +1,73 @@
1
+ import { Input } from 'antd';
2
+ import styles from './style.module.less';
3
+ import { useEffect, useState } from 'react';
4
+ import ChatItem from '../components/ChatItem';
5
+ import { MsgDataType } from '../common/type';
6
+
7
+ const { Search } = Input;
8
+
9
+ const Chat = () => {
10
+ const [inputMsg, setInputMsg] = useState('');
11
+ const [msg, setMsg] = useState('');
12
+ const [triggerResize, setTriggerResize] = useState(false);
13
+ const [chatItemVisible, setChatItemVisible] = useState(false);
14
+
15
+ const onWindowResize = () => {
16
+ setTriggerResize(true);
17
+ setTimeout(() => {
18
+ setTriggerResize(false);
19
+ }, 0);
20
+ };
21
+
22
+ useEffect(() => {
23
+ window.addEventListener('resize', onWindowResize);
24
+ return () => {
25
+ window.removeEventListener('resize', onWindowResize);
26
+ };
27
+ }, []);
28
+
29
+ const onInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
30
+ const { value } = e.target;
31
+ setInputMsg(value);
32
+ };
33
+
34
+ const onSearch = () => {
35
+ setMsg(inputMsg);
36
+ setChatItemVisible(false);
37
+ setTimeout(() => {
38
+ setChatItemVisible(true);
39
+ }, 200);
40
+ };
41
+
42
+ const onMsgDataLoaded = (msgData: MsgDataType) => {};
43
+
44
+ //预发环境: 5: 查信息,6: 智能圈选,12:问指标,15:歌曲库,16:艺人库
45
+
46
+ return (
47
+ <div className={styles.page}>
48
+ <div className={styles.inputMsg}>
49
+ <Search
50
+ placeholder="请输入问题"
51
+ value={inputMsg}
52
+ onChange={onInputChange}
53
+ onSearch={onSearch}
54
+ />
55
+ </div>
56
+ {msg && chatItemVisible && (
57
+ <div className={styles.chatItem}>
58
+ <ChatItem
59
+ msg={msg}
60
+ agentId={5}
61
+ conversationId={112211121}
62
+ onMsgDataLoaded={onMsgDataLoaded}
63
+ triggerResize={triggerResize}
64
+ integrateSystem="wiki"
65
+ isDeveloper
66
+ />
67
+ </div>
68
+ )}
69
+ </div>
70
+ );
71
+ };
72
+
73
+ export default Chat;
@@ -0,0 +1,14 @@
1
+ import Chat from '../Chat';
2
+ import styles from './style.module.less';
3
+
4
+ type Props = {};
5
+
6
+ const ChatDemo: React.FC<Props> = () => {
7
+ return (
8
+ <div className={styles.chatDemo}>
9
+ <Chat isDeveloper />
10
+ </div>
11
+ );
12
+ };
13
+
14
+ export default ChatDemo;
@@ -0,0 +1,43 @@
1
+ import { Button, Space } from 'antd';
2
+ import styles from './style.module.less';
3
+ import Copilot from '../Copilot';
4
+ import { useRef } from 'react';
5
+
6
+ const buttonParams = [
7
+ {
8
+ msg: '周杰伦 艺人趋势解读',
9
+ agentId: 8,
10
+ modelId: 23,
11
+ filters: [{ bizName: 'singer_id', elementID: 283, value: 4558 }],
12
+ },
13
+ {
14
+ msg: '林俊杰 艺人趋势解读',
15
+ agentId: 8,
16
+ modelId: 23,
17
+ filters: [{ bizName: 'singer_id', elementID: 283, value: 4286 }],
18
+ },
19
+ ];
20
+
21
+ const CopilotDemo = () => {
22
+ const copilotRef = useRef<any>();
23
+
24
+ return (
25
+ <div className={styles.copilotDemo}>
26
+ <Space>
27
+ {buttonParams.map(params => (
28
+ <Button
29
+ key={params.msg}
30
+ onClick={() => {
31
+ copilotRef?.current?.sendCopilotMsg(params);
32
+ }}
33
+ >
34
+ {params.msg}
35
+ </Button>
36
+ ))}
37
+ </Space>
38
+ <Copilot isDeveloper ref={copilotRef} />
39
+ </div>
40
+ );
41
+ };
42
+
43
+ export default CopilotDemo;
@@ -0,0 +1,19 @@
1
+ .page {
2
+ display: flex;
3
+ flex-direction: column;
4
+ row-gap: 20px;
5
+ padding: 20px;
6
+ background:
7
+ linear-gradient(180deg,rgba(23,74,228,0) 29.44%,rgba(23,74,228,.06)),linear-gradient(90deg,#f3f3f7,#f3f3f7 20%,#ebf0f9 60%,#f3f3f7 80%,#f3f3f7);
8
+ height: 100vh;
9
+ overflow: auto;
10
+ box-sizing: border-box;
11
+ }
12
+
13
+ .copilotDemo {
14
+ padding: 20px;
15
+ }
16
+
17
+ .chatDemo {
18
+ height: 100vh;
19
+ }
@@ -0,0 +1,3 @@
1
+ export * from './useMethodRegister';
2
+ export * from './useComposing';
3
+ export * from './useExportByEcharts';