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.
- package/.prettierrc.js +24 -0
- package/README.md +46 -0
- package/config/env.js +104 -0
- package/config/getHttpsConfig.js +66 -0
- package/config/jest/babelTransform.js +29 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +134 -0
- package/config/paths.js +77 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +785 -0
- package/config/webpackDevServer.config.js +127 -0
- package/dist/Chat/AgentList/index.d.ts +9 -0
- package/dist/Chat/ChatFooter/index.d.ts +17 -0
- package/dist/Chat/Conversation/index.d.ts +11 -0
- package/dist/Chat/MessageContainer/index.d.ts +19 -0
- package/dist/Chat/MobileAgents/index.d.ts +11 -0
- package/dist/Chat/components/AgentTip/index.d.ts +8 -0
- package/dist/Chat/components/ConversationModal/index.d.ts +10 -0
- package/dist/Chat/components/CopilotAvatar/index.d.ts +2 -0
- package/dist/Chat/components/Message.d.ts +10 -0
- package/dist/Chat/components/RecommendQuestions/index.d.ts +6 -0
- package/dist/Chat/components/Text.d.ts +9 -0
- package/dist/Chat/constants.d.ts +19 -0
- package/dist/Chat/index.d.ts +17 -0
- package/dist/Chat/service.d.ts +11 -0
- package/dist/Chat/type.d.ts +97 -0
- package/dist/Copilot/constants.d.ts +11 -0
- package/dist/Copilot/index.d.ts +13 -0
- package/dist/ShowCase/index.d.ts +8 -0
- package/dist/ShowCase/service.d.ts +2 -0
- package/dist/ShowCase/type.d.ts +11 -0
- package/dist/common/constants.d.ts +58 -0
- package/dist/common/env.d.ts +3 -0
- package/dist/common/type.d.ts +247 -0
- package/dist/components/ChatItem/ExecuteItem.d.ts +25 -0
- package/dist/components/ChatItem/ExpandParseTip.d.ts +20 -0
- package/dist/components/ChatItem/FilterItem.d.ts +17 -0
- package/dist/components/ChatItem/Loading.d.ts +2 -0
- package/dist/components/ChatItem/ParseTip.d.ts +26 -0
- package/dist/components/ChatItem/ParseTipUtils.d.ts +10 -0
- package/dist/components/ChatItem/SimilarQuestionItem.d.ts +10 -0
- package/dist/components/ChatItem/SqlItem.d.ts +17 -0
- package/dist/components/ChatItem/SwitchEntity.d.ts +9 -0
- package/dist/components/ChatItem/Text.d.ts +6 -0
- package/dist/components/ChatItem/Typing.d.ts +2 -0
- package/dist/components/ChatItem/index.d.ts +33 -0
- package/dist/components/ChatMsg/ApplyAuth/index.d.ts +7 -0
- package/dist/components/ChatMsg/Bar/index.d.ts +13 -0
- package/dist/components/ChatMsg/DateOptions/index.d.ts +9 -0
- package/dist/components/ChatMsg/FilterSection/index.d.ts +8 -0
- package/dist/components/ChatMsg/MarkDown/index.d.ts +10 -0
- package/dist/components/ChatMsg/Message/index.d.ts +18 -0
- package/dist/components/ChatMsg/MetricCard/PeriodCompareItem.d.ts +7 -0
- package/dist/components/ChatMsg/MetricCard/index.d.ts +10 -0
- package/dist/components/ChatMsg/MetricTrend/MetricInfo.d.ts +8 -0
- package/dist/components/ChatMsg/MetricTrend/MetricTrendChart.d.ts +14 -0
- package/dist/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.d.ts +12 -0
- package/dist/components/ChatMsg/MetricTrend/index.d.ts +16 -0
- package/dist/components/ChatMsg/NoPermissionChart/index.d.ts +8 -0
- package/dist/components/ChatMsg/Pie/PieChart.d.ts +11 -0
- package/dist/components/ChatMsg/Pie/index.d.ts +14 -0
- package/dist/components/ChatMsg/Table/index.d.ts +12 -0
- package/dist/components/ChatMsg/Text/index.d.ts +9 -0
- package/dist/components/ChatMsg/WebPage/index.d.ts +8 -0
- package/dist/components/ChatMsg/index.d.ts +15 -0
- package/dist/components/DrillDownDimensions/DimensionSection.d.ts +11 -0
- package/dist/components/DrillDownDimensions/index.d.ts +13 -0
- package/dist/components/IconFont/index.d.ts +3 -0
- package/dist/components/MetricOptions/index.d.ts +11 -0
- package/dist/components/RecommendOptions/index.d.ts +9 -0
- package/dist/components/Tools/FeedbackModal.d.ts +9 -0
- package/dist/components/Tools/index.d.ts +12 -0
- package/dist/demo/Chat.d.ts +2 -0
- package/dist/demo/ChatDemo.d.ts +4 -0
- package/dist/demo/CopilotDemo.d.ts +2 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useComposing.d.ts +5 -0
- package/dist/hooks/useExportByEcharts.d.ts +10 -0
- package/dist/hooks/useMethodRegister.d.ts +4 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.es.js +1 -0
- package/dist/service/axiosInstance.d.ts +3 -0
- package/dist/service/index.d.ts +25 -0
- package/dist/utils/utils.d.ts +45 -0
- package/package.json +214 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/manifest.json +15 -0
- package/public/robots.txt +3 -0
- package/rollup/rollup.config.mjs +37 -0
- package/rollup/rollup.esm.config.mjs +21 -0
- package/rollup/rollup.umd.config.mjs +30 -0
- package/scripts/build.js +217 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +52 -0
- package/src/Chat/AgentList/index.tsx +52 -0
- package/src/Chat/AgentList/style.module.less +83 -0
- package/src/Chat/ChatFooter/index.tsx +423 -0
- package/src/Chat/ChatFooter/style.module.less +225 -0
- package/src/Chat/Conversation/index.tsx +236 -0
- package/src/Chat/Conversation/style.module.less +171 -0
- package/src/Chat/MessageContainer/index.tsx +145 -0
- package/src/Chat/MessageContainer/style.module.less +53 -0
- package/src/Chat/MobileAgents/index.tsx +62 -0
- package/src/Chat/MobileAgents/style.module.less +55 -0
- package/src/Chat/components/AgentTip/index.tsx +48 -0
- package/src/Chat/components/AgentTip/style.module.less +44 -0
- package/src/Chat/components/ConversationModal/index.tsx +65 -0
- package/src/Chat/components/CopilotAvatar/index.tsx +8 -0
- package/src/Chat/components/CopilotAvatar/style.module.less +13 -0
- package/src/Chat/components/Message.tsx +38 -0
- package/src/Chat/components/RecommendQuestions/index.tsx +64 -0
- package/src/Chat/components/RecommendQuestions/style.module.less +36 -0
- package/src/Chat/components/Text.tsx +42 -0
- package/src/Chat/components/style.module.less +311 -0
- package/src/Chat/constants.ts +37 -0
- package/src/Chat/index.tsx +526 -0
- package/src/Chat/service.ts +49 -0
- package/src/Chat/style.module.less +119 -0
- package/src/Chat/type.ts +107 -0
- package/src/Copilot/constants.ts +11 -0
- package/src/Copilot/index.tsx +149 -0
- package/src/Copilot/style.module.less +151 -0
- package/src/ShowCase/index.tsx +120 -0
- package/src/ShowCase/service.ts +12 -0
- package/src/ShowCase/style.module.less +46 -0
- package/src/ShowCase/type.ts +14 -0
- package/src/common/constants.ts +93 -0
- package/src/common/env.ts +5 -0
- package/src/common/type.ts +270 -0
- package/src/components/ChatItem/ExecuteItem.tsx +210 -0
- package/src/components/ChatItem/ExpandParseTip.tsx +333 -0
- package/src/components/ChatItem/FilterItem.tsx +209 -0
- package/src/components/ChatItem/Loading.tsx +14 -0
- package/src/components/ChatItem/ParseTip.tsx +322 -0
- package/src/components/ChatItem/ParseTipUtils.tsx +205 -0
- package/src/components/ChatItem/SimilarQuestionItem.tsx +84 -0
- package/src/components/ChatItem/SqlItem.tsx +410 -0
- package/src/components/ChatItem/SwitchEntity.tsx +52 -0
- package/src/components/ChatItem/Text.tsx +17 -0
- package/src/components/ChatItem/Typing.tsx +19 -0
- package/src/components/ChatItem/index.tsx +843 -0
- package/src/components/ChatItem/style.less +670 -0
- package/src/components/ChatMsg/ApplyAuth/index.tsx +30 -0
- package/src/components/ChatMsg/ApplyAuth/style.less +13 -0
- package/src/components/ChatMsg/Bar/index.tsx +208 -0
- package/src/components/ChatMsg/Bar/style.less +60 -0
- package/src/components/ChatMsg/DateOptions/index.tsx +46 -0
- package/src/components/ChatMsg/DateOptions/style.less +43 -0
- package/src/components/ChatMsg/FilterSection/index.tsx +42 -0
- package/src/components/ChatMsg/FilterSection/style.less +37 -0
- package/src/components/ChatMsg/MarkDown/index.tsx +26 -0
- package/src/components/ChatMsg/MarkDown/style.less +9 -0
- package/src/components/ChatMsg/Message/index.tsx +105 -0
- package/src/components/ChatMsg/Message/style.less +119 -0
- package/src/components/ChatMsg/MetricCard/PeriodCompareItem.tsx +29 -0
- package/src/components/ChatMsg/MetricCard/index.tsx +80 -0
- package/src/components/ChatMsg/MetricCard/style.less +126 -0
- package/src/components/ChatMsg/MetricTrend/MetricInfo.tsx +60 -0
- package/src/components/ChatMsg/MetricTrend/MetricTrendChart.tsx +235 -0
- package/src/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.tsx +162 -0
- package/src/components/ChatMsg/MetricTrend/index.tsx +127 -0
- package/src/components/ChatMsg/MetricTrend/style.less +195 -0
- package/src/components/ChatMsg/NoPermissionChart/index.tsx +28 -0
- package/src/components/ChatMsg/NoPermissionChart/style.less +26 -0
- package/src/components/ChatMsg/Pie/PieChart.tsx +120 -0
- package/src/components/ChatMsg/Pie/index.tsx +88 -0
- package/src/components/ChatMsg/Pie/style.less +43 -0
- package/src/components/ChatMsg/Table/index.tsx +103 -0
- package/src/components/ChatMsg/Table/style.less +131 -0
- package/src/components/ChatMsg/Text/index.tsx +70 -0
- package/src/components/ChatMsg/Text/style.less +38 -0
- package/src/components/ChatMsg/WebPage/index.tsx +125 -0
- package/src/components/ChatMsg/index.tsx +428 -0
- package/src/components/ChatMsg/style.less +28 -0
- package/src/components/DrillDownDimensions/DimensionSection.tsx +99 -0
- package/src/components/DrillDownDimensions/index.tsx +76 -0
- package/src/components/DrillDownDimensions/style.less +64 -0
- package/src/components/IconFont/index.tsx +7 -0
- package/src/components/MetricOptions/index.tsx +75 -0
- package/src/components/MetricOptions/style.less +69 -0
- package/src/components/RecommendOptions/index.tsx +126 -0
- package/src/components/RecommendOptions/style.less +24 -0
- package/src/components/Tools/FeedbackModal.tsx +55 -0
- package/src/components/Tools/index.tsx +126 -0
- package/src/components/Tools/style.less +67 -0
- package/src/demo/Chat.tsx +73 -0
- package/src/demo/ChatDemo.tsx +14 -0
- package/src/demo/CopilotDemo.tsx +43 -0
- package/src/demo/style.module.less +19 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useComposing.ts +31 -0
- package/src/hooks/useExportByEcharts.ts +41 -0
- package/src/hooks/useMethodRegister.ts +25 -0
- package/src/index.tsx +44 -0
- package/src/service/axiosInstance.ts +58 -0
- package/src/service/index.ts +174 -0
- package/src/setupProxy.js +18 -0
- package/src/setupTests.ts +5 -0
- package/src/styles/global.less +52 -0
- package/src/styles/index.less +39 -0
- package/src/styles/reboot.less +14 -0
- package/src/styles/variables.less +80 -0
- package/src/typings.d.ts +179 -0
- package/src/utils/utils.ts +346 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +27 -0
package/src/Chat/type.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ChatContextType, MsgDataType, ParseTimeCostType, SendMsgParamsType } from '../common/type';
|
|
2
|
+
|
|
3
|
+
export enum MessageTypeEnum {
|
|
4
|
+
TEXT = 'text', // 指标文本
|
|
5
|
+
QUESTION = 'question',
|
|
6
|
+
TAG = 'tag', // 标签
|
|
7
|
+
SUGGESTION = 'suggestion', // 建议
|
|
8
|
+
NO_PERMISSION = 'no_permission', // 无权限
|
|
9
|
+
SEMANTIC_DETAIL = 'semantic_detail', // 语义指标/维度等信息详情
|
|
10
|
+
PLUGIN = 'PLUGIN', // 插件
|
|
11
|
+
WEB_PAGE = 'WEB_PAGE', // 插件
|
|
12
|
+
RECOMMEND_QUESTIONS = 'recommend_questions', // 推荐问题
|
|
13
|
+
AGENT_LIST = 'agent_list', // 专家列表
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type MessageItem = {
|
|
17
|
+
id: string | number;
|
|
18
|
+
type?: MessageTypeEnum;
|
|
19
|
+
msg?: string;
|
|
20
|
+
questionId?: number;
|
|
21
|
+
msgValue?: string;
|
|
22
|
+
identityMsg?: string;
|
|
23
|
+
modelId?: number;
|
|
24
|
+
agentId?: number;
|
|
25
|
+
entityId?: string;
|
|
26
|
+
parseInfos?: ChatContextType[];
|
|
27
|
+
parseTimeCost?: ParseTimeCostType;
|
|
28
|
+
msgData?: MsgDataType;
|
|
29
|
+
quote?: string;
|
|
30
|
+
score?: number;
|
|
31
|
+
feedback?: string;
|
|
32
|
+
filters?: any;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ConversationDetailType = {
|
|
36
|
+
chatId: number;
|
|
37
|
+
chatName: string;
|
|
38
|
+
createTime?: string;
|
|
39
|
+
creator?: string;
|
|
40
|
+
lastQuestion?: string;
|
|
41
|
+
lastTime?: string;
|
|
42
|
+
initialMsgParams?: SendMsgParamsType;
|
|
43
|
+
isAdd?: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export enum MessageModeEnum {
|
|
47
|
+
INTERPRET = 'interpret',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ModelType = {
|
|
51
|
+
id: number;
|
|
52
|
+
name: string;
|
|
53
|
+
bizName: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export enum PluginShowTypeEnum {
|
|
57
|
+
DASHBOARD = 'DASHBOARD',
|
|
58
|
+
WIDGET = 'WIDGET',
|
|
59
|
+
URL = 'URL',
|
|
60
|
+
TAG = 'TAG',
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type PluginType = {
|
|
64
|
+
id: number;
|
|
65
|
+
name: string;
|
|
66
|
+
comment: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type SuggestionItemType = {
|
|
70
|
+
id: number;
|
|
71
|
+
model: number;
|
|
72
|
+
name: string;
|
|
73
|
+
bizName: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type SuggestionType = {
|
|
77
|
+
dimensions: SuggestionItemType[];
|
|
78
|
+
metrics: SuggestionItemType[];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type AgentType = {
|
|
82
|
+
id: number;
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
examples: string[];
|
|
86
|
+
status: 0 | 1;
|
|
87
|
+
initialSendMsgParams?: SendMsgParamsType;
|
|
88
|
+
createdBy: string;
|
|
89
|
+
updatedBy: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
enableSearch: number;
|
|
93
|
+
enableFeedback: number;
|
|
94
|
+
toolConfig: string;
|
|
95
|
+
modelConfig: {
|
|
96
|
+
provider: string;
|
|
97
|
+
baseUrl: string;
|
|
98
|
+
apiKey: string;
|
|
99
|
+
modelName: string;
|
|
100
|
+
temperature: number;
|
|
101
|
+
timeOut: number;
|
|
102
|
+
};
|
|
103
|
+
multiTurnConfig: {
|
|
104
|
+
enableMultiTurn: boolean;
|
|
105
|
+
};
|
|
106
|
+
dataSetIds: number[];
|
|
107
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import IconFont from '../components/IconFont';
|
|
2
|
+
import { CaretRightOutlined, CloseOutlined } from '@ant-design/icons';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import {
|
|
5
|
+
ForwardRefRenderFunction,
|
|
6
|
+
forwardRef,
|
|
7
|
+
useEffect,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import Chat from '../Chat';
|
|
13
|
+
import { AgentType } from '../Chat/type';
|
|
14
|
+
import { setToken } from '../utils/utils';
|
|
15
|
+
import { SendMsgParamsType } from '../common/type';
|
|
16
|
+
import styles from './style.module.less';
|
|
17
|
+
import { copilotTitle } from '../common/env';
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
token?: string;
|
|
21
|
+
agentIds?: number[];
|
|
22
|
+
noInput?: boolean;
|
|
23
|
+
isDeveloper?: boolean;
|
|
24
|
+
integrateSystem?: string;
|
|
25
|
+
apiUrl?: string;
|
|
26
|
+
onReportMsgEvent?: (msg: string, valid: boolean) => void;
|
|
27
|
+
onOpenChatPage?: (agentId?: number) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const Copilot: ForwardRefRenderFunction<any, Props> = (
|
|
31
|
+
{
|
|
32
|
+
token,
|
|
33
|
+
agentIds,
|
|
34
|
+
noInput,
|
|
35
|
+
isDeveloper,
|
|
36
|
+
integrateSystem,
|
|
37
|
+
apiUrl,
|
|
38
|
+
onReportMsgEvent,
|
|
39
|
+
onOpenChatPage,
|
|
40
|
+
},
|
|
41
|
+
ref
|
|
42
|
+
) => {
|
|
43
|
+
const [chatVisible, setChatVisible] = useState(false);
|
|
44
|
+
const [copilotMinimized, setCopilotMinimized] = useState(false);
|
|
45
|
+
const [currentAgent, setCurrentAgent] = useState<AgentType>();
|
|
46
|
+
|
|
47
|
+
const chatRef = useRef<any>();
|
|
48
|
+
|
|
49
|
+
useImperativeHandle(ref, () => ({
|
|
50
|
+
sendCopilotMsg,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (token) {
|
|
55
|
+
setToken(token);
|
|
56
|
+
}
|
|
57
|
+
}, [token]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (apiUrl) {
|
|
61
|
+
localStorage.setItem('SUPERSONIC_CHAT_API_URL', apiUrl);
|
|
62
|
+
}
|
|
63
|
+
}, [apiUrl]);
|
|
64
|
+
|
|
65
|
+
const sendCopilotMsg = (params: SendMsgParamsType) => {
|
|
66
|
+
chatRef?.current?.sendCopilotMsg(params);
|
|
67
|
+
updateChatVisible(true);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const updateChatVisible = (visible: boolean) => {
|
|
71
|
+
setChatVisible(visible);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const onToggleChatVisible = () => {
|
|
75
|
+
updateChatVisible(!chatVisible);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const onCloseChat = () => {
|
|
79
|
+
updateChatVisible(false);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const onTransferChat = () => {
|
|
83
|
+
onOpenChatPage?.(currentAgent?.id);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const onMinimizeCopilot = (e: any) => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
updateChatVisible(false);
|
|
89
|
+
setCopilotMinimized(true);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const copilotClass = classNames(styles.copilot, {
|
|
93
|
+
[styles.copilotMinimized]: copilotMinimized,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const chatPopoverClass = classNames(styles.chatPopover, {
|
|
97
|
+
[styles.c2System]: integrateSystem === 'c2',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<div
|
|
103
|
+
className={copilotClass}
|
|
104
|
+
onMouseEnter={() => {
|
|
105
|
+
setCopilotMinimized(false);
|
|
106
|
+
}}
|
|
107
|
+
onClick={onToggleChatVisible}
|
|
108
|
+
>
|
|
109
|
+
<IconFont type="icon-copilot-fill" />
|
|
110
|
+
<div className={styles.minimizeWrapper} onClick={onMinimizeCopilot}>
|
|
111
|
+
<div className={styles.minimize}>-</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
<div className={styles.copilotContent} style={{ display: chatVisible ? 'block' : 'none' }}>
|
|
115
|
+
<div className={chatPopoverClass}>
|
|
116
|
+
<div className={styles.header}>
|
|
117
|
+
<div className={styles.leftSection}>
|
|
118
|
+
<CloseOutlined className={styles.close} onClick={onCloseChat} />
|
|
119
|
+
{onOpenChatPage && (
|
|
120
|
+
<IconFont
|
|
121
|
+
type="icon-weibiaoti-"
|
|
122
|
+
className={styles.transfer}
|
|
123
|
+
onClick={onTransferChat}
|
|
124
|
+
/>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
<div className={styles.title}>{copilotTitle}</div>
|
|
128
|
+
</div>
|
|
129
|
+
<div className={styles.chat}>
|
|
130
|
+
<Chat
|
|
131
|
+
chatVisible={chatVisible}
|
|
132
|
+
agentIds={agentIds}
|
|
133
|
+
noInput={noInput}
|
|
134
|
+
isDeveloper={isDeveloper}
|
|
135
|
+
integrateSystem={integrateSystem}
|
|
136
|
+
isCopilot
|
|
137
|
+
onCurrentAgentChange={setCurrentAgent}
|
|
138
|
+
onReportMsgEvent={onReportMsgEvent}
|
|
139
|
+
ref={chatRef}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
<CaretRightOutlined className={styles.rightArrow} />
|
|
144
|
+
</div>
|
|
145
|
+
</>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default forwardRef(Copilot);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
.copilot {
|
|
2
|
+
position: fixed;
|
|
3
|
+
right: 8px;
|
|
4
|
+
bottom: 220px;
|
|
5
|
+
z-index: 999;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
width: 54px;
|
|
12
|
+
height: 54px;
|
|
13
|
+
color: #fff;
|
|
14
|
+
font-size: 26px;
|
|
15
|
+
background-color: var(--chat-blue);
|
|
16
|
+
background-clip: padding-box;
|
|
17
|
+
border: 2px solid #fff;
|
|
18
|
+
border-radius: 50%;
|
|
19
|
+
box-shadow: 8px 8px 20px 0 rgba(55, 99, 170, 0.1);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
transition: all 0.2s ease-in-out;
|
|
22
|
+
|
|
23
|
+
&.copilotMinimized {
|
|
24
|
+
right: -40px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.minimizeWrapper {
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: -18px;
|
|
30
|
+
right: -6px;
|
|
31
|
+
display: none;
|
|
32
|
+
width: 22px;
|
|
33
|
+
height: 22px;
|
|
34
|
+
padding: 4px;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
|
|
37
|
+
.minimize {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
padding-bottom: 5px;
|
|
44
|
+
background-color: var(--text-color-fifth-4);
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
transition: all 0.1s ease-in-out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
.minimize {
|
|
51
|
+
background-color: var(--text-color-fifth);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:hover {
|
|
57
|
+
text-decoration: none;
|
|
58
|
+
box-shadow: 8px 8px 20px rgba(55, 99, 170, 0.3);
|
|
59
|
+
|
|
60
|
+
.minimizeWrapper {
|
|
61
|
+
display: block;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.chatPopover {
|
|
67
|
+
position: fixed;
|
|
68
|
+
right: 90px;
|
|
69
|
+
bottom: 5vh;
|
|
70
|
+
z-index: 999;
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
width: 70vw;
|
|
74
|
+
min-width: 1100px;
|
|
75
|
+
height: 90vh;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
box-shadow: 4px 4px 10px rgba(55, 99, 170, 0.3), -2px -2px 16px rgba(55, 99, 170, 0.3);
|
|
78
|
+
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out,
|
|
79
|
+
-webkit-transform 0.3s ease-in-out;
|
|
80
|
+
|
|
81
|
+
&.c2System {
|
|
82
|
+
width: calc(100vw - 180px);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.header {
|
|
86
|
+
position: relative;
|
|
87
|
+
z-index: 99;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
height: 40px;
|
|
92
|
+
padding-right: 16px;
|
|
93
|
+
padding-left: 16px;
|
|
94
|
+
background: linear-gradient(81.62deg, #2870ea 8.72%, var(--chat-blue) 85.01%);
|
|
95
|
+
box-shadow: 1px 1px 8px #1b4aef5c;
|
|
96
|
+
|
|
97
|
+
.title {
|
|
98
|
+
color: #fff;
|
|
99
|
+
font-weight: 700;
|
|
100
|
+
font-size: 16px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.leftSection {
|
|
104
|
+
position: absolute;
|
|
105
|
+
left: 16px;
|
|
106
|
+
display: flex;
|
|
107
|
+
align-items: center;
|
|
108
|
+
color: #fff;
|
|
109
|
+
font-size: 16px;
|
|
110
|
+
column-gap: 20px;
|
|
111
|
+
|
|
112
|
+
.close {
|
|
113
|
+
font-size: 18px;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.transfer {
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.fullscreen {
|
|
122
|
+
font-size: 20px;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.chat {
|
|
129
|
+
height: calc(90vh - 40px);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&.fullscreen {
|
|
133
|
+
bottom: 0;
|
|
134
|
+
left: 60px;
|
|
135
|
+
width: calc(100vw - 150px);
|
|
136
|
+
height: 100vh;
|
|
137
|
+
|
|
138
|
+
.chat {
|
|
139
|
+
height: calc(100vh - 50px);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.rightArrow {
|
|
145
|
+
position: fixed;
|
|
146
|
+
right: 69px;
|
|
147
|
+
bottom: 232px;
|
|
148
|
+
z-index: 999;
|
|
149
|
+
color: var(--chat-blue);
|
|
150
|
+
font-size: 30px;
|
|
151
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import styles from './style.module.less';
|
|
3
|
+
import { ShowCaseItemType } from './type';
|
|
4
|
+
import { queryShowCase } from './service';
|
|
5
|
+
import Text from '../Chat/components/Text';
|
|
6
|
+
import ChatItem from '../components/ChatItem';
|
|
7
|
+
import { HistoryMsgItemType } from '../common/type';
|
|
8
|
+
import { Spin } from 'antd';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import { isMobile } from '../utils/utils';
|
|
11
|
+
import { useThrottleFn } from 'ahooks';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
height?: number | string;
|
|
15
|
+
agentId: number;
|
|
16
|
+
onSendMsg?: (msg: string) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const ShowCase: React.FC<Props> = ({ height, agentId, onSendMsg }) => {
|
|
20
|
+
const [showCaseList, setShowCaseList] = useState<ShowCaseItemType[]>([]);
|
|
21
|
+
const [loading, setLoading] = useState(false);
|
|
22
|
+
const [pageNo, setPageNo] = useState(1);
|
|
23
|
+
|
|
24
|
+
const showcaseRef = useRef<any>(null);
|
|
25
|
+
|
|
26
|
+
const updateData = async (pageNoValue: number) => {
|
|
27
|
+
if (pageNoValue === 1) {
|
|
28
|
+
setLoading(true);
|
|
29
|
+
}
|
|
30
|
+
const res = await queryShowCase(agentId, pageNoValue, isMobile ? 10 : 20);
|
|
31
|
+
if (pageNoValue === 1) {
|
|
32
|
+
setLoading(false);
|
|
33
|
+
}
|
|
34
|
+
const showCaseMapRes: any = res.data.showCaseMap || {};
|
|
35
|
+
const list = Object.keys(showCaseMapRes)
|
|
36
|
+
.reduce((result: ShowCaseItemType[], key: string) => {
|
|
37
|
+
result.push({ msgList: showCaseMapRes[key], caseId: key });
|
|
38
|
+
return result;
|
|
39
|
+
}, [])
|
|
40
|
+
.sort((a, b) => {
|
|
41
|
+
return (b.msgList?.[0]?.score || 3) - (a.msgList?.[0]?.score || 3);
|
|
42
|
+
});
|
|
43
|
+
setShowCaseList(pageNoValue === 1 ? list : [...showCaseList, ...list]);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const { run: handleScroll } = useThrottleFn(
|
|
47
|
+
e => {
|
|
48
|
+
const bottom =
|
|
49
|
+
e.target.scrollHeight - e.target.scrollTop === e.target.clientHeight ||
|
|
50
|
+
e.target.scrollHeight - e.target.scrollTop === e.target.clientHeight + 0.5;
|
|
51
|
+
if (bottom) {
|
|
52
|
+
updateData(pageNo + 1);
|
|
53
|
+
setPageNo(pageNo + 1);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
leading: true,
|
|
58
|
+
trailing: true,
|
|
59
|
+
wait: 200,
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (isMobile) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const el = showcaseRef.current;
|
|
68
|
+
el?.addEventListener('scroll', handleScroll);
|
|
69
|
+
return () => {
|
|
70
|
+
el.removeEventListener('scroll', handleScroll);
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (agentId) {
|
|
76
|
+
setShowCaseList([]);
|
|
77
|
+
updateData(1);
|
|
78
|
+
setPageNo(1);
|
|
79
|
+
}
|
|
80
|
+
}, [agentId]);
|
|
81
|
+
|
|
82
|
+
const showCaseClass = classNames(styles.showCase, { [styles.mobile]: isMobile });
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Spin spinning={loading} size="large">
|
|
86
|
+
<div className={showCaseClass} style={{ height }} ref={showcaseRef}>
|
|
87
|
+
<div className={styles.showCaseContent}>
|
|
88
|
+
{showCaseList.map(showCaseItem => {
|
|
89
|
+
return (
|
|
90
|
+
<div key={showCaseItem.caseId} className={styles.showCaseItem}>
|
|
91
|
+
{showCaseItem.msgList
|
|
92
|
+
.filter((chatItem: HistoryMsgItemType) => !!chatItem.queryResult)
|
|
93
|
+
.slice(0, 1)
|
|
94
|
+
.map((chatItem: HistoryMsgItemType) => {
|
|
95
|
+
return (
|
|
96
|
+
<div className={styles.showCaseChatItem} key={chatItem.questionId}>
|
|
97
|
+
<Text position="right" data={chatItem.queryText} anonymousUser />
|
|
98
|
+
<ChatItem
|
|
99
|
+
msg={chatItem.queryText}
|
|
100
|
+
parseInfos={chatItem.parseInfos}
|
|
101
|
+
msgData={chatItem.queryResult}
|
|
102
|
+
conversationId={chatItem.chatId}
|
|
103
|
+
agentId={agentId}
|
|
104
|
+
integrateSystem="showcase"
|
|
105
|
+
score={chatItem.score}
|
|
106
|
+
onSendMsg={onSendMsg}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
})}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</Spin>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default ShowCase;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import axios from '../service/axiosInstance';
|
|
2
|
+
import { isMobile } from '../utils/utils';
|
|
3
|
+
import { ShowCaseType } from './type';
|
|
4
|
+
|
|
5
|
+
const prefix = isMobile ? '/openapi' : '/api';
|
|
6
|
+
|
|
7
|
+
export function queryShowCase(agentId: number, current: number, pageSize: number) {
|
|
8
|
+
return axios.post<ShowCaseType>(`${prefix}/chat/manage/queryShowCase?agentId=${agentId}`, {
|
|
9
|
+
current,
|
|
10
|
+
pageSize,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.showCase {
|
|
2
|
+
position: relative;
|
|
3
|
+
height: 100%;
|
|
4
|
+
padding: 0 20px;
|
|
5
|
+
overflow-y: auto;
|
|
6
|
+
padding-bottom: 2px;
|
|
7
|
+
|
|
8
|
+
.showCaseContent {
|
|
9
|
+
column-count: 2;
|
|
10
|
+
column-gap: 20px;
|
|
11
|
+
|
|
12
|
+
.showcaseLoading {
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 400px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.showCaseItem {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
row-gap: 12px;
|
|
24
|
+
padding: 12px;
|
|
25
|
+
margin-bottom: 20px;
|
|
26
|
+
overflow-y: auto;
|
|
27
|
+
border-radius: 12px;
|
|
28
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12);
|
|
29
|
+
background: linear-gradient(180deg, rgba(23, 74, 228, 0) 29.44%, rgba(23, 74, 228, 0.06) 100%),
|
|
30
|
+
linear-gradient(90deg, #f3f3f7 0%, #f3f3f7 20%, #ebf0f9 60%, #f3f3f7 80%, #f3f3f7 100%);
|
|
31
|
+
|
|
32
|
+
.showCaseChatItem {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
row-gap: 12px;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.mobile {
|
|
41
|
+
padding: 0 4px;
|
|
42
|
+
.showCaseContent {
|
|
43
|
+
column-count: 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HistoryMsgItemType } from "../common/type";
|
|
2
|
+
|
|
3
|
+
export type ShowCaseMapType = Record<number, HistoryMsgItemType[]>;
|
|
4
|
+
|
|
5
|
+
export type ShowCaseItemType = {
|
|
6
|
+
caseId: string;
|
|
7
|
+
msgList: HistoryMsgItemType[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ShowCaseType = {
|
|
11
|
+
showCaseMap: ShowCaseMapType,
|
|
12
|
+
current: number,
|
|
13
|
+
pageSize: number,
|
|
14
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { MsgValidTypeEnum } from './type';
|
|
2
|
+
|
|
3
|
+
export enum NumericUnit {
|
|
4
|
+
None = '无',
|
|
5
|
+
TenThousand = '万',
|
|
6
|
+
EnTenThousand = 'w',
|
|
7
|
+
OneHundredMillion = '亿',
|
|
8
|
+
Thousand = 'k',
|
|
9
|
+
Million = 'M',
|
|
10
|
+
Giga = 'G',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PRIMARY_COLOR = '#f87653';
|
|
14
|
+
export const CHART_BLUE_COLOR = '#446dff';
|
|
15
|
+
|
|
16
|
+
export const CHAT_BLUE = '#1b4aef';
|
|
17
|
+
|
|
18
|
+
export const CHART_SECONDARY_COLOR = 'rgba(153, 153, 153, 0.3)';
|
|
19
|
+
|
|
20
|
+
export const CLS_PREFIX = 'ss-chat';
|
|
21
|
+
|
|
22
|
+
export const DATE_TYPES = {
|
|
23
|
+
DAY: [
|
|
24
|
+
{ label: '近7天', value: 7 },
|
|
25
|
+
{ label: '近30天', value: 30 },
|
|
26
|
+
{ label: '近60天', value: 60 },
|
|
27
|
+
{ label: '近90天', value: 90 },
|
|
28
|
+
],
|
|
29
|
+
WEEK: [
|
|
30
|
+
{ label: '近4周', value: 4 },
|
|
31
|
+
{ label: '近12周', value: 12 },
|
|
32
|
+
{ label: '近24周', value: 24 },
|
|
33
|
+
{ label: '近52周', value: 52 },
|
|
34
|
+
],
|
|
35
|
+
MONTH: [
|
|
36
|
+
{ label: '近3个月', value: 3 },
|
|
37
|
+
{ label: '近6个月', value: 6 },
|
|
38
|
+
{ label: '近12个月', value: 12 },
|
|
39
|
+
{ label: '近24个月', value: 24 },
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const THEME_COLOR_LIST = [
|
|
44
|
+
'#3369FF',
|
|
45
|
+
'#36D2B8',
|
|
46
|
+
'#DB8D76',
|
|
47
|
+
'#47B359',
|
|
48
|
+
'#8545E6',
|
|
49
|
+
'#E0B18B',
|
|
50
|
+
'#7258F3',
|
|
51
|
+
'#0095FF',
|
|
52
|
+
'#52CC8F',
|
|
53
|
+
'#6675FF',
|
|
54
|
+
'#CC516E',
|
|
55
|
+
'#5CA9E6',
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
export const PARSE_ERROR_TIP = '智能助理不太懂您说什么呐,回去一定补充知识';
|
|
59
|
+
|
|
60
|
+
export const SEARCH_EXCEPTION_TIP =
|
|
61
|
+
'查询出错啦,数据库可能出现异常或者负载繁忙,请联系管理员或者稍后重试';
|
|
62
|
+
|
|
63
|
+
export const MSG_VALID_TIP = {
|
|
64
|
+
[MsgValidTypeEnum.SEARCH_EXCEPTION]: '数据查询异常',
|
|
65
|
+
[MsgValidTypeEnum.INVALID]: '智能助理不太懂您说什么呐,回去一定补充知识',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const PREFIX_CLS = 'ss-chat';
|
|
69
|
+
|
|
70
|
+
export const AGG_TYPE_MAP = {
|
|
71
|
+
SUM: '总计',
|
|
72
|
+
AVG: '平均值',
|
|
73
|
+
MAX: '最大值',
|
|
74
|
+
MIN: '最小值',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export enum MsgContentTypeEnum {
|
|
78
|
+
TEXT = 'TEXT',
|
|
79
|
+
METRIC_CARD = 'METRIC_CARD',
|
|
80
|
+
TABLE = 'TABLE',
|
|
81
|
+
METRIC_TREND = 'METRIC_TREND',
|
|
82
|
+
METRIC_BAR = 'METRIC_BAR',
|
|
83
|
+
MARKDOWN = 'MARKDOWN',
|
|
84
|
+
METRIC_PIE = 'METRIC_PIE',
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export enum ChatContextTypeQueryTypeEnum {
|
|
88
|
+
AGGREGATE = 'AGGREGATE',
|
|
89
|
+
METRIC_TAG = 'METRIC_TAG',
|
|
90
|
+
ID = 'ID',
|
|
91
|
+
DETAIL = 'DETAIL',
|
|
92
|
+
OTHER = 'OTHER',
|
|
93
|
+
}
|