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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type MutableRefObject, useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const isRefObject = <T>(value: any): value is MutableRefObject<T> => {
|
|
4
|
+
return value !== null && typeof value === 'object' && 'current' in value;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const useComposing = (element?: HTMLElement | null | MutableRefObject<HTMLElement>) => {
|
|
8
|
+
const [isComposing, setIsComposing] = useState(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const handleCompositionStart = (): void => {
|
|
12
|
+
setIsComposing(true);
|
|
13
|
+
};
|
|
14
|
+
const handleCompositionEnd = (): void => {
|
|
15
|
+
setIsComposing(false);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const dom = isRefObject(element) ? element.current : element;
|
|
19
|
+
const target = dom || window;
|
|
20
|
+
|
|
21
|
+
target.addEventListener('compositionstart', handleCompositionStart);
|
|
22
|
+
target.addEventListener('compositionend', handleCompositionEnd);
|
|
23
|
+
|
|
24
|
+
return () => {
|
|
25
|
+
target.removeEventListener('compositionstart', handleCompositionStart);
|
|
26
|
+
target.removeEventListener('compositionend', handleCompositionEnd);
|
|
27
|
+
};
|
|
28
|
+
}, [element]);
|
|
29
|
+
|
|
30
|
+
return { isComposing, setIsComposing };
|
|
31
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { message } from 'antd';
|
|
2
|
+
import { ECharts } from 'echarts';
|
|
3
|
+
|
|
4
|
+
export interface ExportByEchartsProps {
|
|
5
|
+
instanceRef: React.MutableRefObject<ECharts | undefined>;
|
|
6
|
+
question: string;
|
|
7
|
+
options?: Parameters<ECharts['getConnectedDataURL']>[0];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useExportByEcharts = ({ instanceRef, question, options }: ExportByEchartsProps) => {
|
|
11
|
+
const handleSaveAsImage = () => {
|
|
12
|
+
if (instanceRef.current) {
|
|
13
|
+
return instanceRef.current.getConnectedDataURL({
|
|
14
|
+
type: 'png',
|
|
15
|
+
pixelRatio: 2,
|
|
16
|
+
backgroundColor: '#fff',
|
|
17
|
+
excludeComponents: ['toolbox'],
|
|
18
|
+
...options,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const downloadImage = (url: string) => {
|
|
24
|
+
const a = document.createElement('a');
|
|
25
|
+
a.href = url;
|
|
26
|
+
a.download = `${question}.png`;
|
|
27
|
+
a.click();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const downloadChartAsImage = () => {
|
|
31
|
+
const url = handleSaveAsImage();
|
|
32
|
+
if (url) {
|
|
33
|
+
downloadImage(url);
|
|
34
|
+
message.success('导出图片成功');
|
|
35
|
+
} else {
|
|
36
|
+
message.error('该条消息暂不支持导出图片');
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return { downloadChartAsImage };
|
|
41
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useMethodRegister = (fallback?: (...args: any[]) => any) => {
|
|
4
|
+
const methodStore = useRef<Map<string, (...args: any[]) => any>>(new Map());
|
|
5
|
+
|
|
6
|
+
const register = useCallback<(key: string, method: (...args: any[]) => any) => any>(
|
|
7
|
+
(key, method) => {
|
|
8
|
+
methodStore.current.set(key, method);
|
|
9
|
+
},
|
|
10
|
+
[methodStore]
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const call = useCallback<(key: string, ...args: any[]) => any>(
|
|
14
|
+
(key, ...args) => {
|
|
15
|
+
const method = methodStore.current.get(key);
|
|
16
|
+
if (method) {
|
|
17
|
+
return method(...args);
|
|
18
|
+
}
|
|
19
|
+
return fallback?.(...args);
|
|
20
|
+
},
|
|
21
|
+
[methodStore]
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return { register, call };
|
|
25
|
+
};
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import './styles/index.less';
|
|
2
|
+
|
|
3
|
+
// import ReactDOM from 'react-dom/client';
|
|
4
|
+
// import Chat from './demo/Chat';
|
|
5
|
+
// import ChatDemo from './demo/ChatDemo';
|
|
6
|
+
// import CopilotDemo from './demo/CopilotDemo';
|
|
7
|
+
// const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
8
|
+
// root.render(<ChatDemo />);
|
|
9
|
+
|
|
10
|
+
export { default as Chat } from './Chat';
|
|
11
|
+
|
|
12
|
+
export { default as Copilot } from './Copilot';
|
|
13
|
+
|
|
14
|
+
export { default as ChatMsg } from './components/ChatMsg';
|
|
15
|
+
|
|
16
|
+
export { default as ChatItem } from './components/ChatItem';
|
|
17
|
+
|
|
18
|
+
export { default as ShowCase } from './ShowCase';
|
|
19
|
+
|
|
20
|
+
export type {
|
|
21
|
+
SearchRecommendItem,
|
|
22
|
+
FieldType,
|
|
23
|
+
ModelInfoType,
|
|
24
|
+
EntityInfoType,
|
|
25
|
+
DateInfoType,
|
|
26
|
+
ChatContextType,
|
|
27
|
+
MsgValidTypeEnum,
|
|
28
|
+
MsgDataType,
|
|
29
|
+
PluginResonseType,
|
|
30
|
+
ColumnType,
|
|
31
|
+
SuggestionItemType,
|
|
32
|
+
SuggestionType,
|
|
33
|
+
SuggestionDataType,
|
|
34
|
+
FilterItemType,
|
|
35
|
+
HistoryType,
|
|
36
|
+
HistoryMsgItemType,
|
|
37
|
+
SendMsgParamsType,
|
|
38
|
+
} from './common/type';
|
|
39
|
+
|
|
40
|
+
export { searchRecommend } from './service';
|
|
41
|
+
|
|
42
|
+
export { saveConversation, getAllConversations } from './Chat/service';
|
|
43
|
+
|
|
44
|
+
export { setToken } from './utils/utils';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// 引入axios库
|
|
2
|
+
import axios, { AxiosInstance } from 'axios';
|
|
3
|
+
import { getToken } from '../utils/utils';
|
|
4
|
+
|
|
5
|
+
// 创建axios实例
|
|
6
|
+
const axiosInstance: AxiosInstance = axios.create({
|
|
7
|
+
// 设置基本URL,所有请求都会使用这个URL作为前缀
|
|
8
|
+
baseURL: 'http://192.168.50.202:9082',
|
|
9
|
+
// 设置请求超时时间(毫秒)
|
|
10
|
+
timeout: 120000,
|
|
11
|
+
// 设置请求头
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// 请求拦截器
|
|
18
|
+
axiosInstance.interceptors.request.use(
|
|
19
|
+
(config: any) => {
|
|
20
|
+
const token = getToken();
|
|
21
|
+
if (token && config?.headers) {
|
|
22
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
23
|
+
}
|
|
24
|
+
return config;
|
|
25
|
+
},
|
|
26
|
+
(error) => {
|
|
27
|
+
// 请求错误时的处理
|
|
28
|
+
return Promise.reject(error);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// 响应拦截器
|
|
33
|
+
axiosInstance.interceptors.response.use(
|
|
34
|
+
(response: any) => {
|
|
35
|
+
const redirect = response.headers['redirect'];
|
|
36
|
+
if (redirect === 'REDIRECT') {
|
|
37
|
+
let win: any = window;
|
|
38
|
+
while (win !== win.top) {
|
|
39
|
+
win = win.top;
|
|
40
|
+
}
|
|
41
|
+
const contextpath = response.headers['contextpath'];
|
|
42
|
+
win.location.href =
|
|
43
|
+
contextpath?.substring(0, contextpath?.indexOf('&')) +
|
|
44
|
+
`&redirect_uri=${encodeURIComponent(`http://${win.location.host}`)}`;
|
|
45
|
+
}
|
|
46
|
+
return response.data;
|
|
47
|
+
},
|
|
48
|
+
(error) => {
|
|
49
|
+
// 对响应错误进行处理
|
|
50
|
+
if (error.response && error.response.status === 401) {
|
|
51
|
+
// 如果响应状态码为401,表示未授权,可以在这里处理重新登录等操作
|
|
52
|
+
console.log('Unauthorized, please log in again.');
|
|
53
|
+
}
|
|
54
|
+
return Promise.reject(error);
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
export default axiosInstance;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import axios from './axiosInstance';
|
|
2
|
+
import {
|
|
3
|
+
ChatContextType,
|
|
4
|
+
HistoryMsgItemType,
|
|
5
|
+
HistoryType,
|
|
6
|
+
MsgDataType,
|
|
7
|
+
ParseDataType,
|
|
8
|
+
SearchRecommendItem,
|
|
9
|
+
} from '../common/type';
|
|
10
|
+
import { isMobile, getToken } from '../utils/utils';
|
|
11
|
+
|
|
12
|
+
const DEFAULT_CHAT_ID = 0;
|
|
13
|
+
|
|
14
|
+
const prefix = isMobile ? '/openapi' : '/api';
|
|
15
|
+
|
|
16
|
+
export function searchRecommend(
|
|
17
|
+
queryText: string,
|
|
18
|
+
chatId?: number,
|
|
19
|
+
modelId?: number,
|
|
20
|
+
agentId?: number
|
|
21
|
+
) {
|
|
22
|
+
return axios.post<SearchRecommendItem[]>(`${prefix}/chat/query/search`, {
|
|
23
|
+
queryText,
|
|
24
|
+
chatId: chatId || DEFAULT_CHAT_ID,
|
|
25
|
+
modelId,
|
|
26
|
+
agentId,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function chatQuery(queryText: string, chatId?: number, modelId?: number, filters?: any[]) {
|
|
31
|
+
return axios.post<MsgDataType>(`${prefix}/chat/query/query`, {
|
|
32
|
+
queryText,
|
|
33
|
+
chatId: chatId || DEFAULT_CHAT_ID,
|
|
34
|
+
modelId,
|
|
35
|
+
queryFilters: filters
|
|
36
|
+
? {
|
|
37
|
+
filters,
|
|
38
|
+
}
|
|
39
|
+
: undefined,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function chatParse({
|
|
44
|
+
queryText,
|
|
45
|
+
chatId,
|
|
46
|
+
modelId,
|
|
47
|
+
agentId,
|
|
48
|
+
parseId,
|
|
49
|
+
queryId,
|
|
50
|
+
filters,
|
|
51
|
+
parseInfo,
|
|
52
|
+
dataSetIds,
|
|
53
|
+
}: {
|
|
54
|
+
queryText: string;
|
|
55
|
+
chatId?: number;
|
|
56
|
+
modelId?: number;
|
|
57
|
+
agentId?: number;
|
|
58
|
+
queryId?: number;
|
|
59
|
+
parseId?: number;
|
|
60
|
+
filters?: any[];
|
|
61
|
+
parseInfo?: ChatContextType;
|
|
62
|
+
dataSetIds?: number[];
|
|
63
|
+
}) {
|
|
64
|
+
return axios.post<ParseDataType>(`${prefix}/chat/query/parse`, {
|
|
65
|
+
queryText,
|
|
66
|
+
chatId: chatId || DEFAULT_CHAT_ID,
|
|
67
|
+
dataSetId: dataSetIds && dataSetIds.length > 0 ? dataSetIds[0] : modelId,
|
|
68
|
+
agentId,
|
|
69
|
+
parseId,
|
|
70
|
+
queryId,
|
|
71
|
+
selectedParse: parseInfo,
|
|
72
|
+
dataSetIds,
|
|
73
|
+
queryFilters: filters
|
|
74
|
+
? {
|
|
75
|
+
filters,
|
|
76
|
+
}
|
|
77
|
+
: undefined,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function chatExecute(
|
|
82
|
+
queryText: string,
|
|
83
|
+
chatId: number,
|
|
84
|
+
parseInfo: ChatContextType,
|
|
85
|
+
agentId?: number
|
|
86
|
+
) {
|
|
87
|
+
return axios.post<MsgDataType>(`${prefix}/chat/query/execute`, {
|
|
88
|
+
queryText,
|
|
89
|
+
agentId,
|
|
90
|
+
chatId: chatId || DEFAULT_CHAT_ID,
|
|
91
|
+
queryId: parseInfo.queryId,
|
|
92
|
+
parseId: parseInfo.id,
|
|
93
|
+
dataSetIds: parseInfo.dataSetIds,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 流式总结功能已移除
|
|
98
|
+
// export function streamSummary(queryId: number, parseId: number, agentId: number, dataSetIds?: number[]) {
|
|
99
|
+
// const token = getToken();
|
|
100
|
+
// const tokenParam = token ? `&token=${encodeURIComponent(token)}` : '';
|
|
101
|
+
// const dataSetIdsParam = dataSetIds && dataSetIds.length > 0 ? `&dataSetIds=${dataSetIds.join(',')}` : '';
|
|
102
|
+
// return new EventSource(
|
|
103
|
+
// `${prefix}/chat/query/stream/summarize?queryId=${queryId}&parseId=${parseId}&agentId=${agentId}${dataSetIdsParam}${tokenParam}`
|
|
104
|
+
// );
|
|
105
|
+
// }
|
|
106
|
+
|
|
107
|
+
export function switchEntity(entityId: string, modelId?: number, chatId?: number) {
|
|
108
|
+
return axios.post<any>(`${prefix}/chat/query/switchQuery`, {
|
|
109
|
+
queryText: entityId,
|
|
110
|
+
modelId,
|
|
111
|
+
chatId: chatId || DEFAULT_CHAT_ID,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function queryData(chatContext: Partial<ChatContextType>) {
|
|
116
|
+
return axios.post<MsgDataType>(`${prefix}/chat/query/queryData`, chatContext);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function getHistoryMsg(
|
|
120
|
+
current: number,
|
|
121
|
+
chatId: number = DEFAULT_CHAT_ID,
|
|
122
|
+
pageSize: number = 10
|
|
123
|
+
) {
|
|
124
|
+
return axios.post<HistoryType>(`${prefix}/chat/manage/pageQueryInfo?chatId=${chatId}`, {
|
|
125
|
+
current,
|
|
126
|
+
pageSize,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function querySimilarQuestions(queryId: number) {
|
|
131
|
+
return axios.get<HistoryMsgItemType>(`${prefix}/chat/manage/getChatQuery/${queryId}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function deleteQuery(queryId: number) {
|
|
135
|
+
return axios.delete<any>(`${prefix}/chat/manage/${queryId}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function queryEntities(entityId: string | number, modelId: number) {
|
|
139
|
+
return axios.post<any>(`${prefix}/chat/query/choice`, {
|
|
140
|
+
entityId,
|
|
141
|
+
modelId,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function updateQAFeedback(questionId: number, score: number) {
|
|
146
|
+
return axios.post<any>(
|
|
147
|
+
`${prefix}/chat/manage/updateQAFeedback?id=${questionId}&score=${score}&feedback=`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function queryDimensionValues(
|
|
152
|
+
modelId: number,
|
|
153
|
+
bizName: string,
|
|
154
|
+
agentId: number,
|
|
155
|
+
elementID: number,
|
|
156
|
+
value: string
|
|
157
|
+
) {
|
|
158
|
+
return axios.post<any>(`${prefix}/chat/query/queryDimensionValue`, {
|
|
159
|
+
modelId,
|
|
160
|
+
bizName,
|
|
161
|
+
agentId,
|
|
162
|
+
elementID,
|
|
163
|
+
value,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function getDataSetDetail(dataSetId: number) {
|
|
168
|
+
return axios.get<any>(`${prefix}/semantic/dataSet/${dataSetId}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function getDataSetList(domainId?: number) {
|
|
172
|
+
const params = domainId ? { domainId } : {};
|
|
173
|
+
return axios.get<any>(`${prefix}/semantic/dataSet/getDataSetList`, { params });
|
|
174
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
2
|
+
|
|
3
|
+
module.exports = function (app) {
|
|
4
|
+
app.use(
|
|
5
|
+
'/api',
|
|
6
|
+
createProxyMiddleware({
|
|
7
|
+
target: 'http://localhost:9080',
|
|
8
|
+
changeOrigin: true,
|
|
9
|
+
})
|
|
10
|
+
);
|
|
11
|
+
app.use(
|
|
12
|
+
'/openapi',
|
|
13
|
+
createProxyMiddleware({
|
|
14
|
+
target: 'http://localhost:9080',
|
|
15
|
+
changeOrigin: true,
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @import '~antd/dist/antd.css';
|
|
2
|
+
|
|
3
|
+
@import './index.less';
|
|
4
|
+
|
|
5
|
+
@prefix-cls: ~'@{supersonic-chat-prefix}';
|
|
6
|
+
|
|
7
|
+
.@{prefix-cls} {
|
|
8
|
+
&-dimension,
|
|
9
|
+
&-metric {
|
|
10
|
+
position: relative;
|
|
11
|
+
|
|
12
|
+
&::after {
|
|
13
|
+
position: absolute;
|
|
14
|
+
right: 0.5px;
|
|
15
|
+
bottom: -2px;
|
|
16
|
+
left: 0.5px;
|
|
17
|
+
height: 2px;
|
|
18
|
+
margin: 0 1px;
|
|
19
|
+
content: '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-dimension {
|
|
24
|
+
&::after {
|
|
25
|
+
background: var(--chat-blue);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-metric {
|
|
30
|
+
&::after {
|
|
31
|
+
background: var(--primary-green);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&-table-row {
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&-even-row {
|
|
40
|
+
background-color: #fbfbfb;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-no-border-table {
|
|
44
|
+
.ant-table-cell {
|
|
45
|
+
border: none !important;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ant-table-tbody > tr.ant-table-row:hover > td {
|
|
49
|
+
background-color: #efefef !important;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import './reboot.less';
|
|
2
|
+
|
|
3
|
+
@import './variables.less';
|
|
4
|
+
|
|
5
|
+
@import './global.less';
|
|
6
|
+
|
|
7
|
+
@import '../components/ChatMsg/style.less';
|
|
8
|
+
|
|
9
|
+
@import '../components/ChatMsg/Bar/style.less';
|
|
10
|
+
|
|
11
|
+
@import '../components/ChatMsg/Table/style.less';
|
|
12
|
+
|
|
13
|
+
@import '../components/ChatMsg/Message/style.less';
|
|
14
|
+
|
|
15
|
+
@import '../components/ChatMsg/MetricCard/style.less';
|
|
16
|
+
|
|
17
|
+
@import "../components/ChatMsg/MetricTrend/style.less";
|
|
18
|
+
|
|
19
|
+
@import "../components/ChatMsg/Pie/style.less";
|
|
20
|
+
|
|
21
|
+
@import "../components/ChatMsg/ApplyAuth/style.less";
|
|
22
|
+
|
|
23
|
+
@import "../components/ChatMsg/NoPermissionChart/style.less";
|
|
24
|
+
|
|
25
|
+
@import "../components/ChatMsg/FilterSection/style.less";
|
|
26
|
+
|
|
27
|
+
@import "../components/ChatMsg/DateOptions/style.less";
|
|
28
|
+
|
|
29
|
+
@import "../components/ChatMsg/Text/style.less";
|
|
30
|
+
|
|
31
|
+
@import '../components/ChatItem/style.less';
|
|
32
|
+
|
|
33
|
+
@import "../components/Tools/style.less";
|
|
34
|
+
|
|
35
|
+
@import "../components/RecommendOptions/style.less";
|
|
36
|
+
|
|
37
|
+
@import "../components/DrillDownDimensions/style.less";
|
|
38
|
+
|
|
39
|
+
@import "../components/MetricOptions/style.less";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
+
sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
-moz-osx-font-smoothing: grayscale;
|
|
8
|
+
font-size: 14px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
code {
|
|
12
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
13
|
+
monospace;
|
|
14
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
@supersonic-chat-prefix: ~'ss-chat';
|
|
2
|
+
|
|
3
|
+
:root:root {
|
|
4
|
+
--primary: 180deg 4%;
|
|
5
|
+
--primary-color: #f87653;
|
|
6
|
+
--blue: #296df3;
|
|
7
|
+
--green: #00d59c;
|
|
8
|
+
--deep-blue: #446dff;
|
|
9
|
+
--chat-blue: #1b4aef;
|
|
10
|
+
--wy-color: #c20c0c;
|
|
11
|
+
--detail-width: 1300px;
|
|
12
|
+
--primary-1: #fff0f0;
|
|
13
|
+
--primary-2: #ffc7c7;
|
|
14
|
+
--primary-3: #ff9ea1;
|
|
15
|
+
--primary-4: #ff757e;
|
|
16
|
+
--primary-5: #ff4d5e;
|
|
17
|
+
--primary-6: #ff2441;
|
|
18
|
+
--primary-7: #d91434;
|
|
19
|
+
--primary-8: rgba(255, 36, 66, 0.1);
|
|
20
|
+
--body-background: #f7fafa;
|
|
21
|
+
--deep-background: #f0f0f0;
|
|
22
|
+
--light-background: #f5f5f5;
|
|
23
|
+
--component-background: #fff;
|
|
24
|
+
--header-color: #edf2f2;
|
|
25
|
+
--text-color: #181a1a;
|
|
26
|
+
--text-color-secondary: #3d4242;
|
|
27
|
+
--text-color-third: #626a6a;
|
|
28
|
+
--text-color-fourth: #889191;
|
|
29
|
+
--text-color-fifth: #afb6b6;
|
|
30
|
+
--text-color-six: #a3a4a6;
|
|
31
|
+
--text-color-fifth-4: hsla(180, 5%, 70%, 0.4);
|
|
32
|
+
--tooltip-max-width: 350px;
|
|
33
|
+
--info-color: #ff2442;
|
|
34
|
+
--success-color: #52c41a;
|
|
35
|
+
--processing-color: #ff2442;
|
|
36
|
+
--error-color: #ff4d4f;
|
|
37
|
+
--highlight-color: #ff4d4f;
|
|
38
|
+
--newrank-color: #ff7800;
|
|
39
|
+
--warning-color: #faad14;
|
|
40
|
+
--normal-color: #d9d9d9;
|
|
41
|
+
--white: #fff;
|
|
42
|
+
--white-30: hsla(0, 0%, 100%, 0.3);
|
|
43
|
+
--black: #000;
|
|
44
|
+
--disabled-color: #afb6b6;
|
|
45
|
+
--disabled-bg: #eceeee;
|
|
46
|
+
--border-color-base: #e1e6e6;
|
|
47
|
+
--chat-border-color-base: #d5d7db;
|
|
48
|
+
--light-blue-background: rgba(58, 100, 255, 0.1);
|
|
49
|
+
--link-color: #3a64ff;
|
|
50
|
+
--link-hover-color: #638aff;
|
|
51
|
+
--link-active-color: #2748d9;
|
|
52
|
+
--link-bg-color: rgba(58, 100, 255, 0.1);
|
|
53
|
+
--text-accent-color: #3a64ff;
|
|
54
|
+
--primary-green: #31c462;
|
|
55
|
+
--link-hover-bg-color: rgba(58, 100, 255, 0.06);
|
|
56
|
+
--success-2: rgba(82, 196, 26, 0.2);
|
|
57
|
+
--success-pink: #ff8193;
|
|
58
|
+
--disabled-bg-3: hsla(180, 6%, 93%, 0.3);
|
|
59
|
+
--tooltip-bg: #fff;
|
|
60
|
+
--record-btn: #00b354;
|
|
61
|
+
--record-btn-bg: rgba(0, 179, 84, 0.1);
|
|
62
|
+
--record-btn-bg-3: rgba(0, 179, 84, 0.3);
|
|
63
|
+
--border-color-base-bg-5: hsla(180, 9%, 89%, 0.5);
|
|
64
|
+
--user-gao-color: #fcad36;
|
|
65
|
+
--user-hao-color: #ec6f6f;
|
|
66
|
+
--user-all-color: #252526;
|
|
67
|
+
--nr-menu-highlight-color: #ff2442;
|
|
68
|
+
--nr-menu-icon-hover-color: #ff2442;
|
|
69
|
+
--nr-sider-background: #fff;
|
|
70
|
+
--nr-menu-bg: #fff;
|
|
71
|
+
--nr-sider-fixed-zindex: 12;
|
|
72
|
+
--nr-header-fixed-zindex: 11;
|
|
73
|
+
--newrank-color-bg: rgba(255, 120, 0, 0.1);
|
|
74
|
+
--newrank-color-bg-3: rgba(255, 120, 0, 0.3);
|
|
75
|
+
--warning-05: rgba(250, 173, 20, 0.05);
|
|
76
|
+
--bridge-account-color: #ff2442;
|
|
77
|
+
--bridge-agency-color: #3a64ff;
|
|
78
|
+
--bridge-free-color: #ff7800;
|
|
79
|
+
--bridge-medium-color: #00b354;
|
|
80
|
+
}
|