From 71cb20eb4fb6ed8b8435b581aebdc62f90eb1d48 Mon Sep 17 00:00:00 2001 From: williamhliu <137068196+williamhliu@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:05:12 +0800 Subject: [PATCH] Integrate Chat and Copilot into chat-sdk, and add SQL parse display (#166) --- webapp/packages/chat-sdk/package.json | 8 +- webapp/packages/chat-sdk/public/index.html | 2 +- webapp/packages/chat-sdk/public/logo192.png | Bin 5347 -> 0 bytes webapp/packages/chat-sdk/public/logo512.png | Bin 9664 -> 0 bytes webapp/packages/chat-sdk/public/manifest.json | 12 +- .../chat-sdk/rollup/rollup.config.mjs | 8 +- .../chat-sdk/rollup/rollup.esm.config.mjs | 2 + .../src}/Chat/AgentList/index.tsx | 4 +- .../src/Chat/AgentList/style.module.less} | 0 .../src}/Chat/ChatFooter/index.tsx | 101 +++--- .../src/Chat/ChatFooter/style.module.less} | 4 +- .../src}/Chat/Conversation/index.tsx | 122 +++----- .../src/Chat/Conversation/style.module.less} | 7 +- .../src}/Chat/MessageContainer/index.tsx | 40 +-- .../Chat/MessageContainer/style.module.less} | 0 .../src}/Chat/MobileAgents/index.tsx | 4 +- .../src/Chat/MobileAgents/style.module.less} | 0 .../src}/Chat/components/AgentTip/index.tsx | 6 +- .../components/AgentTip/style.module.less} | 0 .../components/ConversationModal/index.tsx | 2 +- .../Chat/components/CopilotAvatar/index.tsx | 4 +- .../CopilotAvatar/style.module.less} | 0 .../src}/Chat/components/Message.tsx | 6 +- .../components/RecommendQuestions/index.tsx | 9 +- .../RecommendQuestions/style.module.less} | 14 +- .../src}/Chat/components/Text.tsx | 6 +- .../src/Chat/components/style.module.less} | 0 .../pages => chat-sdk/src}/Chat/constants.ts | 10 +- .../src/pages => chat-sdk/src}/Chat/index.tsx | 294 +++++++++--------- webapp/packages/chat-sdk/src/Chat/service.ts | 51 +++ .../src/Chat/style.module.less} | 4 +- .../src/pages => chat-sdk/src}/Chat/type.ts | 18 +- .../src}/Copilot/constants.ts | 0 .../packages/chat-sdk/src/Copilot/index.tsx | 148 +++++++++ .../src/Copilot/style.module.less} | 20 +- webapp/packages/chat-sdk/src/common/type.ts | 29 +- .../src/components/ChatItem/ExecuteItem.tsx | 9 +- .../src/components/ChatItem/FilterItem.tsx | 8 +- .../src/components/ChatItem/ParseTip.tsx | 155 +++++---- .../ChatItem/SimilarQuestionItem.tsx | 60 ++++ .../src/components/ChatItem/SqlItem.tsx | 116 +++++++ .../src/components/ChatItem/index.tsx | 101 ++++-- .../src/components/ChatItem/style.less | 102 +++++- .../src/components/ChatMsg/Message/index.tsx | 2 +- .../src/components/ChatMsg/Text/index.tsx | 28 +- .../src/components/ChatMsg/WebPage/index.tsx | 9 +- .../chat-sdk/src/components/ChatMsg/index.tsx | 15 +- .../components/DrillDownDimensions/index.tsx | 2 +- .../src/components/IconFont/index.tsx | 2 +- .../src/components/RecommendOptions/index.tsx | 2 +- .../packages/chat-sdk/src/demo/ChatDemo.tsx | 14 + .../chat-sdk/src/demo/CopilotDemo.tsx | 50 +++ .../chat-sdk/src/demo/style.module.less | 6 +- webapp/packages/chat-sdk/src/index.tsx | 14 +- .../chat-sdk/src/service/axiosInstance.ts | 10 +- webapp/packages/chat-sdk/src/service/index.ts | 30 +- webapp/packages/chat-sdk/src/typings.d.ts | 19 +- webapp/packages/chat-sdk/src/utils/utils.ts | 71 ++++- webapp/packages/chat-sdk/tsconfig.build.json | 2 +- .../supersonic-fe/config/envConfig.ts | 2 +- .../packages/supersonic-fe/config/routes.ts | 4 +- webapp/packages/supersonic-fe/src/app.tsx | 38 +-- .../src/pages/Chat/components/Typing.tsx | 19 -- .../supersonic-fe/src/pages/Chat/service.ts | 78 ----- .../src/pages/ChatPage/index.tsx | 14 + .../supersonic-fe/src/pages/Copilot/index.tsx | 119 ------- .../supersonic-fe/src/services/login.ts | 8 - webapp/pnpm-lock.yaml | 191 +++++++++--- 68 files changed, 1353 insertions(+), 882 deletions(-) delete mode 100644 webapp/packages/chat-sdk/public/logo192.png delete mode 100644 webapp/packages/chat-sdk/public/logo512.png rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/AgentList/index.tsx (94%) rename webapp/packages/{supersonic-fe/src/pages/Chat/AgentList/style.less => chat-sdk/src/Chat/AgentList/style.module.less} (100%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/ChatFooter/index.tsx (82%) rename webapp/packages/{supersonic-fe/src/pages/Chat/ChatFooter/style.less => chat-sdk/src/Chat/ChatFooter/style.module.less} (98%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/Conversation/index.tsx (72%) rename webapp/packages/{supersonic-fe/src/pages/Chat/Conversation/style.less => chat-sdk/src/Chat/Conversation/style.module.less} (98%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/MessageContainer/index.tsx (85%) rename webapp/packages/{supersonic-fe/src/pages/Chat/MessageContainer/style.less => chat-sdk/src/Chat/MessageContainer/style.module.less} (100%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/MobileAgents/index.tsx (94%) rename webapp/packages/{supersonic-fe/src/pages/Chat/MobileAgents/style.less => chat-sdk/src/Chat/MobileAgents/style.module.less} (100%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/components/AgentTip/index.tsx (89%) rename webapp/packages/{supersonic-fe/src/pages/Chat/components/AgentTip/style.less => chat-sdk/src/Chat/components/AgentTip/style.module.less} (100%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/components/ConversationModal/index.tsx (98%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/components/CopilotAvatar/index.tsx (60%) rename webapp/packages/{supersonic-fe/src/pages/Chat/components/CopilotAvatar/style.less => chat-sdk/src/Chat/components/CopilotAvatar/style.module.less} (100%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/components/Message.tsx (87%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/components/RecommendQuestions/index.tsx (92%) rename webapp/packages/{supersonic-fe/src/pages/Chat/components/RecommendQuestions/style.less => chat-sdk/src/Chat/components/RecommendQuestions/style.module.less} (95%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/components/Text.tsx (79%) rename webapp/packages/{supersonic-fe/src/pages/Chat/components/style.less => chat-sdk/src/Chat/components/style.module.less} (100%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/constants.ts (77%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/index.tsx (62%) create mode 100644 webapp/packages/chat-sdk/src/Chat/service.ts rename webapp/packages/{supersonic-fe/src/pages/Chat/style.less => chat-sdk/src/Chat/style.module.less} (96%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Chat/type.ts (84%) rename webapp/packages/{supersonic-fe/src/pages => chat-sdk/src}/Copilot/constants.ts (100%) create mode 100644 webapp/packages/chat-sdk/src/Copilot/index.tsx rename webapp/packages/{supersonic-fe/src/pages/Copilot/style.less => chat-sdk/src/Copilot/style.module.less} (98%) create mode 100644 webapp/packages/chat-sdk/src/components/ChatItem/SimilarQuestionItem.tsx create mode 100644 webapp/packages/chat-sdk/src/components/ChatItem/SqlItem.tsx create mode 100644 webapp/packages/chat-sdk/src/demo/ChatDemo.tsx create mode 100644 webapp/packages/chat-sdk/src/demo/CopilotDemo.tsx delete mode 100644 webapp/packages/supersonic-fe/src/pages/Chat/components/Typing.tsx delete mode 100644 webapp/packages/supersonic-fe/src/pages/Chat/service.ts create mode 100644 webapp/packages/supersonic-fe/src/pages/ChatPage/index.tsx delete mode 100644 webapp/packages/supersonic-fe/src/pages/Copilot/index.tsx diff --git a/webapp/packages/chat-sdk/package.json b/webapp/packages/chat-sdk/package.json index 1504b02d2..e1bd15bff 100644 --- a/webapp/packages/chat-sdk/package.json +++ b/webapp/packages/chat-sdk/package.json @@ -8,13 +8,17 @@ "dependencies": { "@ant-design/icons": "^4.7.0", "@uiw/react-watermark": "^0.0.5", + "ahooks": "^3.7.8", "antd": "^5.5.2", - "axios": "^1.4.0", + "axios": "^0.21.1", "classnames": "^2.3.2", "echarts": "^5.4.2", "lodash": "^4.17.11", "moment": "^2.29.4", + "react-copy-to-clipboard": "^5.1.0", "react-spinners": "^0.13.8", + "react-syntax-highlighter": "^15.5.0", + "sql-formatter": "^2.3.3", "tslib": "^2.5.2" }, "peerDependencies": { @@ -72,6 +76,7 @@ "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.5.2", + "@types/lodash": "^4.14.198", "@types/node": "^16.18.31", "@types/react": "^18.2.6", "@types/react-dom": "^18.2.4", @@ -122,6 +127,7 @@ "rollup-plugin-exclude-dependencies-from-bundle": "^1.1.23", "rollup-plugin-less": "^1.1.3", "rollup-plugin-postcss": "^4.0.2", + "rollup-plugin-styles": "^4.0.0", "rollup-plugin-typescript2": "^0.34.1", "sass-loader": "^12.3.0", "semver": "^7.3.5", diff --git a/webapp/packages/chat-sdk/public/index.html b/webapp/packages/chat-sdk/public/index.html index c582212e6..5c07d0e4b 100644 --- a/webapp/packages/chat-sdk/public/index.html +++ b/webapp/packages/chat-sdk/public/index.html @@ -28,7 +28,7 @@
- +