From 77baf7e1fa4933da5aade75be8a1e21bd9ad4ab8 Mon Sep 17 00:00:00 2001 From: lhwan <1017484907@qq.com> Date: Wed, 21 Aug 2024 09:39:27 +0800 Subject: [PATCH] feat: Front-end engineering replacement --- web/.env.template | 1 - web/.prettierrc | 9 - web/README.md | 42 +- {web_new => web}/ant-components/README.md | 0 .../ant-components/app/AppCard.tsx | 0 .../ant-components/app/TabContent.tsx | 0 .../chat/ChatContentContainer.tsx | 0 .../chat/content/ChatCompletion.tsx | 0 .../chat/content/ChatContent.tsx | 0 .../chat/content/ChatDefault.tsx | 0 .../ant-components/chat/content/Feedback.tsx | 0 .../ant-components/chat/content/ModelIcon.tsx | 0 .../ant-components/chat/content/RobotIcon.tsx | 0 .../ant-components/chat/header/ChatHeader.tsx | 0 .../ant-components/chat/input/ChatInput.tsx | 0 .../chat/input/ChatInputPanel.tsx | 0 .../chat/input/ModelSwitcher.tsx | 0 .../ant-components/chat/input/Resource.tsx | 0 .../ant-components/chat/input/Temperature.tsx | 0 .../ant-components/chat/input/ToolsBar.tsx | 0 .../ant-components/chat/sider/ChatSider.tsx | 0 .../ant-components/common/AppDefaultIcon.tsx | 0 .../ant-components/common/Icon.tsx | 0 .../ant-components/common/MarkdownContext.tsx | 0 .../ant-components/common/MyEmpty.tsx | 0 .../common/blurredCard/index.tsx | 0 .../common/blurredCard/style.css | 0 .../common/modelSelector/index.tsx | 0 .../common/modelSelector/styles.module.css | 0 .../ant-components/layout/Construct.tsx | 0 .../ant-components/layout/FloatHelper.tsx | 0 .../ant-components/layout/Header.tsx | 0 .../ant-components/layout/Sider.tsx | 0 .../ant-components/layout/UserBar.tsx | 0 .../ant-components/layout/style.css | 0 web/app/chat-context.tsx | 101 +- web/app/i18n.ts | 457 +- {web_new => web}/client/api/app/index.ts | 0 {web_new => web}/client/api/chat/index.ts | 0 {web_new => web}/client/api/evaluate/index.ts | 0 {web_new => web}/client/api/flow/index.ts | 0 web/client/api/index.ts | 12 +- .../client/api/knowledge/index.ts | 0 {web_new => web}/client/api/prompt/index.ts | 0 web/client/api/request.ts | 143 +- {web_new => web}/client/api/user/index.ts | 0 .../components/MenuModal/index.tsx | 0 web/components/agent/market-plugins.tsx | 51 +- web/components/app/agent-panel.tsx | 2 +- web/components/app/app-card.tsx | 169 +- web/components/app/app-modal.tsx | 10 +- web/components/app/resource-card.tsx | 2 +- .../chart/autoChart/advisor/pipeline.ts | 16 +- .../autoChart/charts/multi-line-chart.ts | 2 +- .../charts/multi-measure-line-chart.ts | 2 +- web/components/chart/autoChart/charts/util.ts | 2 +- web/components/chart/autoChart/index.tsx | 13 +- web/components/chart/index.tsx | 3 +- web/components/chat/agent-content.tsx | 2 +- web/components/chat/chat-container.tsx | 10 +- .../chat/chat-content/ReferencesContent.tsx | 0 .../chat/chat-content/VisAppLink.tsx | 0 .../chat/chat-content/VisChatLink.tsx | 0 .../chat/chat-content/VisResponse.tsx | 0 .../chat/chat-content/agent-messages.tsx | 21 +- .../chat/chat-content/agent-plans.tsx | 11 +- .../chat/chat-content/chart-view.tsx | 3 +- .../chat/chat-content/code-preview.tsx | 2 +- web/components/chat/chat-content/config.tsx | 151 +- .../chat/chat-content/vis-chart.tsx | 5 +- .../chat/chat-content/vis-plugin.tsx | 9 +- .../components/chat/chat-default/index.tsx | 0 web/components/chat/completion.tsx | 44 +- web/components/chat/db-editor.tsx | 24 +- web/components/chat/header/excel-upload.tsx | 2 +- web/components/chat/header/model-selector.tsx | 3 +- web/components/chat/monaco-editor.tsx | 5 +- web/components/chat/ob-editor/theme.ts | 1389 ++-- web/components/common/chat-dialog.tsx | 2 +- web/components/common/completion-input.tsx | 16 +- web/components/common/gpt-card.tsx | 12 +- web/components/database/form-dialog.tsx | 113 +- web/components/flow/flow-card.tsx | 8 +- web/components/icons/split-screen-height.tsx | 17 +- web/components/icons/split-screen-width.tsx | 1 + .../components/knowledge/RecallTestModal.tsx | 0 web/components/knowledge/arguments-modal.tsx | 2 +- web/components/knowledge/doc-icon.tsx | 4 +- web/components/knowledge/doc-panel.tsx | 517 +- web/components/knowledge/doc-type-form.tsx | 6 + web/components/knowledge/doc-upload-form.tsx | 254 +- web/components/knowledge/segmentation.tsx | 17 +- web/components/knowledge/space-card.tsx | 1 + web/components/knowledge/space-form.tsx | 18 +- web/components/knowledge/strategy-form.tsx | 4 +- web/components/layout/side-bar.tsx | 423 +- web/components/layout/top-progress-bar.tsx | 4 +- web/components/model/model-card.tsx | 26 +- web/defaultTheme.ts | 68 - web/global.d.ts | 2 +- web/hooks/use-chat.ts | 50 +- web/hooks/use-summary.ts | 2 +- {web_new => web}/hooks/use-user.ts | 0 {web_new => web}/lib/api/get-userinfo.ts | 0 {web_new => web}/lib/api/save-feedback.ts | 0 {web_new => web}/lib/dto/connect.ts | 0 .../lib/dto/models/feedback.dto.ts | 0 {web_new => web}/lib/dto/models/user.dto.ts | 0 {web_new => web}/lib/google-one-tap.ts | 0 {web_new => web}/lib/response.ts | 0 {web_new => web}/lib/session.ts | 0 {web_new => web}/locales/en/chat.ts | 0 {web_new => web}/locales/en/common.ts | 0 {web_new => web}/locales/en/index.ts | 0 {web_new => web}/locales/zh/chat.ts | 0 {web_new => web}/locales/zh/common.ts | 0 {web_new => web}/locales/zh/index.ts | 0 web/next.config.js | 13 +- {web_new => web}/package-lock.json | 0 web/package.json | 29 +- web/pages/_app.tsx | 116 +- web/pages/_document.tsx | 4 +- web/pages/chat/index.tsx | 316 +- .../pages/construct/agent/index.tsx | 0 .../app/components/create-app-modal/index.tsx | 0 .../create-app-modal/styles.module.css | 0 .../app/extra/components/AwelLayout.tsx | 0 .../app/extra/components/NativeApp.tsx | 0 .../extra/components/RecommendQuestions.tsx | 0 .../components/auto-plan/DetailsCard.tsx | 0 .../components/auto-plan/ResourceContent.tsx | 0 .../components/auto-plan/ResourcesCard.tsx | 0 .../app/extra/components/auto-plan/index.tsx | 0 .../pages/construct/app/extra/config.tsx | 0 .../pages/construct/app/extra/index.tsx | 0 .../construct/app/extra/styles.module.css | 0 .../pages/construct/app/index.tsx | 0 {web_new => web}/pages/construct/database.tsx | 0 .../pages/construct/flow/canvas/index.tsx | 0 .../pages/construct/flow/index.tsx | 0 {web_new => web}/pages/construct/index.tsx | 0 .../pages/construct/knowledge/chunk/index.tsx | 0 .../pages/construct/knowledge/index.tsx | 0 .../pages/construct/models/index.tsx | 0 .../pages/construct/prompt/[type]/index.tsx | 0 .../pages/construct/prompt/index.tsx | 0 .../pages/construct/prompt/styles.module.css | 0 web/pages/database/index.tsx | 3 +- {web_new => web}/pages/evaluation/index.tsx | 0 web/pages/flow/canvas/index.tsx | 1 - web/pages/flow/index.tsx | 4 +- web/pages/index.tsx | 460 +- web/pages/knowledge/index.tsx | 5 +- .../mobile/chat/components/ChatDialog.tsx | 0 .../pages/mobile/chat/components/Content.tsx | 0 .../mobile/chat/components/DislikeDrawer.tsx | 0 .../pages/mobile/chat/components/Feedback.tsx | 0 .../pages/mobile/chat/components/Header.tsx | 0 .../mobile/chat/components/InputContainer.tsx | 0 .../mobile/chat/components/ModelSelector.tsx | 0 .../mobile/chat/components/OptionIcon.tsx | 0 .../pages/mobile/chat/components/Resource.tsx | 0 .../mobile/chat/components/Thermometer.tsx | 0 {web_new => web}/pages/mobile/chat/index.tsx | 0 web/public/WHITE_LOGO.png | Bin 21248 -> 0 bytes web/public/empty.png | Bin 22909 -> 21789 bytes .../public/icons/app/auto_plan.png | Bin .../public/icons/app/awel_layout.png | Bin .../public/icons/app/native_app.png | Bin .../public/icons/app/single_agent.png | Bin {web_new => web}/public/icons/chat/excel.png | Bin {web_new => web}/public/icons/chat/other.png | Bin {web_new => web}/public/icons/chat/pdf.png | Bin {web_new => web}/public/icons/chat/word.png | Bin {web_new => web}/public/icons/english.png | Bin {web_new => web}/public/icons/odc.png | Bin {web_new => web}/public/icons/send.png | Bin {web_new => web}/public/icons/zh.png | Bin {web_new => web}/public/logo_s_latest.png | Bin {web_new => web}/public/logo_zh_latest.png | Bin {web_new => web}/public/models/bailing.svg | 0 {web_new => web}/public/models/tongyi.apng | Bin {web_new => web}/public/pictures/QR.png | Bin {web_new => web}/public/pictures/agent.png | Bin {web_new => web}/public/pictures/app.png | Bin .../public/pictures/app_active.png | Bin {web_new => web}/public/pictures/bg.png | Bin {web_new => web}/public/pictures/bg_dark.png | Bin .../public/pictures/card_chat.png | Bin {web_new => web}/public/pictures/chat.png | Bin .../public/pictures/chat_active.png | Bin {web_new => web}/public/pictures/database.png | Bin {web_new => web}/public/pictures/empty.png | Bin {web_new => web}/public/pictures/explore.png | Bin .../public/pictures/explore_active.png | Bin web/public/{images => pictures}/fallback.png | Bin {web_new => web}/public/pictures/flow.png | Bin .../public/pictures/knowledge.png | Bin {web_new => web}/public/pictures/model.png | Bin .../public/pictures/theme_dark.png | Bin .../public/pictures/theme_light.png | Bin web/styles/globals.css | 47 +- web/tailwind.config.js | 43 +- web/types/agent.ts | 2 +- web/types/app.ts | 73 +- web/types/chat.ts | 64 + {web_new => web}/types/evaluate.ts | 0 web/types/flow.ts | 16 +- web/types/knowledge.ts | 36 +- web/types/prompt.ts | 63 + {web_new => web}/types/userinfo.ts | 0 web/utils/constants.ts | 33 + {web_new => web}/utils/constants/cookie.ts | 0 .../utils/constants/error-code.ts | 0 {web_new => web}/utils/constants/header.ts | 0 {web_new => web}/utils/constants/index.ts | 0 {web_new => web}/utils/constants/storage.ts | 0 web/utils/request.ts | 2 + web/utils/storage.ts | 11 +- web/yarn.lock | 6722 ----------------- web_new/README.md | 133 - web_new/app/chat-context.tsx | 170 - web_new/app/i18n.ts | 32 - web_new/client/api/index.ts | 78 - web_new/client/api/request.ts | 354 - web_new/client/api/tools/index.ts | 1 - web_new/client/api/tools/interceptors.ts | 45 - web_new/components/agent/market-plugins.tsx | 197 - web_new/components/agent/my-plugins.tsx | 124 - web_new/components/app/agent-panel.tsx | 156 - web_new/components/app/app-card.tsx | 196 - web_new/components/app/app-modal.tsx | 367 - web_new/components/app/dag-layout.tsx | 58 - web_new/components/app/resource-card.tsx | 141 - .../chart/autoChart/advisor/pipeline.ts | 101 - .../chart/autoChart/advisor/rule.ts | 1 - .../chart/autoChart/advisor/utils.ts | 46 - .../chart/autoChart/charts/index.ts | 8 - .../autoChart/charts/multi-line-chart.ts | 77 - .../charts/multi-measure-column-chart.ts | 69 - .../charts/multi-measure-line-chart.ts | 73 - .../components/chart/autoChart/charts/util.ts | 82 - .../chart/autoChart/helpers/index.ts | 35 - web_new/components/chart/autoChart/index.tsx | 169 - web_new/components/chart/autoChart/types.ts | 46 - web_new/components/chart/bar-chart.tsx | 34 - .../chart/helpers/downloadChartImage.ts | 40 - web_new/components/chart/index.tsx | 81 - web_new/components/chart/line-chart.tsx | 57 - web_new/components/chart/table-chart.tsx | 36 - web_new/components/chat/agent-content.tsx | 40 - web_new/components/chat/chat-container.tsx | 139 - .../chat/chat-content/agent-messages.tsx | 46 - .../chat/chat-content/agent-plans.tsx | 53 - .../chat/chat-content/chart-view.tsx | 38 - .../chat/chat-content/code-preview.tsx | 36 - .../components/chat/chat-content/config.tsx | 331 - .../components/chat/chat-content/index.tsx | 181 - .../chat/chat-content/vis-chart.tsx | 22 - .../components/chat/chat-content/vis-code.tsx | 69 - .../chat/chat-content/vis-convert-error.tsx | 24 - .../chat/chat-content/vis-dashboard.tsx | 58 - .../chat/chat-content/vis-plugin.tsx | 67 - web_new/components/chat/chat-feedback.tsx | 236 - web_new/components/chat/completion.tsx | 241 - web_new/components/chat/db-editor.tsx | 662 -- web_new/components/chat/doc-list.tsx | 57 - web_new/components/chat/doc-upload.tsx | 53 - .../components/chat/header/agent-selector.tsx | 31 - web_new/components/chat/header/chat-excel.tsx | 33 - .../components/chat/header/db-selector.tsx | 54 - .../components/chat/header/excel-upload.tsx | 114 - web_new/components/chat/header/index.tsx | 42 - .../components/chat/header/model-selector.tsx | 62 - web_new/components/chat/mode-tab/index.css | 13 - web_new/components/chat/mode-tab/index.tsx | 35 - web_new/components/chat/monaco-editor.tsx | 77 - .../components/chat/ob-editor/ob-plugin.ts | 31 - web_new/components/chat/ob-editor/service.ts | 21 - web_new/components/chat/ob-editor/theme.ts | 697 -- web_new/components/common/FileStatusIcon.tsx | 21 - web_new/components/common/MyEmpty.tsx | 33 - web_new/components/common/chat-dialog.tsx | 112 - .../components/common/completion-input.tsx | 103 - web_new/components/common/db-icon.tsx | 23 - web_new/components/common/gpt-card.tsx | 141 - web_new/components/common/icon-wrapper.tsx | 23 - web_new/components/common/loading.tsx | 13 - web_new/components/common/prompt-bot.tsx | 128 - web_new/components/database/form-dialog.tsx | 215 - web_new/components/flow/add-nodes.tsx | 130 - web_new/components/flow/button-edge.tsx | 41 - web_new/components/flow/canvas-node.tsx | 152 - web_new/components/flow/flow-card.tsx | 133 - web_new/components/flow/node-handler.tsx | 147 - .../components/flow/node-param-handler.tsx | 102 - web_new/components/flow/preview-flow.tsx | 18 - web_new/components/flow/required-icon.tsx | 10 - web_new/components/flow/static-nodes.tsx | 41 - web_new/components/icons/add-icon.tsx | 13 - web_new/components/icons/collect.tsx | 13 - web_new/components/icons/collected.tsx | 7 - web_new/components/icons/colorful-chat.tsx | 33 - .../components/icons/colorful-dashboard.tsx | 28 - web_new/components/icons/colorful-data.tsx | 33 - web_new/components/icons/colorful-db.tsx | 67 - web_new/components/icons/colorful-doc.tsx | 18 - web_new/components/icons/colorful-excel.tsx | 28 - web_new/components/icons/colorful-plugin.tsx | 13 - web_new/components/icons/dark-svg.tsx | 12 - web_new/components/icons/database.tsx | 19 - web_new/components/icons/db-svg.tsx | 12 - web_new/components/icons/done-icon.tsx | 21 - web_new/components/icons/field.tsx | 21 - web_new/components/icons/file-done.tsx | 23 - web_new/components/icons/file-error.tsx | 13 - web_new/components/icons/file-sync.tsx | 23 - web_new/components/icons/index.tsx | 41 - web_new/components/icons/knowledge.tsx | 13 - web_new/components/icons/model-svg.tsx | 9 - web_new/components/icons/pending-icon.tsx | 13 - .../components/icons/split-screen-height.tsx | 13 - .../components/icons/split-screen-width.tsx | 13 - web_new/components/icons/stars-svg.tsx | 12 - web_new/components/icons/sunny-svg.tsx | 12 - web_new/components/icons/sync-icon.tsx | 11 - web_new/components/icons/table.tsx | 23 - .../components/knowledge/arguments-modal.tsx | 192 - web_new/components/knowledge/doc-icon.tsx | 13 - web_new/components/knowledge/doc-panel.tsx | 540 -- .../components/knowledge/doc-type-form.tsx | 59 - .../components/knowledge/doc-upload-form.tsx | 395 - web_new/components/knowledge/segmentation.tsx | 207 - web_new/components/knowledge/space-card.tsx | 123 - web_new/components/knowledge/space-form.tsx | 113 - .../components/knowledge/strategy-form.tsx | 92 - web_new/components/layout/side-bar.tsx | 524 -- .../components/layout/top-progress-bar.tsx | 61 - web_new/components/model/model-card.tsx | 85 - web_new/components/model/model-form.tsx | 100 - web_new/components/model/model-params.tsx | 54 - web_new/components/prompt/prompt-form.tsx | 57 - web_new/genAntdCss.ts | 36 - web_new/global.d.ts | 16 - web_new/hooks/use-chat.ts | 112 - web_new/hooks/use-summary.ts | 38 - web_new/next-env.d.ts | 6 - web_new/next.config.js | 53 - web_new/nprogress.css | 31 - web_new/package.json | 98 - web_new/pages/_app.tsx | 144 - web_new/pages/_document.tsx | 56 - web_new/pages/agent/index.tsx | 34 - web_new/pages/app/index.tsx | 114 - web_new/pages/chat/index.tsx | 321 - web_new/pages/database/index.tsx | 233 - web_new/pages/flow/canvas/index.tsx | 319 - web_new/pages/flow/index.tsx | 117 - web_new/pages/index.tsx | 384 - web_new/pages/knowledge/chunk/index.tsx | 106 - web_new/pages/knowledge/graph/index.tsx | 137 - web_new/pages/knowledge/index.tsx | 123 - web_new/pages/models/index.tsx | 62 - web_new/pages/prompt/index.tsx | 181 - web_new/postcss.config.js | 6 - web_new/public/LOGO.png | Bin 31388 -> 0 bytes web_new/public/LOGO_1.png | Bin 4904 -> 0 bytes web_new/public/LOGO_SMALL.png | Bin 13894 -> 0 bytes web_new/public/empty.png | Bin 21789 -> 0 bytes web_new/public/favicon.ico | Bin 4286 -> 0 bytes web_new/public/huggingface_logo.svg | 73 - web_new/public/icons/access.png | Bin 6982 -> 0 bytes web_new/public/icons/cassandra.png | Bin 4967 -> 0 bytes web_new/public/icons/clickhouse.png | Bin 1768 -> 0 bytes web_new/public/icons/couchbase.png | Bin 3921 -> 0 bytes web_new/public/icons/db.png | Bin 11127 -> 0 bytes web_new/public/icons/db2.png | Bin 768 -> 0 bytes web_new/public/icons/doris.png | Bin 18959 -> 0 bytes web_new/public/icons/duckdb.png | Bin 2768 -> 0 bytes web_new/public/icons/hbase.png | Bin 4396 -> 0 bytes web_new/public/icons/hive.png | Bin 6023 -> 0 bytes web_new/public/icons/knowledge.png | Bin 3636 -> 0 bytes web_new/public/icons/mongodb.png | Bin 1161 -> 0 bytes web_new/public/icons/mssql.png | Bin 3570 -> 0 bytes web_new/public/icons/mysql.png | Bin 5816 -> 0 bytes .../public/icons/node/default_node_icon.svg | 37 - web_new/public/icons/node/http_trigger.svg | 37 - web_new/public/icons/node/llm_operator.svg | 37 - .../public/icons/node/openai_llm_client.svg | 37 - web_new/public/icons/node/vis.png | Bin 172635 -> 0 bytes web_new/public/icons/oceanbase.png | Bin 4362 -> 0 bytes web_new/public/icons/oracle.png | Bin 3974 -> 0 bytes web_new/public/icons/postgresql.png | Bin 9667 -> 0 bytes web_new/public/icons/redis.png | Bin 5267 -> 0 bytes web_new/public/icons/spark.png | Bin 12249 -> 0 bytes web_new/public/icons/sqlite.png | Bin 4572 -> 0 bytes web_new/public/icons/starrocks.png | Bin 5846 -> 0 bytes web_new/public/icons/tugraph.png | Bin 252992 -> 0 bytes web_new/public/icons/vertica.png | Bin 7517 -> 0 bytes web_new/public/models/baichuan.png | Bin 324 -> 0 bytes web_new/public/models/bard.gif | Bin 277497 -> 0 bytes web_new/public/models/chatglm.png | Bin 110331 -> 0 bytes web_new/public/models/chatgpt.png | Bin 3127 -> 0 bytes web_new/public/models/chroma-logo.png | Bin 1635 -> 0 bytes web_new/public/models/claude.png | Bin 375 -> 0 bytes web_new/public/models/falcon.jpeg | Bin 1638 -> 0 bytes web_new/public/models/fin_report.jpg | Bin 15018 -> 0 bytes web_new/public/models/google.png | Bin 3092 -> 0 bytes web_new/public/models/gorilla.png | Bin 4806 -> 0 bytes web_new/public/models/huggingface.svg | 37 - web_new/public/models/internlm.png | Bin 1634 -> 0 bytes web_new/public/models/knowledge-default.jpg | Bin 108470 -> 0 bytes web_new/public/models/knowledge-full-text.jpg | Bin 65860 -> 0 bytes web_new/public/models/knowledge-graph.png | Bin 41168 -> 0 bytes web_new/public/models/llama-cpp.png | Bin 10872 -> 0 bytes web_new/public/models/llama.jpg | Bin 2102 -> 0 bytes web_new/public/models/qwen2.png | Bin 3617 -> 0 bytes web_new/public/models/salesforce.jpeg | Bin 2240 -> 0 bytes web_new/public/models/solar_logo.png | Bin 77090 -> 0 bytes web_new/public/models/vicuna.jpeg | Bin 1390 -> 0 bytes web_new/public/models/vllm.png | Bin 22117 -> 0 bytes web_new/public/models/wizardlm.png | Bin 9230 -> 0 bytes web_new/public/models/yi.svg | 7 - web_new/public/models/zhipu.png | Bin 341 -> 0 bytes web_new/public/pictures/fallback.png | Bin 2404 -> 0 bytes web_new/styles/globals.css | 125 - web_new/tailwind.config.js | 68 - web_new/tsconfig.json | 28 - web_new/types/agent.ts | 75 - web_new/types/app.ts | 152 - web_new/types/chat.ts | 180 - web_new/types/db.ts | 69 - web_new/types/editor.ts | 48 - web_new/types/flow.ts | 145 - web_new/types/knowledge.ts | 202 - web_new/types/model.ts | 67 - web_new/types/prompt.ts | 86 - web_new/utils/constants.ts | 110 - web_new/utils/ctx-axios.ts | 14 - web_new/utils/flow.ts | 100 - web_new/utils/index.ts | 22 - web_new/utils/request.ts | 101 - web_new/utils/storage.ts | 20 - 443 files changed, 3545 insertions(+), 24735 deletions(-) delete mode 100644 web/.env.template delete mode 100644 web/.prettierrc rename {web_new => web}/ant-components/README.md (100%) rename {web_new => web}/ant-components/app/AppCard.tsx (100%) rename {web_new => web}/ant-components/app/TabContent.tsx (100%) rename {web_new => web}/ant-components/chat/ChatContentContainer.tsx (100%) rename {web_new => web}/ant-components/chat/content/ChatCompletion.tsx (100%) rename {web_new => web}/ant-components/chat/content/ChatContent.tsx (100%) rename {web_new => web}/ant-components/chat/content/ChatDefault.tsx (100%) rename {web_new => web}/ant-components/chat/content/Feedback.tsx (100%) rename {web_new => web}/ant-components/chat/content/ModelIcon.tsx (100%) rename {web_new => web}/ant-components/chat/content/RobotIcon.tsx (100%) rename {web_new => web}/ant-components/chat/header/ChatHeader.tsx (100%) rename {web_new => web}/ant-components/chat/input/ChatInput.tsx (100%) rename {web_new => web}/ant-components/chat/input/ChatInputPanel.tsx (100%) rename {web_new => web}/ant-components/chat/input/ModelSwitcher.tsx (100%) rename {web_new => web}/ant-components/chat/input/Resource.tsx (100%) rename {web_new => web}/ant-components/chat/input/Temperature.tsx (100%) rename {web_new => web}/ant-components/chat/input/ToolsBar.tsx (100%) rename {web_new => web}/ant-components/chat/sider/ChatSider.tsx (100%) rename {web_new => web}/ant-components/common/AppDefaultIcon.tsx (100%) rename {web_new => web}/ant-components/common/Icon.tsx (100%) rename {web_new => web}/ant-components/common/MarkdownContext.tsx (100%) rename {web_new => web}/ant-components/common/MyEmpty.tsx (100%) rename {web_new => web}/ant-components/common/blurredCard/index.tsx (100%) rename {web_new => web}/ant-components/common/blurredCard/style.css (100%) rename {web_new => web}/ant-components/common/modelSelector/index.tsx (100%) rename {web_new => web}/ant-components/common/modelSelector/styles.module.css (100%) rename {web_new => web}/ant-components/layout/Construct.tsx (100%) rename {web_new => web}/ant-components/layout/FloatHelper.tsx (100%) rename {web_new => web}/ant-components/layout/Header.tsx (100%) rename {web_new => web}/ant-components/layout/Sider.tsx (100%) rename {web_new => web}/ant-components/layout/UserBar.tsx (100%) rename {web_new => web}/ant-components/layout/style.css (100%) rename {web_new => web}/client/api/app/index.ts (100%) rename {web_new => web}/client/api/chat/index.ts (100%) rename {web_new => web}/client/api/evaluate/index.ts (100%) rename {web_new => web}/client/api/flow/index.ts (100%) rename {web_new => web}/client/api/knowledge/index.ts (100%) rename {web_new => web}/client/api/prompt/index.ts (100%) rename {web_new => web}/client/api/user/index.ts (100%) rename {web_new => web}/components/MenuModal/index.tsx (100%) rename {web_new => web}/components/chat/chat-content/ReferencesContent.tsx (100%) rename {web_new => web}/components/chat/chat-content/VisAppLink.tsx (100%) rename {web_new => web}/components/chat/chat-content/VisChatLink.tsx (100%) rename {web_new => web}/components/chat/chat-content/VisResponse.tsx (100%) rename {web_new => web}/components/chat/chat-default/index.tsx (100%) rename {web_new => web}/components/knowledge/RecallTestModal.tsx (100%) delete mode 100644 web/defaultTheme.ts rename {web_new => web}/hooks/use-user.ts (100%) rename {web_new => web}/lib/api/get-userinfo.ts (100%) rename {web_new => web}/lib/api/save-feedback.ts (100%) rename {web_new => web}/lib/dto/connect.ts (100%) rename {web_new => web}/lib/dto/models/feedback.dto.ts (100%) rename {web_new => web}/lib/dto/models/user.dto.ts (100%) rename {web_new => web}/lib/google-one-tap.ts (100%) rename {web_new => web}/lib/response.ts (100%) rename {web_new => web}/lib/session.ts (100%) rename {web_new => web}/locales/en/chat.ts (100%) rename {web_new => web}/locales/en/common.ts (100%) rename {web_new => web}/locales/en/index.ts (100%) rename {web_new => web}/locales/zh/chat.ts (100%) rename {web_new => web}/locales/zh/common.ts (100%) rename {web_new => web}/locales/zh/index.ts (100%) rename {web_new => web}/package-lock.json (100%) rename {web_new => web}/pages/construct/agent/index.tsx (100%) rename {web_new => web}/pages/construct/app/components/create-app-modal/index.tsx (100%) rename {web_new => web}/pages/construct/app/components/create-app-modal/styles.module.css (100%) rename {web_new => web}/pages/construct/app/extra/components/AwelLayout.tsx (100%) rename {web_new => web}/pages/construct/app/extra/components/NativeApp.tsx (100%) rename {web_new => web}/pages/construct/app/extra/components/RecommendQuestions.tsx (100%) rename {web_new => web}/pages/construct/app/extra/components/auto-plan/DetailsCard.tsx (100%) rename {web_new => web}/pages/construct/app/extra/components/auto-plan/ResourceContent.tsx (100%) rename {web_new => web}/pages/construct/app/extra/components/auto-plan/ResourcesCard.tsx (100%) rename {web_new => web}/pages/construct/app/extra/components/auto-plan/index.tsx (100%) rename {web_new => web}/pages/construct/app/extra/config.tsx (100%) rename {web_new => web}/pages/construct/app/extra/index.tsx (100%) rename {web_new => web}/pages/construct/app/extra/styles.module.css (100%) rename {web_new => web}/pages/construct/app/index.tsx (100%) rename {web_new => web}/pages/construct/database.tsx (100%) rename {web_new => web}/pages/construct/flow/canvas/index.tsx (100%) rename {web_new => web}/pages/construct/flow/index.tsx (100%) rename {web_new => web}/pages/construct/index.tsx (100%) rename {web_new => web}/pages/construct/knowledge/chunk/index.tsx (100%) rename {web_new => web}/pages/construct/knowledge/index.tsx (100%) rename {web_new => web}/pages/construct/models/index.tsx (100%) rename {web_new => web}/pages/construct/prompt/[type]/index.tsx (100%) rename {web_new => web}/pages/construct/prompt/index.tsx (100%) rename {web_new => web}/pages/construct/prompt/styles.module.css (100%) rename {web_new => web}/pages/evaluation/index.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/ChatDialog.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/Content.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/DislikeDrawer.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/Feedback.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/Header.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/InputContainer.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/ModelSelector.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/OptionIcon.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/Resource.tsx (100%) rename {web_new => web}/pages/mobile/chat/components/Thermometer.tsx (100%) rename {web_new => web}/pages/mobile/chat/index.tsx (100%) delete mode 100644 web/public/WHITE_LOGO.png rename {web_new => web}/public/icons/app/auto_plan.png (100%) rename {web_new => web}/public/icons/app/awel_layout.png (100%) rename {web_new => web}/public/icons/app/native_app.png (100%) rename {web_new => web}/public/icons/app/single_agent.png (100%) rename {web_new => web}/public/icons/chat/excel.png (100%) rename {web_new => web}/public/icons/chat/other.png (100%) rename {web_new => web}/public/icons/chat/pdf.png (100%) rename {web_new => web}/public/icons/chat/word.png (100%) rename {web_new => web}/public/icons/english.png (100%) rename {web_new => web}/public/icons/odc.png (100%) rename {web_new => web}/public/icons/send.png (100%) rename {web_new => web}/public/icons/zh.png (100%) rename {web_new => web}/public/logo_s_latest.png (100%) rename {web_new => web}/public/logo_zh_latest.png (100%) rename {web_new => web}/public/models/bailing.svg (100%) rename {web_new => web}/public/models/tongyi.apng (100%) rename {web_new => web}/public/pictures/QR.png (100%) rename {web_new => web}/public/pictures/agent.png (100%) rename {web_new => web}/public/pictures/app.png (100%) rename {web_new => web}/public/pictures/app_active.png (100%) rename {web_new => web}/public/pictures/bg.png (100%) rename {web_new => web}/public/pictures/bg_dark.png (100%) rename {web_new => web}/public/pictures/card_chat.png (100%) rename {web_new => web}/public/pictures/chat.png (100%) rename {web_new => web}/public/pictures/chat_active.png (100%) rename {web_new => web}/public/pictures/database.png (100%) rename {web_new => web}/public/pictures/empty.png (100%) rename {web_new => web}/public/pictures/explore.png (100%) rename {web_new => web}/public/pictures/explore_active.png (100%) rename web/public/{images => pictures}/fallback.png (100%) rename {web_new => web}/public/pictures/flow.png (100%) rename {web_new => web}/public/pictures/knowledge.png (100%) rename {web_new => web}/public/pictures/model.png (100%) rename {web_new => web}/public/pictures/theme_dark.png (100%) rename {web_new => web}/public/pictures/theme_light.png (100%) rename {web_new => web}/types/evaluate.ts (100%) rename {web_new => web}/types/userinfo.ts (100%) rename {web_new => web}/utils/constants/cookie.ts (100%) rename {web_new => web}/utils/constants/error-code.ts (100%) rename {web_new => web}/utils/constants/header.ts (100%) rename {web_new => web}/utils/constants/index.ts (100%) rename {web_new => web}/utils/constants/storage.ts (100%) delete mode 100644 web/yarn.lock delete mode 100644 web_new/README.md delete mode 100644 web_new/app/chat-context.tsx delete mode 100644 web_new/app/i18n.ts delete mode 100644 web_new/client/api/index.ts delete mode 100644 web_new/client/api/request.ts delete mode 100644 web_new/client/api/tools/index.ts delete mode 100644 web_new/client/api/tools/interceptors.ts delete mode 100644 web_new/components/agent/market-plugins.tsx delete mode 100644 web_new/components/agent/my-plugins.tsx delete mode 100644 web_new/components/app/agent-panel.tsx delete mode 100644 web_new/components/app/app-card.tsx delete mode 100644 web_new/components/app/app-modal.tsx delete mode 100644 web_new/components/app/dag-layout.tsx delete mode 100644 web_new/components/app/resource-card.tsx delete mode 100644 web_new/components/chart/autoChart/advisor/pipeline.ts delete mode 100644 web_new/components/chart/autoChart/advisor/rule.ts delete mode 100644 web_new/components/chart/autoChart/advisor/utils.ts delete mode 100644 web_new/components/chart/autoChart/charts/index.ts delete mode 100644 web_new/components/chart/autoChart/charts/multi-line-chart.ts delete mode 100644 web_new/components/chart/autoChart/charts/multi-measure-column-chart.ts delete mode 100644 web_new/components/chart/autoChart/charts/multi-measure-line-chart.ts delete mode 100644 web_new/components/chart/autoChart/charts/util.ts delete mode 100644 web_new/components/chart/autoChart/helpers/index.ts delete mode 100644 web_new/components/chart/autoChart/index.tsx delete mode 100644 web_new/components/chart/autoChart/types.ts delete mode 100644 web_new/components/chart/bar-chart.tsx delete mode 100644 web_new/components/chart/helpers/downloadChartImage.ts delete mode 100644 web_new/components/chart/index.tsx delete mode 100644 web_new/components/chart/line-chart.tsx delete mode 100644 web_new/components/chart/table-chart.tsx delete mode 100644 web_new/components/chat/agent-content.tsx delete mode 100644 web_new/components/chat/chat-container.tsx delete mode 100644 web_new/components/chat/chat-content/agent-messages.tsx delete mode 100644 web_new/components/chat/chat-content/agent-plans.tsx delete mode 100644 web_new/components/chat/chat-content/chart-view.tsx delete mode 100644 web_new/components/chat/chat-content/code-preview.tsx delete mode 100644 web_new/components/chat/chat-content/config.tsx delete mode 100644 web_new/components/chat/chat-content/index.tsx delete mode 100644 web_new/components/chat/chat-content/vis-chart.tsx delete mode 100644 web_new/components/chat/chat-content/vis-code.tsx delete mode 100644 web_new/components/chat/chat-content/vis-convert-error.tsx delete mode 100644 web_new/components/chat/chat-content/vis-dashboard.tsx delete mode 100644 web_new/components/chat/chat-content/vis-plugin.tsx delete mode 100644 web_new/components/chat/chat-feedback.tsx delete mode 100644 web_new/components/chat/completion.tsx delete mode 100644 web_new/components/chat/db-editor.tsx delete mode 100644 web_new/components/chat/doc-list.tsx delete mode 100644 web_new/components/chat/doc-upload.tsx delete mode 100644 web_new/components/chat/header/agent-selector.tsx delete mode 100644 web_new/components/chat/header/chat-excel.tsx delete mode 100644 web_new/components/chat/header/db-selector.tsx delete mode 100644 web_new/components/chat/header/excel-upload.tsx delete mode 100644 web_new/components/chat/header/index.tsx delete mode 100644 web_new/components/chat/header/model-selector.tsx delete mode 100644 web_new/components/chat/mode-tab/index.css delete mode 100644 web_new/components/chat/mode-tab/index.tsx delete mode 100644 web_new/components/chat/monaco-editor.tsx delete mode 100644 web_new/components/chat/ob-editor/ob-plugin.ts delete mode 100644 web_new/components/chat/ob-editor/service.ts delete mode 100644 web_new/components/chat/ob-editor/theme.ts delete mode 100644 web_new/components/common/FileStatusIcon.tsx delete mode 100644 web_new/components/common/MyEmpty.tsx delete mode 100644 web_new/components/common/chat-dialog.tsx delete mode 100644 web_new/components/common/completion-input.tsx delete mode 100644 web_new/components/common/db-icon.tsx delete mode 100644 web_new/components/common/gpt-card.tsx delete mode 100644 web_new/components/common/icon-wrapper.tsx delete mode 100644 web_new/components/common/loading.tsx delete mode 100644 web_new/components/common/prompt-bot.tsx delete mode 100644 web_new/components/database/form-dialog.tsx delete mode 100644 web_new/components/flow/add-nodes.tsx delete mode 100644 web_new/components/flow/button-edge.tsx delete mode 100644 web_new/components/flow/canvas-node.tsx delete mode 100644 web_new/components/flow/flow-card.tsx delete mode 100644 web_new/components/flow/node-handler.tsx delete mode 100644 web_new/components/flow/node-param-handler.tsx delete mode 100644 web_new/components/flow/preview-flow.tsx delete mode 100644 web_new/components/flow/required-icon.tsx delete mode 100644 web_new/components/flow/static-nodes.tsx delete mode 100644 web_new/components/icons/add-icon.tsx delete mode 100644 web_new/components/icons/collect.tsx delete mode 100644 web_new/components/icons/collected.tsx delete mode 100644 web_new/components/icons/colorful-chat.tsx delete mode 100644 web_new/components/icons/colorful-dashboard.tsx delete mode 100644 web_new/components/icons/colorful-data.tsx delete mode 100644 web_new/components/icons/colorful-db.tsx delete mode 100644 web_new/components/icons/colorful-doc.tsx delete mode 100644 web_new/components/icons/colorful-excel.tsx delete mode 100644 web_new/components/icons/colorful-plugin.tsx delete mode 100644 web_new/components/icons/dark-svg.tsx delete mode 100644 web_new/components/icons/database.tsx delete mode 100644 web_new/components/icons/db-svg.tsx delete mode 100644 web_new/components/icons/done-icon.tsx delete mode 100644 web_new/components/icons/field.tsx delete mode 100644 web_new/components/icons/file-done.tsx delete mode 100644 web_new/components/icons/file-error.tsx delete mode 100644 web_new/components/icons/file-sync.tsx delete mode 100644 web_new/components/icons/index.tsx delete mode 100644 web_new/components/icons/knowledge.tsx delete mode 100644 web_new/components/icons/model-svg.tsx delete mode 100644 web_new/components/icons/pending-icon.tsx delete mode 100644 web_new/components/icons/split-screen-height.tsx delete mode 100644 web_new/components/icons/split-screen-width.tsx delete mode 100644 web_new/components/icons/stars-svg.tsx delete mode 100644 web_new/components/icons/sunny-svg.tsx delete mode 100644 web_new/components/icons/sync-icon.tsx delete mode 100644 web_new/components/icons/table.tsx delete mode 100644 web_new/components/knowledge/arguments-modal.tsx delete mode 100644 web_new/components/knowledge/doc-icon.tsx delete mode 100644 web_new/components/knowledge/doc-panel.tsx delete mode 100644 web_new/components/knowledge/doc-type-form.tsx delete mode 100644 web_new/components/knowledge/doc-upload-form.tsx delete mode 100644 web_new/components/knowledge/segmentation.tsx delete mode 100644 web_new/components/knowledge/space-card.tsx delete mode 100644 web_new/components/knowledge/space-form.tsx delete mode 100644 web_new/components/knowledge/strategy-form.tsx delete mode 100644 web_new/components/layout/side-bar.tsx delete mode 100644 web_new/components/layout/top-progress-bar.tsx delete mode 100644 web_new/components/model/model-card.tsx delete mode 100644 web_new/components/model/model-form.tsx delete mode 100644 web_new/components/model/model-params.tsx delete mode 100644 web_new/components/prompt/prompt-form.tsx delete mode 100644 web_new/genAntdCss.ts delete mode 100644 web_new/global.d.ts delete mode 100644 web_new/hooks/use-chat.ts delete mode 100644 web_new/hooks/use-summary.ts delete mode 100644 web_new/next-env.d.ts delete mode 100644 web_new/next.config.js delete mode 100644 web_new/nprogress.css delete mode 100644 web_new/package.json delete mode 100644 web_new/pages/_app.tsx delete mode 100644 web_new/pages/_document.tsx delete mode 100644 web_new/pages/agent/index.tsx delete mode 100644 web_new/pages/app/index.tsx delete mode 100644 web_new/pages/chat/index.tsx delete mode 100644 web_new/pages/database/index.tsx delete mode 100644 web_new/pages/flow/canvas/index.tsx delete mode 100644 web_new/pages/flow/index.tsx delete mode 100644 web_new/pages/index.tsx delete mode 100644 web_new/pages/knowledge/chunk/index.tsx delete mode 100644 web_new/pages/knowledge/graph/index.tsx delete mode 100644 web_new/pages/knowledge/index.tsx delete mode 100644 web_new/pages/models/index.tsx delete mode 100644 web_new/pages/prompt/index.tsx delete mode 100644 web_new/postcss.config.js delete mode 100644 web_new/public/LOGO.png delete mode 100644 web_new/public/LOGO_1.png delete mode 100644 web_new/public/LOGO_SMALL.png delete mode 100644 web_new/public/empty.png delete mode 100644 web_new/public/favicon.ico delete mode 100644 web_new/public/huggingface_logo.svg delete mode 100644 web_new/public/icons/access.png delete mode 100644 web_new/public/icons/cassandra.png delete mode 100644 web_new/public/icons/clickhouse.png delete mode 100644 web_new/public/icons/couchbase.png delete mode 100644 web_new/public/icons/db.png delete mode 100644 web_new/public/icons/db2.png delete mode 100644 web_new/public/icons/doris.png delete mode 100644 web_new/public/icons/duckdb.png delete mode 100644 web_new/public/icons/hbase.png delete mode 100644 web_new/public/icons/hive.png delete mode 100644 web_new/public/icons/knowledge.png delete mode 100644 web_new/public/icons/mongodb.png delete mode 100644 web_new/public/icons/mssql.png delete mode 100644 web_new/public/icons/mysql.png delete mode 100644 web_new/public/icons/node/default_node_icon.svg delete mode 100644 web_new/public/icons/node/http_trigger.svg delete mode 100644 web_new/public/icons/node/llm_operator.svg delete mode 100644 web_new/public/icons/node/openai_llm_client.svg delete mode 100644 web_new/public/icons/node/vis.png delete mode 100644 web_new/public/icons/oceanbase.png delete mode 100644 web_new/public/icons/oracle.png delete mode 100644 web_new/public/icons/postgresql.png delete mode 100644 web_new/public/icons/redis.png delete mode 100644 web_new/public/icons/spark.png delete mode 100644 web_new/public/icons/sqlite.png delete mode 100644 web_new/public/icons/starrocks.png delete mode 100644 web_new/public/icons/tugraph.png delete mode 100644 web_new/public/icons/vertica.png delete mode 100644 web_new/public/models/baichuan.png delete mode 100644 web_new/public/models/bard.gif delete mode 100644 web_new/public/models/chatglm.png delete mode 100644 web_new/public/models/chatgpt.png delete mode 100644 web_new/public/models/chroma-logo.png delete mode 100644 web_new/public/models/claude.png delete mode 100644 web_new/public/models/falcon.jpeg delete mode 100644 web_new/public/models/fin_report.jpg delete mode 100644 web_new/public/models/google.png delete mode 100644 web_new/public/models/gorilla.png delete mode 100644 web_new/public/models/huggingface.svg delete mode 100644 web_new/public/models/internlm.png delete mode 100644 web_new/public/models/knowledge-default.jpg delete mode 100644 web_new/public/models/knowledge-full-text.jpg delete mode 100644 web_new/public/models/knowledge-graph.png delete mode 100644 web_new/public/models/llama-cpp.png delete mode 100644 web_new/public/models/llama.jpg delete mode 100644 web_new/public/models/qwen2.png delete mode 100644 web_new/public/models/salesforce.jpeg delete mode 100644 web_new/public/models/solar_logo.png delete mode 100644 web_new/public/models/vicuna.jpeg delete mode 100644 web_new/public/models/vllm.png delete mode 100644 web_new/public/models/wizardlm.png delete mode 100644 web_new/public/models/yi.svg delete mode 100644 web_new/public/models/zhipu.png delete mode 100644 web_new/public/pictures/fallback.png delete mode 100644 web_new/styles/globals.css delete mode 100644 web_new/tailwind.config.js delete mode 100644 web_new/tsconfig.json delete mode 100644 web_new/types/agent.ts delete mode 100644 web_new/types/app.ts delete mode 100644 web_new/types/chat.ts delete mode 100644 web_new/types/db.ts delete mode 100644 web_new/types/editor.ts delete mode 100644 web_new/types/flow.ts delete mode 100644 web_new/types/knowledge.ts delete mode 100644 web_new/types/model.ts delete mode 100644 web_new/types/prompt.ts delete mode 100644 web_new/utils/constants.ts delete mode 100644 web_new/utils/ctx-axios.ts delete mode 100644 web_new/utils/flow.ts delete mode 100644 web_new/utils/index.ts delete mode 100644 web_new/utils/request.ts delete mode 100644 web_new/utils/storage.ts diff --git a/web/.env.template b/web/.env.template deleted file mode 100644 index e1ccb02b6..000000000 --- a/web/.env.template +++ /dev/null @@ -1 +0,0 @@ -API_BASE_URL=http://127.0.0.1:5000 \ No newline at end of file diff --git a/web/.prettierrc b/web/.prettierrc deleted file mode 100644 index 91e2a9ce2..000000000 --- a/web/.prettierrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "tabWidth": 2, - "printWidth": 150, - "semi": true, - "trailingComma": "all", - "singleQuote": true, - "jsxSingleQuote": false, - "arrowParens": "always" -} diff --git a/web/README.md b/web/README.md index 1ae75a221..512b446d0 100644 --- a/web/README.md +++ b/web/README.md @@ -36,6 +36,7 @@ Also, it is a **LLM to Vision** solution. ### Prerequisites - [Node.js](https://nodejs.org/) >= 16 +- [npm](https://npmjs.com/) >= 8 - [yarn](https://yarnpkg.com/) >= 1.22 - Supported OSes: Linux, macOS and Windows @@ -43,6 +44,7 @@ Also, it is a **LLM to Vision** solution. ```sh # Install dependencies +npm install yarn install ``` @@ -54,12 +56,14 @@ edit the `API_BASE_URL` to the real address ```sh # development model +npm run dev yarn dev ``` ## 🚀 Use In DB-GPT ```sh +npm run compile yarn compile # copy compile file to DB-GPT static file dictory @@ -90,4 +94,40 @@ Enjoy using DB-GPT-Web to build stunning UIs for your AI and GPT projects. For any queries or issues, feel free to open an [issue](https://github.com/eosphoros-ai/DB-GPT-Web/issues) on the repository. -Happy coding! 😊 \ No newline at end of file +Happy coding! 😊 + + +## antdbgptweb installation + +### deploy in local environment: + +1. 在 /etc/hosts文件增加一行, 必须配置本地xxx.alipay.net,否则无法接入线下的登陆系统 +``` +127.0.0.1 local.alipay.net +``` + +2. 在.env文件增加下面配置 +deploy in local environment: +``` +ANT_BUC_GET_USER_URL='http://antbuservice.stable.alipay.net/pub/getLoginUser.json?appName=antdbgpt' +ANT_BUC_NOT_LOGIN_URL='http://antbuservice.stable.alipay.net/pub/userNotLogin.htm?appName=antdbgpt&sourceUrl=' +API_BASE_URL='http://local.alipay.net:5000' +``` + +OR modify file next.config.js +``` + env: { + API_BASE_URL: process.env.API_BASE_URL || "http://local.alipay.net:5000", + GITHUB_CLIENT_ID: process.env.GITHUB_CLIENT_ID, + GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID, + ANT_BUC_GET_USER_URL: 'http://antbuservice.stable.alipay.net/pub/getLoginUser.json?appName=antdbgpt', + ANT_BUC_NOT_LOGIN_URL: 'http://antbuservice.stable.alipay.net/pub/userNotLogin.htm?appName=antdbgpt&sourceUrl=' + }, +``` + + +deploy in production environment: +``` +ANT_BUC_GET_USER_URL=https://antbuservice.alipay.com/pub/getLoginUser.json?appName=antdbgpt +ANT_BUC_NOT_LOGIN_URL=https://antbuservice.alipay.com/pub/userNotLogin.htm?appName=antdbgpt&sourceUrl= +``` diff --git a/web_new/ant-components/README.md b/web/ant-components/README.md similarity index 100% rename from web_new/ant-components/README.md rename to web/ant-components/README.md diff --git a/web_new/ant-components/app/AppCard.tsx b/web/ant-components/app/AppCard.tsx similarity index 100% rename from web_new/ant-components/app/AppCard.tsx rename to web/ant-components/app/AppCard.tsx diff --git a/web_new/ant-components/app/TabContent.tsx b/web/ant-components/app/TabContent.tsx similarity index 100% rename from web_new/ant-components/app/TabContent.tsx rename to web/ant-components/app/TabContent.tsx diff --git a/web_new/ant-components/chat/ChatContentContainer.tsx b/web/ant-components/chat/ChatContentContainer.tsx similarity index 100% rename from web_new/ant-components/chat/ChatContentContainer.tsx rename to web/ant-components/chat/ChatContentContainer.tsx diff --git a/web_new/ant-components/chat/content/ChatCompletion.tsx b/web/ant-components/chat/content/ChatCompletion.tsx similarity index 100% rename from web_new/ant-components/chat/content/ChatCompletion.tsx rename to web/ant-components/chat/content/ChatCompletion.tsx diff --git a/web_new/ant-components/chat/content/ChatContent.tsx b/web/ant-components/chat/content/ChatContent.tsx similarity index 100% rename from web_new/ant-components/chat/content/ChatContent.tsx rename to web/ant-components/chat/content/ChatContent.tsx diff --git a/web_new/ant-components/chat/content/ChatDefault.tsx b/web/ant-components/chat/content/ChatDefault.tsx similarity index 100% rename from web_new/ant-components/chat/content/ChatDefault.tsx rename to web/ant-components/chat/content/ChatDefault.tsx diff --git a/web_new/ant-components/chat/content/Feedback.tsx b/web/ant-components/chat/content/Feedback.tsx similarity index 100% rename from web_new/ant-components/chat/content/Feedback.tsx rename to web/ant-components/chat/content/Feedback.tsx diff --git a/web_new/ant-components/chat/content/ModelIcon.tsx b/web/ant-components/chat/content/ModelIcon.tsx similarity index 100% rename from web_new/ant-components/chat/content/ModelIcon.tsx rename to web/ant-components/chat/content/ModelIcon.tsx diff --git a/web_new/ant-components/chat/content/RobotIcon.tsx b/web/ant-components/chat/content/RobotIcon.tsx similarity index 100% rename from web_new/ant-components/chat/content/RobotIcon.tsx rename to web/ant-components/chat/content/RobotIcon.tsx diff --git a/web_new/ant-components/chat/header/ChatHeader.tsx b/web/ant-components/chat/header/ChatHeader.tsx similarity index 100% rename from web_new/ant-components/chat/header/ChatHeader.tsx rename to web/ant-components/chat/header/ChatHeader.tsx diff --git a/web_new/ant-components/chat/input/ChatInput.tsx b/web/ant-components/chat/input/ChatInput.tsx similarity index 100% rename from web_new/ant-components/chat/input/ChatInput.tsx rename to web/ant-components/chat/input/ChatInput.tsx diff --git a/web_new/ant-components/chat/input/ChatInputPanel.tsx b/web/ant-components/chat/input/ChatInputPanel.tsx similarity index 100% rename from web_new/ant-components/chat/input/ChatInputPanel.tsx rename to web/ant-components/chat/input/ChatInputPanel.tsx diff --git a/web_new/ant-components/chat/input/ModelSwitcher.tsx b/web/ant-components/chat/input/ModelSwitcher.tsx similarity index 100% rename from web_new/ant-components/chat/input/ModelSwitcher.tsx rename to web/ant-components/chat/input/ModelSwitcher.tsx diff --git a/web_new/ant-components/chat/input/Resource.tsx b/web/ant-components/chat/input/Resource.tsx similarity index 100% rename from web_new/ant-components/chat/input/Resource.tsx rename to web/ant-components/chat/input/Resource.tsx diff --git a/web_new/ant-components/chat/input/Temperature.tsx b/web/ant-components/chat/input/Temperature.tsx similarity index 100% rename from web_new/ant-components/chat/input/Temperature.tsx rename to web/ant-components/chat/input/Temperature.tsx diff --git a/web_new/ant-components/chat/input/ToolsBar.tsx b/web/ant-components/chat/input/ToolsBar.tsx similarity index 100% rename from web_new/ant-components/chat/input/ToolsBar.tsx rename to web/ant-components/chat/input/ToolsBar.tsx diff --git a/web_new/ant-components/chat/sider/ChatSider.tsx b/web/ant-components/chat/sider/ChatSider.tsx similarity index 100% rename from web_new/ant-components/chat/sider/ChatSider.tsx rename to web/ant-components/chat/sider/ChatSider.tsx diff --git a/web_new/ant-components/common/AppDefaultIcon.tsx b/web/ant-components/common/AppDefaultIcon.tsx similarity index 100% rename from web_new/ant-components/common/AppDefaultIcon.tsx rename to web/ant-components/common/AppDefaultIcon.tsx diff --git a/web_new/ant-components/common/Icon.tsx b/web/ant-components/common/Icon.tsx similarity index 100% rename from web_new/ant-components/common/Icon.tsx rename to web/ant-components/common/Icon.tsx diff --git a/web_new/ant-components/common/MarkdownContext.tsx b/web/ant-components/common/MarkdownContext.tsx similarity index 100% rename from web_new/ant-components/common/MarkdownContext.tsx rename to web/ant-components/common/MarkdownContext.tsx diff --git a/web_new/ant-components/common/MyEmpty.tsx b/web/ant-components/common/MyEmpty.tsx similarity index 100% rename from web_new/ant-components/common/MyEmpty.tsx rename to web/ant-components/common/MyEmpty.tsx diff --git a/web_new/ant-components/common/blurredCard/index.tsx b/web/ant-components/common/blurredCard/index.tsx similarity index 100% rename from web_new/ant-components/common/blurredCard/index.tsx rename to web/ant-components/common/blurredCard/index.tsx diff --git a/web_new/ant-components/common/blurredCard/style.css b/web/ant-components/common/blurredCard/style.css similarity index 100% rename from web_new/ant-components/common/blurredCard/style.css rename to web/ant-components/common/blurredCard/style.css diff --git a/web_new/ant-components/common/modelSelector/index.tsx b/web/ant-components/common/modelSelector/index.tsx similarity index 100% rename from web_new/ant-components/common/modelSelector/index.tsx rename to web/ant-components/common/modelSelector/index.tsx diff --git a/web_new/ant-components/common/modelSelector/styles.module.css b/web/ant-components/common/modelSelector/styles.module.css similarity index 100% rename from web_new/ant-components/common/modelSelector/styles.module.css rename to web/ant-components/common/modelSelector/styles.module.css diff --git a/web_new/ant-components/layout/Construct.tsx b/web/ant-components/layout/Construct.tsx similarity index 100% rename from web_new/ant-components/layout/Construct.tsx rename to web/ant-components/layout/Construct.tsx diff --git a/web_new/ant-components/layout/FloatHelper.tsx b/web/ant-components/layout/FloatHelper.tsx similarity index 100% rename from web_new/ant-components/layout/FloatHelper.tsx rename to web/ant-components/layout/FloatHelper.tsx diff --git a/web_new/ant-components/layout/Header.tsx b/web/ant-components/layout/Header.tsx similarity index 100% rename from web_new/ant-components/layout/Header.tsx rename to web/ant-components/layout/Header.tsx diff --git a/web_new/ant-components/layout/Sider.tsx b/web/ant-components/layout/Sider.tsx similarity index 100% rename from web_new/ant-components/layout/Sider.tsx rename to web/ant-components/layout/Sider.tsx diff --git a/web_new/ant-components/layout/UserBar.tsx b/web/ant-components/layout/UserBar.tsx similarity index 100% rename from web_new/ant-components/layout/UserBar.tsx rename to web/ant-components/layout/UserBar.tsx diff --git a/web_new/ant-components/layout/style.css b/web/ant-components/layout/style.css similarity index 100% rename from web_new/ant-components/layout/style.css rename to web/ant-components/layout/style.css diff --git a/web/app/chat-context.tsx b/web/app/chat-context.tsx index f2c4b2493..62827e79f 100644 --- a/web/app/chat-context.tsx +++ b/web/app/chat-context.tsx @@ -1,9 +1,11 @@ -import { createContext, useEffect, useMemo, useState } from 'react'; -import { apiInterceptors, getDialogueList, getUsableModels } from '@/client/api'; -import { useRequest } from 'ahooks'; +import { apiInterceptors, getDialogueList, getUsableModels, queryAdminList } from '@/client/api'; import { ChatHistoryResponse, DialogueListResponse, IChatDialogueSchema } from '@/types/chat'; +import { UserInfoResponse } from '@/types/userinfo'; +import { getUserId } from '@/utils'; +import { STORAGE_THEME_KEY } from '@/utils/constants/index'; +import { useRequest } from 'ahooks'; import { useSearchParams } from 'next/navigation'; -import { STORAGE_THEME_KEY } from '@/utils'; +import { createContext, useEffect, useMemo, useState } from 'react'; type ThemeMode = 'dark' | 'light'; @@ -14,8 +16,8 @@ interface IChatContext { scene: IChatDialogueSchema['chat_mode'] | (string & {}); chatId: string; model: string; + modelList: string[]; dbParam?: string; - modelList: Array; agent: string; dialogueList?: DialogueListResponse; setAgent?: (val: string) => void; @@ -24,13 +26,19 @@ interface IChatContext { setIsContract: (val: boolean) => void; setIsMenuExpand: (val: boolean) => void; setDbParam: (val: string) => void; - queryDialogueList: () => void; - refreshDialogList: () => void; currentDialogue?: DialogueListResponse[0]; history: ChatHistoryResponse; setHistory: (val: ChatHistoryResponse) => void; docId?: number; setDocId: (docId: number) => void; + // 当前对话信息 + currentDialogInfo: { + chat_scene: string; + app_code: string; + }; + setCurrentDialogInfo: (val: { chat_scene: string; app_code: string }) => void; + adminList: UserInfoResponse[]; + refreshDialogList?: any; } function getDefaultTheme(): ThemeMode { @@ -43,8 +51,8 @@ const ChatContext = createContext({ mode: 'light', scene: '', chatId: '', - modelList: [], model: '', + modelList: [], dbParam: undefined, dialogueList: [], agent: '', @@ -53,13 +61,18 @@ const ChatContext = createContext({ setIsContract: () => {}, setIsMenuExpand: () => {}, setDbParam: () => void 0, - queryDialogueList: () => {}, - refreshDialogList: () => {}, setMode: () => void 0, history: [], setHistory: () => {}, docId: undefined, setDocId: () => {}, + currentDialogInfo: { + chat_scene: '', + app_code: '', + }, + setCurrentDialogInfo: () => {}, + adminList: [], + refreshDialogList: () => {}, }); const ChatContextProvider = ({ children }: { children: React.ReactElement }) => { @@ -67,7 +80,6 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) => const chatId = searchParams?.get('id') ?? ''; const scene = searchParams?.get('scene') ?? ''; const db_param = searchParams?.get('db_param') ?? ''; - const [isContract, setIsContract] = useState(false); const [model, setModel] = useState(''); const [isMenuExpand, setIsMenuExpand] = useState(scene !== 'chat_dashboard'); @@ -76,51 +88,66 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) => const [history, setHistory] = useState([]); const [docId, setDocId] = useState(); const [mode, setMode] = useState('light'); + // 管理员列表 + const [adminList, setAdminList] = useState([]); - const { - run: queryDialogueList, - data: dialogueList = [], - refresh: refreshDialogList, - } = useRequest( - async () => { - const [, res] = await apiInterceptors(getDialogueList()); - return res ?? []; - }, - { - manual: true, - }, - ); - - useEffect(() => { - if (dialogueList.length && scene === 'chat_agent') { - const agent = dialogueList.find((item) => item.conv_uid === chatId)?.select_param; - agent && setAgent(agent); - } - }, [dialogueList, scene, chatId]); + const [currentDialogInfo, setCurrentDialogInfo] = useState({ + chat_scene: '', + app_code: '', + }); + // 获取model const { data: modelList = [] } = useRequest(async () => { const [, res] = await apiInterceptors(getUsableModels()); return res ?? []; }); + // 获取管理员列表 + const { run: queryAdminListRun } = useRequest( + async () => { + const [, res] = await apiInterceptors(queryAdminList({ role: 'admin' })); + return res ?? []; + }, + { + onSuccess: (data) => { + setAdminList(data); + }, + manual: true, + }, + ); + + useEffect(() => { + if (getUserId()) { + queryAdminListRun(); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [queryAdminListRun, getUserId()]); + useEffect(() => { setMode(getDefaultTheme()); + try { + const dialogInfo = JSON.parse(localStorage.getItem('cur_dialog_info') || ''); + setCurrentDialogInfo(dialogInfo); + } catch (error) { + setCurrentDialogInfo({ + chat_scene: '', + app_code: '', + }); + } }, []); useEffect(() => { setModel(modelList[0]); }, [modelList, modelList?.length]); - const currentDialogue = useMemo(() => dialogueList.find((item: any) => item.conv_uid === chatId), [chatId, dialogueList]); const contextValue = { isContract, isMenuExpand, scene, chatId, - modelList, model, + modelList, dbParam: dbParam || db_param, - dialogueList, agent, setAgent, mode, @@ -129,13 +156,13 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) => setIsContract, setIsMenuExpand, setDbParam, - queryDialogueList, - refreshDialogList, - currentDialogue, history, setHistory, docId, setDocId, + currentDialogInfo, + setCurrentDialogInfo, + adminList, }; return {children}; }; diff --git a/web/app/i18n.ts b/web/app/i18n.ts index 1ecde2e6c..b9bf268e1 100644 --- a/web/app/i18n.ts +++ b/web/app/i18n.ts @@ -1,464 +1,13 @@ import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; - -const en = { - Knowledge_Space: 'Knowledge', - space: 'space', - Vector: 'Vector', - Owner: 'Owner', - Count: 'Count', - File_type_Invalid: 'The file type is invalid', - Knowledge_Space_Config: 'Space Config', - Choose_a_Datasource_type: 'Datasource type', - Segmentation: 'Segmentation', - No_parameter: `No segementation parameter required.`, - Knowledge_Space_Name: 'Knowledge Space Name', - Please_input_the_name: 'Please input the name', - Please_input_the_owner: 'Please input the owner', - Please_select_file: 'Please select one file', - Description: 'Description', - Storage: 'Storage', - Please_input_the_description: 'Please input the description', - Please_select_the_storage: 'Please select the storage', - Please_select_the_domain_type: 'Please select the domain type', - Next: 'Next', - the_name_can_only_contain: 'the name can only contain numbers, letters, Chinese characters, "-" and "_"', - Text: 'Text', - 'Fill your raw text': 'Fill your raw text', - URL: 'URL', - Fetch_the_content_of_a_URL: 'Fetch the content of a URL', - Document: 'Document', - Upload_a_document: 'Upload a document, document type can be PDF, CSV, Text, PowerPoint, Word, Markdown', - Name: 'Name', - Text_Source: 'Text Source(Optional)', - Please_input_the_text_source: 'Please input the text source', - Sync: 'Sync', - Back: 'Back', - Finish: 'Finish', - Web_Page_URL: 'Web Page URL', - Please_input_the_Web_Page_URL: 'Please input the Web Page URL', - Select_or_Drop_file: 'Select or Drop file', - Documents: 'Documents', - Chat: 'Chat', - Add_Datasource: 'Add Datasource', - View_Graph: 'View Graph', - Arguments: 'Arguments', - Type: 'Type', - Size: 'Size', - Last_Sync: 'Last Sync', - Status: 'Status', - Result: 'Result', - Details: 'Details', - Delete: 'Delete', - Operation: 'Operation', - Submit: 'Submit', - Chunks: 'Chunks', - Content: 'Content', - Meta_Data: 'Meta Data', - Please_select_a_file: 'Please select a file', - Please_input_the_text: 'Please input the text', - Embedding: 'Embedding', - topk: 'topk', - the_top_k_vectors: 'the top k vectors based on similarity score', - recall_score: 'recall_score', - Set_a_threshold_score: 'Set a threshold score for the retrieval of similar vectors', - recall_type: 'recall_type', - model: 'model', - A_model_used: 'A model used to create vector representations of text or other data', - Automatic: 'Automatic', - Process: 'Process', - Automatic_desc: 'Automatically set segmentation and preprocessing rules.', - chunk_size: 'chunk_size', - The_size_of_the_data_chunks: 'The size of the data chunks used in processing', - chunk_overlap: 'chunk_overlap', - The_amount_of_overlap: 'The amount of overlap between adjacent data chunks', - Prompt: 'Prompt', - scene: 'scene', - A_contextual_parameter: 'A contextual parameter used to define the setting or environment in which the prompt is being used', - template: 'template', - structure_or_format: - 'A pre-defined structure or format for the prompt, which can help ensure that the AI system generates responses that are consistent with the desired style or tone.', - max_token: 'max_token', - max_iteration: 'max_iteration', - concurrency_limit: 'concurrency_limit', - The_maximum_number_of_tokens: 'The maximum number of tokens or words allowed in a prompt', - Theme: 'Theme', - Port: 'Port', - Username: 'Username', - Password: 'Password', - Remark: 'Remark', - Edit: 'Edit', - Database: 'Database', - Data_Source: 'Data Center', - Close_Sidebar: 'Fold', - Show_Sidebar: 'UnFold', - language: 'Language', - choose_model: 'Please choose a model', - data_center_desc: 'DB-GPT also offers a user-friendly data center management interface for efficient data maintenance.', - create_database: 'Create Database', - create_knowledge: 'Create Knowledge', - path: 'Path', - model_manage: 'Models', - stop_model_success: 'Stop model success', - create_model: 'Create Model', - model_select_tips: 'Please select a model', - language_select_tips: 'Please select a language', - submit: 'Submit', - close: 'Close', - start_model_success: 'Start model success', - download_model_tip: 'Please download model first.', - Plugins: 'Plugins', - try_again: 'Try again', - no_data: 'No data', - Open_Sidebar: 'Unfold', - cancel: 'Cancel', - Edit_Success: 'Edit Success', - Add: 'Add', - Add_Success: 'Add Success', - Error_Message: 'Something Error', - Please_Input: 'Please Input', - Prompt_Info_Scene: 'Scene', - Prompt_Info_Sub_Scene: 'Sub Scene', - Prompt_Info_Name: 'Name', - Prompt_Info_Content: 'Content', - Public: 'Public', - Private: 'Private', - Lowest: 'Lowest', - Missed: 'Missed', - Lost: 'Lost', - Incorrect: 'Incorrect', - Verbose: 'Verbose', - Best: 'Best', - Rating: 'Rating', - Q_A_Category: 'Q&A Category', - Q_A_Rating: 'Q&A Rating', - feed_back_desc: - '0: No results\n' + - '1: Results exist, but they are irrelevant, the question is not understood\n' + - '2: Results exist, the question is understood, but it indicates that the question cannot be answered\n' + - '3: Results exist, the question is understood, and an answer is given, but the answer is incorrect\n' + - '4: Results exist, the question is understood, the answer is correct, but it is verbose and lacks a summary\n' + - '5: Results exist, the question is understood, the answer is correct, the reasoning is correct, and a summary is provided, concise and to the point\n', - input_count: 'Total input', - input_unit: 'characters', - Copy: 'Copy', - Copy_success: 'Content copied successfully', - Copy_nothing: 'Content copied is empty', - Copry_error: 'Copy failed', - Click_Select: 'Click&Select', - Quick_Start: 'Quick Start', - Select_Plugins: 'Select Plugins', - Search: 'Search', - Update_From_Github: 'Upload From Github', - Reset: 'Reset', - Upload: 'Upload', - Market_Plugins: 'Market Plugin', - My_Plugins: 'My Plugins', - Del_Knowledge_Tips: 'Do you want delete the Space', - Del_Document_Tips: 'Do you want delete the Document', - Tips: 'Tips', - Limit_Upload_File_Count_Tips: 'Only one file can be uploaded at a time', - To_Plugin_Market: 'Go to the Plugin Market', - Summary: 'Summary', - stacked_column_chart: 'Stacked Column', - column_chart: 'Column', - percent_stacked_column_chart: 'Percent Stacked Column', - grouped_column_chart: 'Grouped Column', - time_column: 'Time Column', - pie_chart: 'Pie', - line_chart: 'Line', - area_chart: 'Area', - stacked_area_chart: 'Stacked Area', - scatter_plot: 'Scatter', - bubble_chart: 'Bubble', - stacked_bar_chart: 'Stacked Bar', - bar_chart: 'Bar', - percent_stacked_bar_chart: 'Percent Stacked Bar', - grouped_bar_chart: 'Grouped Bar', - water_fall_chart: 'Waterfall', - table: 'Table', - multi_line_chart: 'Multi Line', - multi_measure_column_chart: 'Multi Measure Column', - multi_measure_line_chart: 'Multi Measure Line', - Advices: 'Advices', - Retry: 'Retry', - Load_more: 'load more', - new_chat: 'New Chat', - choice_agent_tip: 'Please choose an agent', - no_context_tip: 'Please enter your question', - Terminal: 'Terminal', - awel_flow: 'AWEL Flow', - save: 'Save', - add_node: 'Add Node', - no_node: 'No Node', - connect_warning: 'Nodes cannot be connected', - flow_modal_title: 'Save Flow', - flow_name: 'Flow Name', - flow_description: 'Flow Description', - flow_name_required: 'Please enter the flow name', - flow_description_required: 'Please enter the flow description', - save_flow_success: 'Save flow success', - delete_flow_confirm: 'Are you sure you want to delete this flow?', - related_nodes: 'Related Nodes', - add_resource: 'Add Resource', - team_modal: 'Work Modal', - App: 'App', - resource_name: 'Resource Name', - resource_type: 'Resource Type', - resource_value: 'Value', - resource_dynamic: 'Dynamic', - Please_input_the_work_modal: 'Please select the work modal', - available_resources: ' Available Resources', - edit_new_applications: 'Edit new applications', - collect: 'Collect', - collected: 'Collected', - create: 'Create', - Agents: 'Agents', - edit_application: 'edit application', - add_application: 'add application', - app_name: 'App Name', - LLM_strategy: 'LLM Strategy', - LLM_strategy_value: 'LLM Strategy Value', - resource: 'Resource', - operators: 'Operators', - Chinese: 'Chinese', - English: 'English', - refreshSuccess: 'Refresh Success', - Download: 'Download' -} as const; +import en from '@/locales/en'; +import zh from '@/locales/zh'; export type I18nKeys = keyof typeof en; - -export interface Resources { +interface Resources { translation: Record; } -const zh: Resources['translation'] = { - Knowledge_Space: '知识库', - space: '知识库', - Vector: '向量', - Owner: '创建人', - Count: '文档数', - File_type_Invalid: '文件类型错误', - Knowledge_Space_Config: '知识库配置', - Choose_a_Datasource_type: '知识库类型', - Segmentation: '分片', - No_parameter: '不需要配置分片参数', - Knowledge_Space_Name: '知识库名称', - Please_input_the_name: '请输入名称', - Please_input_the_owner: '请输入创建人', - Please_select_file: '请至少选择一个文件', - Description: '描述', - Storage: '存储类型', - Domain: '领域类型', - Please_input_the_description: '请输入描述', - Please_select_the_storage: '请选择存储类型', - Please_select_the_domain_type: '请选择领域类型', - Next: '下一步', - the_name_can_only_contain: '名称只能包含数字、字母、中文字符、-或_', - Text: '文本', - 'Fill your raw text': '填写您的原始文本', - URL: '网址', - Fetch_the_content_of_a_URL: '获取 URL 的内容', - Document: '文档', - Upload_a_document: '上传文档,文档类型可以是PDF、CSV、Text、PowerPoint、Word、Markdown', - Name: '名称', - Text_Source: '文本来源(可选)', - Please_input_the_text_source: '请输入文本来源', - Sync: '同步', - Back: '上一步', - Finish: '完成', - Web_Page_URL: '网页网址', - Please_input_the_Web_Page_URL: '请输入网页网址', - Select_or_Drop_file: '选择或拖拽文件', - Documents: '文档', - Chat: '对话', - Add_Datasource: '添加数据源', - View_Graph: '查看图谱', - Arguments: '参数', - Type: '类型', - Size: '切片', - Last_Sync: '上次同步时间', - Status: '状态', - Result: '结果', - Details: '明细', - Delete: '删除', - Operation: '操作', - Submit: '提交', - close: '关闭', - Chunks: '切片', - Content: '内容', - Meta_Data: '元数据', - Please_select_a_file: '请上传一个文件', - Please_input_the_text: '请输入文本', - Embedding: '嵌入', - topk: 'TopK', - the_top_k_vectors: '基于相似度得分的前 k 个向量', - recall_score: '召回分数', - Set_a_threshold_score: '设置相似向量检索的阈值分数', - recall_type: '召回类型', - model: '模型', - A_model_used: '用于创建文本或其他数据的矢量表示的模型', - Automatic: '自动切片', - Process: '切片处理', - Automatic_desc: '自动设置分割和预处理规则。', - chunk_size: '块大小', - The_size_of_the_data_chunks: '处理中使用的数据块的大小', - chunk_overlap: '块重叠', - The_amount_of_overlap: '相邻数据块之间的重叠量', - scene: '场景', - A_contextual_parameter: '用于定义使用提示的设置或环境的上下文参数', - template: '模板', - structure_or_format: '预定义的提示结构或格式,有助于确保人工智能系统生成与所需风格或语气一致的响应。', - max_token: '最大令牌', - max_iteration: '最大迭代', - concurrency_limit: '并发限制', - The_maximum_number_of_tokens: '提示中允许的最大标记或单词数', - Theme: '主题', - Port: '端口', - Username: '用户名', - Password: '密码', - Remark: '备注', - Edit: '编辑', - Database: '数据库', - Data_Source: '数据中心', - Close_Sidebar: '收起', - Show_Sidebar: '展开', - language: '语言', - choose_model: '请选择一个模型', - data_center_desc: 'DB-GPT支持数据库交互和基于文档的对话,它还提供了一个用户友好的数据中心管理界面。', - create_database: '创建数据库', - create_knowledge: '创建知识库', - path: '路径', - model_manage: '模型管理', - stop_model_success: '模型停止成功', - create_model: '创建模型', - model_select_tips: '请选择一个模型', - submit: '提交', - start_model_success: '启动模型成功', - download_model_tip: '请先下载模型!', - Plugins: '插件列表', - try_again: '刷新重试', - no_data: '暂无数据', - Prompt: '提示语', - Open_Sidebar: '展开', - cancel: '取消', - Edit_Success: '编辑成功', - Add: '新增', - Add_Success: '新增成功', - Error_Message: '出错了', - Please_Input: '请输入', - Prompt_Info_Scene: '场景', - Prompt_Info_Sub_Scene: '次级场景', - Prompt_Info_Name: '名称', - Prompt_Info_Content: '内容', - Public: '公共', - Private: '私有', - Lowest: '渣渣', - Missed: '没理解', - Lost: '答不了', - Incorrect: '答错了', - Verbose: '较啰嗦', - Best: '真棒', - Rating: '评分', - Q_A_Category: '问答类别', - Q_A_Rating: '问答评分', - feed_back_desc: - '0: 无结果\n' + - '1: 有结果,但是在文不对题,没有理解问题\n' + - '2: 有结果,理解了问题,但是提示回答不了这个问题\n' + - '3: 有结果,理解了问题,并做出回答,但是回答的结果错误\n' + - '4: 有结果,理解了问题,回答结果正确,但是比较啰嗦,缺乏总结\n' + - '5: 有结果,理解了问题,回答结果正确,推理正确,并给出了总结,言简意赅\n', - input_count: '共计输入', - input_unit: '字', - Copy: '复制', - Copy_success: '内容复制成功', - Copy_nothing: '内容复制为空', - Copry_error: '复制失败', - Click_Select: '点击选择', - Quick_Start: '快速开始', - Select_Plugins: '选择插件', - Search: '搜索', - Reset: '重置', - Update_From_Github: '更新Github插件', - Upload: '上传', - Market_Plugins: '插件市场', - My_Plugins: '我的插件', - Del_Knowledge_Tips: '你确定删除该知识库吗', - Del_Document_Tips: '你确定删除该文档吗', - Tips: '提示', - Limit_Upload_File_Count_Tips: '一次只能上传一个文件', - To_Plugin_Market: '前往插件市场', - Summary: '总结', - stacked_column_chart: '堆叠柱状图', - column_chart: '柱状图', - percent_stacked_column_chart: '百分比堆叠柱状图', - grouped_column_chart: '簇形柱状图', - time_column: '簇形柱状图', - pie_chart: '饼图', - line_chart: '折线图', - area_chart: '面积图', - stacked_area_chart: '堆叠面积图', - scatter_plot: '散点图', - bubble_chart: '气泡图', - stacked_bar_chart: '堆叠条形图', - bar_chart: '条形图', - percent_stacked_bar_chart: '百分比堆叠条形图', - grouped_bar_chart: '簇形条形图', - water_fall_chart: '瀑布图', - table: '表格', - multi_line_chart: '多折线图', - multi_measure_column_chart: '多指标柱形图', - multi_measure_line_chart: '多指标折线图', - Advices: '自动推荐', - Retry: '重试', - Load_more: '加载更多', - new_chat: '创建会话', - choice_agent_tip: '请选择代理', - no_context_tip: '请输入你的问题', - Terminal: '终端', - awel_flow: 'AWEL 工作流', - save: '保存', - add_node: '添加节点', - no_node: '没有可编排节点', - connect_warning: '节点无法连接', - flow_modal_title: '保存工作流', - flow_name: '工作流名称', - flow_description: '工作流描述', - flow_name_required: '请输入工作流名称', - flow_description_required: '请输入工作流描述', - save_flow_success: '保存工作流成功', - delete_flow_confirm: '确定删除该工作流吗?', - related_nodes: '关联节点', - language_select_tips: '请选择语言', - add_resource: '添加资源', - team_modal: '工作模式', - App: '应用程序', - resource: '资源', - resource_name: '资源名', - resource_type: '资源类型', - resource_value: '参数', - resource_dynamic: '动态', - Please_input_the_work_modal: '请选择工作模式', - available_resources: '可用资源', - edit_new_applications: '编辑新的应用', - collect: '收藏', - collected: '已收藏', - create: '创建', - Agents: '智能体', - edit_application: '编辑应用', - add_application: '添加应用', - app_name: '应用名称', - LLM_strategy: '模型策略', - LLM_strategy_value: '模型策略参数', - operators: '算子', - Chinese: '中文', - English: '英文', - refreshSuccess: '刷新成功', - Download: '下载', -} as const; - i18n.use(initReactI18next).init({ resources: { en: { diff --git a/web_new/client/api/app/index.ts b/web/client/api/app/index.ts similarity index 100% rename from web_new/client/api/app/index.ts rename to web/client/api/app/index.ts diff --git a/web_new/client/api/chat/index.ts b/web/client/api/chat/index.ts similarity index 100% rename from web_new/client/api/chat/index.ts rename to web/client/api/chat/index.ts diff --git a/web_new/client/api/evaluate/index.ts b/web/client/api/evaluate/index.ts similarity index 100% rename from web_new/client/api/evaluate/index.ts rename to web/client/api/evaluate/index.ts diff --git a/web_new/client/api/flow/index.ts b/web/client/api/flow/index.ts similarity index 100% rename from web_new/client/api/flow/index.ts rename to web/client/api/flow/index.ts diff --git a/web/client/api/index.ts b/web/client/api/index.ts index f6bd6fab2..7936755c1 100644 --- a/web/client/api/index.ts +++ b/web/client/api/index.ts @@ -1,3 +1,5 @@ +import { getUserId } from '@/utils'; +import { HEADER_USER_ID_KEY } from '@/utils/constants/index'; import axios, { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios'; export type ResponseType = { @@ -39,8 +41,9 @@ const LONG_TIME_API: string[] = [ ins.interceptors.request.use((request) => { const isLongTimeApi = LONG_TIME_API.some((item) => request.url && request.url.indexOf(item) >= 0); if (!request.timeout) { - request.timeout = isLongTimeApi ? 60000 : 10000; + request.timeout = isLongTimeApi ? 60000 : 100000; } + request.headers.set(HEADER_USER_ID_KEY, getUserId()); return request; }); @@ -66,3 +69,10 @@ export const DELETE = (url: string, param export * from './tools'; export * from './request'; +export * from './chat'; +export * from './flow'; +export * from './app'; +export * from './knowledge'; +export * from './user'; +export * from './prompt'; +export * from './evaluate'; diff --git a/web_new/client/api/knowledge/index.ts b/web/client/api/knowledge/index.ts similarity index 100% rename from web_new/client/api/knowledge/index.ts rename to web/client/api/knowledge/index.ts diff --git a/web_new/client/api/prompt/index.ts b/web/client/api/prompt/index.ts similarity index 100% rename from web_new/client/api/prompt/index.ts rename to web/client/api/prompt/index.ts diff --git a/web/client/api/request.ts b/web/client/api/request.ts index bd735d8b1..706b9862b 100644 --- a/web/client/api/request.ts +++ b/web/client/api/request.ts @@ -1,8 +1,23 @@ -import { AxiosRequestConfig } from 'axios'; -import { DELETE, GET, POST, PUT } from '.'; -import { DbListResponse, DbSupportTypeResponse, PostDbParams, ChatFeedBackSchema, PostDbRefreshParams } from '@/types/db'; -import { DialogueListResponse, IChatDialogueSchema, NewDialogueParam, SceneResponse, ChatHistoryResponse, FeedBack, IDB } from '@/types/chat'; -import { IModelData, StartModelParams, BaseModelParams, SupportModel } from '@/types/model'; +import { + GetDBGPTsListResponse, + PostAgentHubUpdateParams, + PostAgentMyPluginResponse, + PostAgentPluginResponse, + PostAgentQueryParams, +} from '@/types/agent'; +import { GetAppInfoParams, IApp, IAgent, IAppData } from '@/types/app'; +import { + ChatHistoryResponse, + DialogueListResponse, + FeedBack, + IChatDialogueSchema, + IDB, + NewDialogueParam, + SceneResponse, + UserParam, + UserParamResponse, +} from '@/types/chat'; +import { ChatFeedBackSchema, DbListResponse, DbSupportTypeResponse, PostDbParams, PostDbRefreshParams } from '@/types/db'; import { GetEditorSQLRoundRequest, GetEditorySqlParams, @@ -11,13 +26,7 @@ import { PostEditorSQLRunParams, PostSQLEditorSubmitParams, } from '@/types/editor'; -import { - PostAgentHubUpdateParams, - PostAgentQueryParams, - PostAgentPluginResponse, - PostAgentMyPluginResponse, - GetDBGPTsListResponse, -} from '@/types/agent'; +import { IFlow, IFlowNode, IFlowUpdateParam, IFlowResponse } from '@/types/flow'; import { AddKnowledgeParams, ArgumentsParams, @@ -33,16 +42,21 @@ import { ISyncBatchResponse, SpaceConfig, } from '@/types/knowledge'; -import { UpdatePromptParams, IPrompt, PromptParams } from '@/types/prompt'; -import { IFlow, IFlowNode, IFlowResponse, IFlowUpdateParam } from '@/types/flow'; -import { IAgent, IApp, IAppData, ITeamModal } from '@/types/app'; +import { BaseModelParams, IModelData, StartModelParams, SupportModel } from '@/types/model'; +import { AxiosRequestConfig } from 'axios'; +import { DELETE, GET, POST, PUT } from '.'; + /** App */ export const postScenes = () => { return POST>('/api/v1/chat/dialogue/scenes'); }; export const newDialogue = (data: NewDialogueParam) => { - return POST('/api/v1/chat/dialogue/new', data); + return POST(`/api/v1/chat/dialogue/new?chat_mode=${data.chat_mode}&model_name=${data.model}`, data); +}; + +export const addUser = (data: UserParam) => { + return POST('/api/v1/user/add', data); }; /** Database Page */ @@ -90,15 +104,19 @@ export const postChatModeParamsFileLoad = ({ data, config, model, + userName, + sysCode, }: { convUid: string; chatMode: string; data: FormData; model: string; + userName?: string; + sysCode?: string; config?: Omit; }) => { - return POST( - `/api/v1/chat/mode/params/file/load?conv_uid=${convUid}&chat_mode=${chatMode}&model_name=${model}`, + return POST( + `/api/v1/resource/file/upload?conv_uid=${convUid}&chat_mode=${chatMode}&model_name=${model}&user_name=${userName}&sys_code=${sysCode}`, data, { headers: { @@ -109,6 +127,10 @@ export const postChatModeParamsFileLoad = ({ ); }; +export const clearChatHistory = (conUid: string) => { + return POST>(`/api/v1/chat/dialogue/clear?con_uid=${conUid}`); +}; + /** Menu */ export const delDialogue = (conv_uid: string) => { return POST(`/api/v1/chat/dialogue/delete?con_uid=${conv_uid}`); @@ -139,8 +161,8 @@ export const saveArguments = (knowledgeName: string, data: ArgumentsParams) => { return POST(`/knowledge/${knowledgeName}/argument/save`, data); }; -export const getSpaceList = () => { - return POST>('/knowledge/space/list', {}); +export const getSpaceList = (data: any) => { + return POST>('/knowledge/space/list', data); }; export const getDocumentList = (spaceName: string, data: Record>) => { return POST>, IDocumentResponse>(`/knowledge/${spaceName}/document/list`, data); @@ -154,7 +176,7 @@ export const addDocument = (knowledgeName: string, data: DocumentParams) => { }; export const addSpace = (data: AddKnowledgeParams) => { - return POST>(`/knowledge/space/add`, data); + return POST(`/knowledge/space/add`, data); }; export const getChunkStrategies = () => { @@ -178,7 +200,7 @@ export const getChunkList = (spaceName: string, data: ChunkListParams) => { }; export const delDocument = (spaceName: string, data: Record) => { - return POST>(`/knowledge/${spaceName}/document/delete`, data); + return POST, null>(`/knowledge/${spaceName}/document/delete`, data); }; export const delSpace = (data: Record) => { @@ -248,27 +270,12 @@ export const postChatFeedBackForm = ({ data, config }: { data: ChatFeedBackSchem }; /** prompt */ -export const getPromptList = (data: PromptParams) => { - return POST>('/prompt/list', data); -}; - -export const updatePrompt = (data: UpdatePromptParams) => { - return POST('/prompt/update', data); -}; - -export const addPrompt = (data: UpdatePromptParams) => { - return POST('/prompt/add', data); -}; /** AWEL Flow */ export const addFlow = (data: IFlowUpdateParam) => { return POST('/api/v1/serve/awel/flows', data); }; -export const getFlows = () => { - return GET('/api/v1/serve/awel/flows'); -}; - export const getFlowById = (id: string) => { return GET(`/api/v1/serve/awel/flows/${id}`); }; @@ -286,13 +293,6 @@ export const getFlowNodes = () => { }; /** app */ -export const addApp = (data: IApp) => { - return POST('/api/v1/app/create', data); -}; - -export const getAppList = (data: Record) => { - return POST, IAppData>('/api/v1/app/list', data); -}; export const collectApp = (data: Record) => { return POST, []>('/api/v1/app/collect', data); @@ -302,36 +302,51 @@ export const unCollectApp = (data: Record) => { return POST, []>('/api/v1/app/uncollect', data); }; -export const delApp = (data: Record) => { - return POST, []>('/api/v1/app/remove', data); -}; - -export const getAgents = () => { - return GET('/api/v1/agents/list', {}); -}; - -export const getTeamMode = () => { - return GET('/api/v1/team-mode/list'); -}; - export const getResourceType = () => { return GET('/api/v1/resource-type/list'); }; -export const getResource = (data: Record) => { - return GET, []>(`/api/v1/app/resources/list?type=${data.type}`); +export const publishApp = (app_code: string) => { + return POST, []>('/api/v1/app/publish', { app_code }); }; -export const updateApp = (data: IApp) => { - return POST('/api/v1/app/edit', data); +export const unPublishApp = (app_code: string) => { + return POST, []>('/api/v1/app/unpublish', { app_code }); +}; +export const addOmcDB = (params: Record) => { + return POST, []>('/api/v1/chat/db/add', params); }; -export const getAppStrategy = () => { - return GET(`/api/v1/llm-strategy/list`); +export const getAppInfo = (data: GetAppInfoParams) => { + return GET('/api/v1/app/info', data); }; -export const getAppStrategyValues = (type: string) => { - return GET(`/api/v1/llm-strategy/value/list?type=${type}`); +export const getSupportDBList = (db_name = '') => { + return GET>(`/api/v1/permission/db/list?db_name=${db_name}`); +}; + +export const recommendApps = (data: Record) => { + return POST, []>('/api/v1/app/hot/list', data); +}; +export const flowSearch = (data: Record) => { + return POST, []>('/api/v1/serve/awel/flows', data); +}; +export const modelSearch = (data: Record) => { + return POST, []>('/api/controller/models', data); +}; + +export const getKnowledgeAdmins = (spaceId: string) => { + return GET>(`/knowledge/users/list?space_id=${spaceId}`); +}; +export const updateKnowledgeAdmins = (data: Record) => { + return POST, any[]>(`/knowledge/users/update`, data); +}; + +/** AWEL Flow */ + +/** app */ +export const delApp = (data: Record) => { + return POST, []>('/api/v1/app/remove', data); }; export const getSpaceConfig = () => { diff --git a/web_new/client/api/user/index.ts b/web/client/api/user/index.ts similarity index 100% rename from web_new/client/api/user/index.ts rename to web/client/api/user/index.ts diff --git a/web_new/components/MenuModal/index.tsx b/web/components/MenuModal/index.tsx similarity index 100% rename from web_new/components/MenuModal/index.tsx rename to web/components/MenuModal/index.tsx diff --git a/web/components/agent/market-plugins.tsx b/web/components/agent/market-plugins.tsx index 832802c8a..0ad4c2f3b 100644 --- a/web/components/agent/market-plugins.tsx +++ b/web/components/agent/market-plugins.tsx @@ -6,6 +6,8 @@ import { useCallback, useMemo, useState } from 'react'; import MyEmpty from '../common/MyEmpty'; import { ClearOutlined, DownloadOutlined, GithubOutlined, LoadingOutlined, SearchOutlined, SyncOutlined } from '@ant-design/icons'; import { useTranslation } from 'react-i18next'; +import BlurredCard, { ChatButton, InnerDropdown } from '@/ant-components/common/blurredCard'; +import moment from 'moment'; function MarketPlugins() { const { t } = useTranslation(); @@ -96,6 +98,7 @@ function MarketPlugins() { }, [actionIndex, pluginAction], ); + console.log(agents); return ( @@ -114,8 +117,7 @@ function MarketPlugins() { {!agents.length && !loading && }
- {agents.map((agent, index) => ( -

{agent.description}

-
+ */} + {agents.map((agent, index) => ( + { + window.open(agent.storage_url, '_blank'); + }} + description={agent.description} + name={agent.name} + key={agent.id} + Tags={ +
+ {agent.author && {agent.author}} + {agent.version && v{agent.version}} + {agent.type && Type {agent.type}} + {agent.storage_channel && {agent.storage_channel}} +
+ } + LeftBottom={ +
+ {agent.author} + + {agent?.gmt_created && {moment(agent?.gmt_created).fromNow() + ' ' + t('update')}} +
+ } + RightBottom={ + agent.installed ? ( + } + text="Uninstall" + onClick={() => { + pluginAction(agent.name, index, false); + }} + /> + ) : ( + } + text="Install" + onClick={() => { + pluginAction(agent.name, index, true); + }} + /> + ) + } + /> ))}
diff --git a/web/components/app/agent-panel.tsx b/web/components/app/agent-panel.tsx index cb35e6102..2a550b9e1 100644 --- a/web/components/app/agent-panel.tsx +++ b/web/components/app/agent-panel.tsx @@ -40,7 +40,7 @@ export default function AgentPanel(props: IProps) { const getStrategy = async () => { const [_, data] = await apiInterceptors(getAppStrategy()); if (data) { - setStrategyOptions(data?.map((item) => ({ label: item, value: item }))); + setStrategyOptions(data?.map((item) => ({ label: item.name_cn, value: item.value }))); } }; diff --git a/web/components/app/app-card.tsx b/web/components/app/app-card.tsx index 098c3e2e7..2cec496ec 100644 --- a/web/components/app/app-card.tsx +++ b/web/components/app/app-card.tsx @@ -1,28 +1,30 @@ -import React, { useContext, useEffect, useState } from 'react'; -import { Modal } from 'antd'; -import { apiInterceptors, collectApp, delApp, newDialogue, unCollectApp } from '@/client/api'; +import { ChatContext } from '@/app/chat-context'; +import { apiInterceptors, collectApp, delApp, newDialogue, publishApp, unCollectApp, unPublishApp } from '@/client/api'; import { IApp } from '@/types/app'; import { DeleteFilled, MessageFilled, StarFilled, WarningOutlined } from '@ant-design/icons'; -import { useTranslation } from 'react-i18next'; +import { Modal, Popconfirm, Tooltip, message } from 'antd'; import { useRouter } from 'next/router'; -import { ChatContext } from '@/app/chat-context'; +import React, { useContext, useEffect, useMemo, useState } from 'react'; +import { useTranslation } from 'react-i18next'; + +import IconFont from '@/ant-components/common/Icon'; +import { useRequest } from 'ahooks'; import GPTCard from '../common/gpt-card'; interface IProps { - updateApps: (data?: { is_collected: boolean }) => void; + updateApps: (params?: Record) => void; app: IApp; handleEdit: (app: any) => void; - isCollected: boolean; + activeKey: string; } const { confirm } = Modal; export default function AppCard(props: IProps) { - const { updateApps, app, handleEdit, isCollected } = props; + const { updateApps, app, handleEdit, activeKey } = props; const { model } = useContext(ChatContext); const router = useRouter(); - const [isCollect, setIsCollect] = useState(app.is_collected); const { setAgent: setAgentToChat } = useContext(ChatContext); const { t } = useTranslation(); @@ -42,30 +44,135 @@ export default function AppCard(props: IProps) { cancelText: 'No', async onOk() { await apiInterceptors(delApp({ app_code: app.app_code })); - updateApps(isCollected ? { is_collected: isCollected } : undefined); + if (activeKey === 'collected') { + updateApps({ is_collected: 'true', ignore_user: 'true' }); + } else { + updateApps(); + } }, }); }; - useEffect(() => { - setIsCollect(app.is_collected); - }, [app]); - const collect = async () => { - const [error] = await apiInterceptors(isCollect === 'true' ? unCollectApp({ app_code: app.app_code }) : collectApp({ app_code: app.app_code })); + const [error] = await apiInterceptors( + app.is_collected === 'true' ? unCollectApp({ app_code: app.app_code }) : collectApp({ app_code: app.app_code }), + ); if (error) return; - updateApps(isCollected ? { is_collected: isCollected } : undefined); - setIsCollect(isCollect === 'true' ? 'false' : 'true'); + if (activeKey === 'collected') { + updateApps({ is_collected: 'true', ignore_user: 'true' }); + } else if (activeKey === 'common') { + updateApps({ ignore_user: 'true', published: 'true' }); + } else { + updateApps(); + } }; const handleChat = async () => { - setAgentToChat?.(app.app_code); const [, res] = await apiInterceptors(newDialogue({ chat_mode: 'chat_agent' })); if (res) { - router.push(`/chat/?scene=chat_agent&id=${res.conv_uid}${model ? `&model=${model}` : ''}`); + // 原生应用跳转 + if (app.team_mode === 'native_app') { + const { chat_scene = '' } = app.team_context; + router.push(`/chat?scene=${chat_scene}&id=${res.conv_uid}${model ? `&model=${model}` : ''}`); + } else { + setAgentToChat?.(app.app_code); + router.push(`/chat/?scene=chat_agent&id=${res.conv_uid}${model ? `&model=${model}` : ''}`); + } } }; + // 发布或取消发布应用 + const { run: operate } = useRequest( + async () => { + if (app.published === 'true') { + return await apiInterceptors(unPublishApp(app.app_code)); + } else { + return await apiInterceptors(publishApp(app.app_code)); + } + }, + { + manual: true, + onSuccess: (data) => { + if (data[2]?.success) { + if (app.published === 'true') { + message.success(t('cancel_success')); + } else { + message.success(t('published_success')); + } + } + updateApps?.(); + }, + }, + ); + + const publicContent = () => { + const { published = '' } = app; + const stopPropagationFn = (e: React.MouseEvent) => { + e.stopPropagation(); + }; + return ( + { + stopPropagationFn(e); + }} + onConfirm={async (e: any) => { + stopPropagationFn(e); + operate(); + }} + > + + {published == 'true' ? ( + + ) : ( + + )} + + + ); + }; + + const canDelete = useMemo(() => { + return activeKey === 'app'; + }, [activeKey]); + + const operations = useMemo(() => { + const defaultArr = [ + { + label: t('Chat'), + children: , + onClick: handleChat, + }, + { + label: t('collect'), + children: , + onClick: collect, + }, + ]; + if (canDelete) { + defaultArr.push({ + label: t('Delete'), + children: , + onClick: () => showDeleteConfirm() as any, + }); + } + return defaultArr; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [app, canDelete]); + return ( { + if (!canDelete) { + return; + } handleEdit(app); }} - operations={[ - { - label: t('Chat'), - children: , - onClick: handleChat, - }, - { - label: t('collect'), - children: , - onClick: collect, - }, - { - label: t('Delete'), - children: , - onClick: () => { - showDeleteConfirm(); - }, - }, - ]} + operations={operations} + extraContent={canDelete && publicContent()} /> ); } diff --git a/web/components/app/app-modal.tsx b/web/components/app/app-modal.tsx index 09c136639..870f14d46 100644 --- a/web/components/app/app-modal.tsx +++ b/web/components/app/app-modal.tsx @@ -1,4 +1,4 @@ -import { AgentParams, IAgent as IAgentParams, IApp, IDetail } from '@/types/app'; +import { AgentParams, IAgent as IAgentParams, CreateAppParams, IDetail } from '@/types/app'; import { Dropdown, Form, Input, Modal, Select, Space, Spin, Tabs } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -60,7 +60,7 @@ export default function AppModal(props: IProps) { setActiveKey(newActiveKey); }; - const createApp = async (app: IApp) => { + const createApp = async (app: CreateAppParams) => { await apiInterceptors(type === 'add' ? addApp(app) : updateApp(app)); await updateApps(); }; @@ -302,7 +302,7 @@ export default function AppModal(props: IProps) {
- label={t('app_name')} name="app_name" rules={[{ required: true, message: t('Please_input_the_name') }]}> + label={'App Name'} name="app_name" rules={[{ required: true, message: t('Please_input_the_name') }]}> @@ -353,7 +353,7 @@ export default function AppModal(props: IProps) {
{curTeamModal !== 'awel_layout' ? ( <> -
{t('Agents')}
+
Agents
) : ( diff --git a/web/components/app/resource-card.tsx b/web/components/app/resource-card.tsx index 39fa20406..5d47feb61 100644 --- a/web/components/app/resource-card.tsx +++ b/web/components/app/resource-card.tsx @@ -31,7 +31,7 @@ export default function ResourceCard(props: IProps) { if (data) { setResourceValueOptions( data?.map((item) => { - return { label: item, value: item }; + return { label: item.label, value: item.key + '' }; }), ); } else { diff --git a/web/components/chart/autoChart/advisor/pipeline.ts b/web/components/chart/autoChart/advisor/pipeline.ts index 9cf5eda9f..892a40f8a 100644 --- a/web/components/chart/autoChart/advisor/pipeline.ts +++ b/web/components/chart/autoChart/advisor/pipeline.ts @@ -73,10 +73,10 @@ export const getVisAdvices = (props: { data: Datum[]; myChartAdvisor: Advisor; d */ const customDataProps = dataMetaMap ? Object.keys(dataMetaMap).map((item) => { - return { name: item, ...dataMetaMap[item] }; - }) + return { name: item, ...dataMetaMap[item] }; + }) : null; - + // 可根据需要选择是否使用全部 fields 进行推荐 const useAllFields = false; // 挑选出维值不只有一个的字段 @@ -84,11 +84,11 @@ export const getVisAdvices = (props: { data: Datum[]; myChartAdvisor: Advisor; d const selectedFields = size(allFieldsInfo) > 2 ? allFieldsInfo?.filter((field) => { - if (field.recommendation === 'string' || field.recommendation === 'date') { - return field.distinct && field.distinct > 1; - } - return true; - }) + if (field.recommendation === 'string' || field.recommendation === 'date') { + return field.distinct && field.distinct > 1; + } + return true; + }) : allFieldsInfo; const allAdvices = myChartAdvisor?.adviseWithLog({ diff --git a/web/components/chart/autoChart/charts/multi-line-chart.ts b/web/components/chart/autoChart/charts/multi-line-chart.ts index 574a6dd72..192fea123 100644 --- a/web/components/chart/autoChart/charts/multi-line-chart.ts +++ b/web/components/chart/autoChart/charts/multi-line-chart.ts @@ -1,5 +1,5 @@ import { hasSubset } from '../advisor/utils'; -import { findOrdinalField, processDateEncode, findNominalField, getLineSize, sortData } from './util'; +import { processDateEncode, findOrdinalField, findNominalField, getLineSize, sortData } from './util'; import type { ChartKnowledge, CustomChart, GetChartConfigProps, Specification } from '../types'; import type { Datum } from '@antv/ava'; diff --git a/web/components/chart/autoChart/charts/multi-measure-line-chart.ts b/web/components/chart/autoChart/charts/multi-measure-line-chart.ts index f15c20772..28ee2c001 100644 --- a/web/components/chart/autoChart/charts/multi-measure-line-chart.ts +++ b/web/components/chart/autoChart/charts/multi-measure-line-chart.ts @@ -1,5 +1,5 @@ import { hasSubset } from '../advisor/utils'; -import { findNominalField, findOrdinalField, getLineSize, processDateEncode, sortData } from './util'; +import { processDateEncode, findNominalField, findOrdinalField, getLineSize, sortData } from './util'; import type { ChartKnowledge, CustomChart, GetChartConfigProps, Specification } from '../types'; import { Datum } from '@antv/ava'; diff --git a/web/components/chart/autoChart/charts/util.ts b/web/components/chart/autoChart/charts/util.ts index 850222333..94518c2f8 100644 --- a/web/components/chart/autoChart/charts/util.ts +++ b/web/components/chart/autoChart/charts/util.ts @@ -1,5 +1,5 @@ import type { Datum, FieldInfo } from "@antv/ava"; -import { hasSubset, intersects } from "../advisor/utils"; +import { hasSubset, intersects } from '../advisor/utils'; import { cloneDeep, uniq } from "lodash"; /** diff --git a/web/components/chart/autoChart/index.tsx b/web/components/chart/autoChart/index.tsx index cfab3df7c..35d84089d 100644 --- a/web/components/chart/autoChart/index.tsx +++ b/web/components/chart/autoChart/index.tsx @@ -3,7 +3,7 @@ import { Advice, Advisor, Datum } from '@antv/ava'; import { Chart, ChartRef } from '@berryv/g2-react'; import i18n, { I18nKeys } from '@/app/i18n'; import { customizeAdvisor, getVisAdvices } from './advisor/pipeline'; -import { useContext, useEffect, useMemo, useRef, useState } from 'react'; +import { useContext, useEffect, useMemo, useState, useRef } from 'react'; import { defaultAdvicesFilter } from './advisor/utils'; import { AutoChartProps, ChartType, CustomAdvisorConfig, CustomChart, Specification } from './types'; import { customCharts } from './charts'; @@ -16,8 +16,7 @@ import { DownloadOutlined } from '@ant-design/icons'; const { Option } = Select; export const AutoChart = (props: AutoChartProps) => { - const { chartType, scopeOfCharts, ruleConfig, data: originalData } = props; - + const { data: originalData, chartType, scopeOfCharts, ruleConfig } = props; // 处理空值数据 (为'-'的数据) const data = processNilData(originalData) as Datum[]; const { mode } = useContext(ChatContext); @@ -99,7 +98,7 @@ export const AutoChart = (props: AutoChartProps) => { // 处理 ava 内置折线图的排序问题 const dataAnalyzerOutput = advisor?.dataAnalyzer.execute({ data }) if (dataAnalyzerOutput && 'dataProps' in dataAnalyzerOutput) { - spec.data = sortData({ data: spec.data, xField: dataAnalyzerOutput.dataProps?.find(field => field.recommendation === 'date'), chartType: chartTypeInput }); + spec.data = sortData({ data: spec.data, xField: dataAnalyzerOutput.dataProps?.find((field: any) => field.recommendation === 'date'), chartType: chartTypeInput }); } } if (chartTypeInput === 'pie_chart' && spec?.encode?.color) { @@ -111,8 +110,8 @@ export const AutoChart = (props: AutoChartProps) => { key={chartTypeInput} options={{ ...spec, - theme: mode, autoFit: true, + theme: mode, height: 300, }} ref={chartRef} @@ -120,7 +119,7 @@ export const AutoChart = (props: AutoChartProps) => { ); } } - }, [advices, renderChartType]); + }, [advices, mode, renderChartType]); if (renderChartType) { return ( @@ -159,7 +158,7 @@ export const AutoChart = (props: AutoChartProps) => { -
{visComponent}
+
{visComponent}
); } diff --git a/web/components/chart/index.tsx b/web/components/chart/index.tsx index f64e3f957..36ad8ef81 100644 --- a/web/components/chart/index.tsx +++ b/web/components/chart/index.tsx @@ -10,6 +10,7 @@ type Props = { }; function Chart({ chartsData }: Props) { + console.log(chartsData,'xxx') const chartRows = useMemo(() => { if (chartsData) { let res = []; @@ -66,7 +67,7 @@ function Chart({ chartsData }: Props) { return ; } else if (chart.chart_type === 'BarChart' || chart.type === 'BarChart') { return ; - } else if (chart.chart_type === 'Table' || chart.type === 'Table') { + } else if (chart.chart_type === 'Table' || chart.type === 'TableChartData') { return ; } })} diff --git a/web/components/chat/agent-content.tsx b/web/components/chat/agent-content.tsx index e65b7fb0d..041d0e5ec 100644 --- a/web/components/chat/agent-content.tsx +++ b/web/components/chat/agent-content.tsx @@ -11,7 +11,7 @@ interface Props { } function formatMarkdownVal(val: string) { - return val.replace(/]+)>/gi, '').replace(/]+)>/gi, ''); + return val?.replace(/]+)>/gi, '
').replace(/]+)>/gi, ''); } function AgentContent({ content }: Props) { diff --git a/web/components/chat/chat-container.tsx b/web/components/chat/chat-container.tsx index 8fef5f823..477a1923e 100644 --- a/web/components/chat/chat-container.tsx +++ b/web/components/chat/chat-container.tsx @@ -16,7 +16,7 @@ import MyEmpty from '../common/MyEmpty'; const ChatContainer = () => { const searchParams = useSearchParams(); const { scene, chatId, model, agent, setModel, history, setHistory } = useContext(ChatContext); - const chat = useChat({}); + const { chat } = useChat({}); const initMessage = (searchParams && searchParams.get('initMessage')) ?? ''; const [loading, setLoading] = useState(false); @@ -34,9 +34,11 @@ const ChatContainer = () => { if (contextTemp) { try { const contextObj = typeof contextTemp === 'string' ? JSON.parse(contextTemp) : contextTemp; + console.log('contextObj', contextObj); setChartsData(contextObj?.template_name === 'report' ? contextObj?.charts : undefined); } catch (e) { - setChartsData(undefined); + console.log(e); + setChartsData([]); } } }; @@ -117,7 +119,9 @@ const ChatContainer = () => { )} - {!chartsData?.length && scene === 'chat_dashboard' && } + {!chartsData?.length && scene === 'chat_dashboard' && ( + + )} {/** chat panel */}
{data.map((item, index) => ( -
+
- {item.model ? renderModelIcon(item.model) :
} + {item.model ? :
}
{item.sender} {item.receiver}
-
- {item.markdown} +
+ + {item.markdown} +
+ {item.resource && item.resource !== 'null' && }
))} diff --git a/web/components/chat/chat-content/agent-plans.tsx b/web/components/chat/chat-content/agent-plans.tsx index d6fd451c9..73f9850bd 100644 --- a/web/components/chat/chat-content/agent-plans.tsx +++ b/web/components/chat/chat-content/agent-plans.tsx @@ -1,6 +1,9 @@ import { CaretRightOutlined, CheckOutlined, ClockCircleOutlined } from '@ant-design/icons'; import { Collapse } from 'antd'; import ReactMarkdown from 'react-markdown'; +import rehypeRaw from 'rehype-raw'; +import remarkGfm from 'remark-gfm'; + import markdownComponents from './config'; interface Props { @@ -25,7 +28,7 @@ function AgentPlans({ data }: Props) { return { key: index, label: ( -
+
{item.name} - {item.agent} @@ -36,7 +39,11 @@ function AgentPlans({ data }: Props) { )}
), - children: {item.markdown}, + children: ( + + {item.markdown} + + ), }; })} /> diff --git a/web/components/chat/chat-content/chart-view.tsx b/web/components/chat/chat-content/chart-view.tsx index 9c6aedd20..40a9a1d5e 100644 --- a/web/components/chat/chat-content/chart-view.tsx +++ b/web/components/chat/chat-content/chart-view.tsx @@ -20,11 +20,10 @@ function ChartView({ data, type, sql }: { data: Datum[]; type: BackEndChartType; label: 'Chart', children: , }; - const SqlItem = { key: 'sql', label: 'SQL', - children: , + children: , }; const DataItem = { key: 'data', diff --git a/web/components/chat/chat-content/code-preview.tsx b/web/components/chat/chat-content/code-preview.tsx index ad0ffb737..d94572b24 100644 --- a/web/components/chat/chat-content/code-preview.tsx +++ b/web/components/chat/chat-content/code-preview.tsx @@ -25,7 +25,7 @@ export function CodePreview({ code, light, dark, language, customStyle }: Props) icon={} onClick={() => { const success = copy(code); - message[success ? 'success' : 'error'](success ? 'Copy success' : 'Copy failed'); + message[success ? 'success' : 'error'](success ? '复制成功' : '复制失败'); }} /> diff --git a/web/components/chat/chat-content/config.tsx b/web/components/chat/chat-content/config.tsx index eebc6ea57..43898c0ff 100644 --- a/web/components/chat/chat-content/config.tsx +++ b/web/components/chat/chat-content/config.tsx @@ -1,19 +1,23 @@ -import { LinkOutlined, ReadOutlined, SyncOutlined } from '@ant-design/icons'; -import ReactMarkdown from 'react-markdown'; -import { Table, Image, Tag, Tabs, TabsProps, Popover } from 'antd'; -import { Reference } from '@/types/chat'; import { AutoChart, BackEndChartType, getChartType } from '@/components/chart'; -import { CodePreview } from './code-preview'; +import { LinkOutlined, ReadOutlined, SyncOutlined } from '@ant-design/icons'; import { Datum } from '@antv/ava'; +import { Image, Table, Tabs, TabsProps, Tag } from 'antd'; +import ReactMarkdown from 'react-markdown'; import rehypeRaw from 'rehype-raw'; -import { IChunk } from '@/types/knowledge'; -import AgentPlans from './agent-plans'; +import remarkGfm from 'remark-gfm'; + import AgentMessages from './agent-messages'; -import VisConvertError from './vis-convert-error'; +import AgentPlans from './agent-plans'; +import { CodePreview } from './code-preview'; +import ReferencesContent from './ReferencesContent'; import VisChart from './vis-chart'; +import VisCode from './vis-code'; +import VisConvertError from './vis-convert-error'; import VisDashboard from './vis-dashboard'; import VisPlugin from './vis-plugin'; -import VisCode from './vis-code'; +import VisAppLink from './VisAppLink'; +import VisChatLink from './VisChatLink'; +import VisResponse from './VisResponse'; import { formatSql } from '@/utils'; type MarkdownComponent = Parameters['0']['components']; @@ -106,6 +110,22 @@ const basicComponents: MarkdownComponent = { } } + if (lang === 'vis-app-link') { + try { + const data = JSON.parse(content) as Parameters[0]['data']; + return ; + } catch (e) { + return ; + } + } + if (lang === 'vis-api-response') { + try { + const data = JSON.parse(content) as Parameters[0]['data']; + return ; + } catch (e) { + return ; + } + } return ( <> {!inline ? ( @@ -115,7 +135,7 @@ const basicComponents: MarkdownComponent = { {children} )} - + {matchValues.join('\n')} @@ -131,9 +151,7 @@ const basicComponents: MarkdownComponent = { return
  • {children}
  • ; }, table({ children }) { - return ( -
    {children}
    - ); + return {children}
    ; }, thead({ children }) { return {children}; @@ -178,7 +196,7 @@ const basicComponents: MarkdownComponent = { Image Loading... } - fallback="/images/fallback.png" + fallback="/pictures/fallback.png" /> ); @@ -190,6 +208,43 @@ const basicComponents: MarkdownComponent = { ); }, + button({ children, className, ...restProps }) { + if (className === 'chat-link') { + const msg = (restProps as any)?.['data-msg']; + return {children}; + } + return ( + + ); + }, +}; + +const returnSqlVal = (val: string) => { + const punctuationMap: any = { + ',': ',', + '。': '.', + '?': '?', + '!': '!', + ':': ':', + ';': ';', + '“': '"', + '”': '"', + '‘': "'", + '’': "'", + '(': '(', + ')': ')', + '【': '[', + '】': ']', + '《': '<', + '》': '>', + '—': '-', + '、': ',', + '…': '...', + }; + const regex = new RegExp(Object.keys(punctuationMap).join('|'), 'g'); + return val.replace(regex, (match) => punctuationMap[match]); }; const extraComponents: MarkdownComponent = { @@ -228,12 +283,12 @@ const extraComponents: MarkdownComponent = { const SqlItem = { key: 'sql', label: 'SQL', - children: , + children: , }; const DataItem = { key: 'data', label: 'Data', - children: , + children:
    , }; const TabItems: TabsProps['items'] = data?.type === 'response_table' ? [DataItem, SqlItem] : [ChartItem, SqlItem, DataItem]; @@ -245,71 +300,15 @@ const extraComponents: MarkdownComponent = { ); }, references: function ({ title, references, children }) { - let referenceData; - // Low version compatibility, read data from children if (children) { try { - referenceData = JSON.parse(children as string); - title = referenceData.title; - references = referenceData.references; + const referenceData = JSON.parse(children as string); + const references = referenceData.references; + return ; } catch (error) { - console.log('parse references failed', error); - return

    Render Reference Error!

    ; - } - } else { - // new version, read from tag props. - try { - references = JSON.parse(references as string); - } catch (error) { - console.log('parse references failed', error); - return

    Render Reference Error!

    ; + return null; } } - if (!references || references?.length < 1) { - return null; - } - return ( -
    -

    - - {title} -

    - {references.map((reference: Reference, index: number) => ( -
    - [{index + 1}] - {reference.name} - {reference?.chunks?.map((chunk: IChunk | number, index) => ( - - {typeof chunk === 'object' ? ( - -

    Content:

    -

    {chunk?.content || 'No Content'}

    -

    MetaData:

    -

    {chunk?.meta_info || 'No MetaData'}

    -

    Score:

    -

    {chunk?.recall_score || ''}

    -
    - } - title="Chunk Information" - > - - {chunk?.id} - - - ) : ( - - {chunk} - - )} - {index < reference?.chunks.length - 1 && ,} - - ))} -
    - ))} - - ); }, summary: function ({ children }) { return ( diff --git a/web/components/chat/chat-content/vis-chart.tsx b/web/components/chat/chat-content/vis-chart.tsx index 61b961248..1c5cb8070 100644 --- a/web/components/chat/chat-content/vis-chart.tsx +++ b/web/components/chat/chat-content/vis-chart.tsx @@ -13,7 +13,10 @@ interface Props { } function VisChart({ data }: Props) { - return ; + if (!data) { + return null; + } + return ; } export default VisChart; diff --git a/web/components/chat/chat-content/vis-plugin.tsx b/web/components/chat/chat-content/vis-plugin.tsx index df20d5849..17d34c166 100644 --- a/web/components/chat/chat-content/vis-plugin.tsx +++ b/web/components/chat/chat-content/vis-plugin.tsx @@ -2,8 +2,10 @@ import { CheckOutlined, ClockCircleOutlined, CloseOutlined, LoadingOutlined } fr import classNames from 'classnames'; import { ReactNode } from 'react'; import ReactMarkdown from 'react-markdown'; -import markdownComponents from './config'; import rehypeRaw from 'rehype-raw'; +import remarkGfm from 'remark-gfm'; + +import markdownComponents from './config'; interface IVisPlugin { name: string; @@ -42,15 +44,16 @@ const pluginViewStatusMapper: Record +
    {data.name} {icon}
    {data.result ? (
    - + {data.result ?? ''}
    diff --git a/web_new/components/chat/chat-default/index.tsx b/web/components/chat/chat-default/index.tsx similarity index 100% rename from web_new/components/chat/chat-default/index.tsx rename to web/components/chat/chat-default/index.tsx diff --git a/web/components/chat/completion.tsx b/web/components/chat/completion.tsx index ce72a3c8a..915625536 100644 --- a/web/components/chat/completion.tsx +++ b/web/components/chat/completion.tsx @@ -1,25 +1,25 @@ -import { useState, useRef, useEffect, useMemo, useContext } from 'react'; -import { useSearchParams } from 'next/navigation'; -import MonacoEditor from './monaco-editor'; -import ChatContent from './chat-content'; -import ChatFeedback from './chat-feedback'; import { ChatContext } from '@/app/chat-context'; -import { FeedBack, IChatDialogueMessageSchema } from '@/types/chat'; -import classNames from 'classnames'; -import { Modal, message, Tooltip } from 'antd'; -import { renderModelIcon } from './header/model-selector'; -import { cloneDeep } from 'lodash'; -import copy from 'copy-to-clipboard'; -import { useTranslation } from 'react-i18next'; -import CompletionInput from '../common/completion-input'; -import { useAsyncEffect } from 'ahooks'; -import { STORAGE_INIT_MESSAGE_KET } from '@/utils'; -import { Button, IconButton } from '@mui/joy'; -import { CopyOutlined, RedoOutlined } from '@ant-design/icons'; -import { getInitMessage } from '@/utils'; import { apiInterceptors, getChatFeedBackSelect } from '@/client/api'; import useSummary from '@/hooks/use-summary'; +import { FeedBack, IChatDialogueMessageSchema } from '@/types/chat'; +import { STORAGE_INIT_MESSAGE_KET, getInitMessage } from '@/utils'; +import { CopyOutlined, RedoOutlined } from '@ant-design/icons'; +import { Button, IconButton } from '@mui/joy'; +import { useAsyncEffect } from 'ahooks'; +import { Modal, Tooltip, message } from 'antd'; +import classNames from 'classnames'; +import copy from 'copy-to-clipboard'; +import { cloneDeep } from 'lodash'; +import { useSearchParams } from 'next/navigation'; +import { useContext, useEffect, useMemo, useRef, useState } from 'react'; +import { useTranslation } from 'react-i18next'; + +import CompletionInput from '../common/completion-input'; import AgentContent from './agent-content'; +import ChatContent from './chat-content'; +import ChatFeedback from './chat-feedback'; +import { renderModelIcon } from './header/model-selector'; +import MonacoEditor from './monaco-editor'; import MyEmpty from '../common/MyEmpty'; type Props = { @@ -93,12 +93,12 @@ const Completion = ({ messages, onSubmit }: Props) => { const result = copy(pureStr); if (result) { if (pureStr) { - messageApi.open({ type: 'success', content: t('Copy_success') }); + messageApi.open({ type: 'success', content: t('copy_success') }); } else { - messageApi.open({ type: 'warning', content: t('Copy_nothing') }); + messageApi.open({ type: 'warning', content: t('copy_nothing') }); } } else { - messageApi.open({ type: 'error', content: t('Copry_error') }); + messageApi.open({ type: 'error', content: t('copy_failed') }); } }; @@ -184,7 +184,7 @@ const Completion = ({ messages, onSubmit }: Props) => { question={showMessages?.filter((e) => e?.role === 'human' && e?.order === content.order)[0]?.context} knowledge_space={spaceNameOriginal || dbParam || ''} /> - + {!!fileList.length && ( -
    +
    setFileList([])}> {fileList[0]?.name}
    diff --git a/web/components/chat/header/model-selector.tsx b/web/components/chat/header/model-selector.tsx index 493a585e1..87ba3f2a8 100644 --- a/web/components/chat/header/model-selector.tsx +++ b/web/components/chat/header/model-selector.tsx @@ -3,8 +3,8 @@ */ import { ChatContext } from '@/app/chat-context'; -import { Select } from 'antd'; import { MODEL_ICON_MAP } from '@/utils/constants'; +import { Select } from 'antd'; import Image from 'next/image'; import { useContext } from 'react'; import { useTranslation } from 'react-i18next'; @@ -26,6 +26,7 @@ export function renderModelIcon(model?: string, props?: { width: number; height: width={width || 24} height={height || 24} src={MODEL_ICON_MAP[model]?.icon || DEFAULT_ICON_URL} + key={MODEL_ICON_MAP[model]?.icon || DEFAULT_ICON_URL} alt="llm" /> ); diff --git a/web/components/chat/monaco-editor.tsx b/web/components/chat/monaco-editor.tsx index 1263d2eb2..310a63248 100644 --- a/web/components/chat/monaco-editor.tsx +++ b/web/components/chat/monaco-editor.tsx @@ -2,10 +2,10 @@ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js'; import Editor, { OnChange, loader } from '@monaco-editor/react'; import classNames from 'classnames'; import { useContext, useMemo } from 'react'; +import { ChatContext } from '@/app/chat-context'; import { formatSql } from '@/utils'; import { getModelService } from './ob-editor/service'; import { useLatest } from 'ahooks'; -import { ChatContext } from '@/app/chat-context'; import { github, githubDark } from './ob-editor/theme'; import { register } from './ob-editor/ob-plugin'; @@ -24,7 +24,6 @@ interface MonacoEditorProps { onChange?: OnChange; thoughts?: string; session?: ISession; - } let plugin = null; @@ -33,6 +32,7 @@ monaco.editor.defineTheme('githubDark', githubDark as any); export default function MonacoEditor({ className, value, language = 'mysql', onChange, thoughts, session }: MonacoEditorProps) { // merge value and thoughts + const editorValue = useMemo(() => { if (language !== 'mysql') { return value; @@ -58,7 +58,6 @@ export default function MonacoEditor({ className, value, language = 'mysql', onC ) } - return ( ([]); diff --git a/web/components/common/completion-input.tsx b/web/components/common/completion-input.tsx index 23bdcbc78..acbccff2a 100644 --- a/web/components/common/completion-input.tsx +++ b/web/components/common/completion-input.tsx @@ -1,22 +1,23 @@ +import { ChatContext } from '@/app/chat-context'; +import { apiInterceptors, getDocumentList } from '@/client/api'; +import { IDocument } from '@/types/knowledge'; import { SendOutlined } from '@ant-design/icons'; import { Button, Input } from 'antd'; import { PropsWithChildren, useContext, useEffect, useMemo, useRef, useState } from 'react'; -import PromptBot from './prompt-bot'; -import DocUpload from '../chat/doc-upload'; import DocList from '../chat/doc-list'; -import { IDocument } from '@/types/knowledge'; -import { ChatContext } from '@/app/chat-context'; -import { apiInterceptors, getDocumentList } from '@/client/api'; +import DocUpload from '../chat/doc-upload'; +import PromptBot from './prompt-bot'; type TextAreaProps = Omit[0], 'value' | 'onPressEnter' | 'onChange' | 'onSubmit'>; interface Props { - loading?: boolean; onSubmit: (val: string) => void; handleFinish?: (val: boolean) => void; + loading?: boolean; + placeholder?: string; } -function CompletionInput({ children, loading, onSubmit, handleFinish, ...props }: PropsWithChildren) { +function CompletionInput({ children, loading, onSubmit, handleFinish, placeholder, ...props }: PropsWithChildren) { const { dbParam, scene } = useContext(ChatContext); const [userInput, setUserInput] = useState(''); @@ -77,6 +78,7 @@ function CompletionInput({ children, loading, onSubmit, handleFinish, ...props } } setUserInput(e.target.value); }} + placeholder={placeholder} />
    ); } diff --git a/web/components/database/form-dialog.tsx b/web/components/database/form-dialog.tsx index 1b9e30907..c2df7622c 100644 --- a/web/components/database/form-dialog.tsx +++ b/web/components/database/form-dialog.tsx @@ -1,12 +1,13 @@ /* eslint-disable react-hooks/exhaustive-deps */ -import { Button, Form, Input, InputNumber, Modal, Select, message } from 'antd'; +import { Button, Form, Input, InputNumber, Modal, Select, Spin, Tooltip, message } from 'antd'; import { useEffect, useMemo, useState } from 'react'; -import { apiInterceptors, postDbAdd, postDbEdit, postDbTestConnect } from '@/client/api'; +import { addOmcDB, apiInterceptors, getSupportDBList, postDbAdd, postDbEdit, postDbTestConnect } from '@/client/api'; import { DBOption, DBType, DbListResponse, PostDbParams } from '@/types/db'; import { isFileDb } from '@/pages/database'; import { useTranslation } from 'react-i18next'; +import { useDebounceFn } from 'ahooks'; -type DBItem = DbListResponse[0]; +type DBItem = DbListResponse[0] & { db_arn?: string }; interface Props { dbTypeList: DBOption[]; @@ -23,7 +24,8 @@ function FormDialog({ open, choiceDBType, dbTypeList, editValue, dbNames, onClos const { t } = useTranslation(); const [form] = Form.useForm(); const dbType = Form.useWatch('db_type', form); - + const [omcDBList, setOmcDBList] = useState([]); + const [omcListLoading, setOmcListLoading] = useState(false); const fileDb = useMemo(() => isFileDb(dbTypeList, dbType), [dbTypeList, dbType]); useEffect(() => { @@ -35,6 +37,9 @@ function FormDialog({ open, choiceDBType, dbTypeList, editValue, dbNames, onClos useEffect(() => { if (editValue) { form.setFieldsValue({ ...editValue }); + if (editValue.db_type === 'omc') { + form.setFieldValue('db_arn', editValue.db_path); + } } }, [editValue]); @@ -45,7 +50,33 @@ function FormDialog({ open, choiceDBType, dbTypeList, editValue, dbNames, onClos }, [open]); const onFinish = async (val: DBItem) => { - const { db_host, db_path, db_port, ...params } = val; + const { db_host, db_path, db_port, db_type, ...params } = val; + setLoading(true); + + if (db_type === 'omc') { + const item = omcDBList?.find((item: any) => item.arn === val.db_name) as any; + + try { + const [err] = await apiInterceptors( + addOmcDB({ + db_type: 'omc', + file_path: val.db_arn || '', + comment: val.comment, + db_name: item?.dbName || val.db_name, + }), + ); + if (err) { + message.error(err.message); + return; + } + message.success('success'); + onSuccess?.(); + } catch (e: any) { + message.error(e.message); + } finally { + setLoading(false); + } + } if (!editValue && dbNames.some((item) => item === params.db_name)) { message.error('The database already exists!'); return; @@ -53,10 +84,10 @@ function FormDialog({ open, choiceDBType, dbTypeList, editValue, dbNames, onClos const data: PostDbParams = { db_host: fileDb ? undefined : db_host, db_port: fileDb ? undefined : db_port, + db_type: db_type, file_path: fileDb ? db_path : undefined, ...params, }; - setLoading(true); try { const [testErr] = await apiInterceptors(postDbTestConnect(data)); if (testErr) return; @@ -73,24 +104,78 @@ function FormDialog({ open, choiceDBType, dbTypeList, editValue, dbNames, onClos setLoading(false); } }; + console.log(form.getFieldValue('db_type')); + const { run: fetchOmcList } = useDebounceFn( + async (name: string) => { + setOmcListLoading(true); + const [error, data = []] = (await apiInterceptors(getSupportDBList(name))) as any; + setOmcListLoading(false); + + setOmcDBList(data.map((item: any) => ({ ...item, label: item.dbName, value: item.arn }))); + }, + { + wait: 500, + }, + ); + console.log('omcDBList', omcDBList); const lockDBType = useMemo(() => !!editValue || !!choiceDBType, [editValue, choiceDBType]); - return (
    - + {form.getFieldValue('db_type') === 'omc' ? ( + + + + )} {fileDb === true && ( )} - {fileDb === false && ( + {fileDb === false && form.getFieldValue('db_type') !== 'omc' && ( <> @@ -106,7 +191,11 @@ function FormDialog({ open, choiceDBType, dbTypeList, editValue, dbNames, onClos )} - + {form.getFieldValue('db_type') === 'omc' && ( + + + + )} diff --git a/web/components/flow/flow-card.tsx b/web/components/flow/flow-card.tsx index 63e5ee43a..450b9c9e9 100644 --- a/web/components/flow/flow-card.tsx +++ b/web/components/flow/flow-card.tsx @@ -25,6 +25,8 @@ interface FlowCardProps { } const FlowCard: React.FC = ({ flow, onCopy, deleteCallback }) => { + console.log(flow, 'flow'); + const { model } = useContext(ChatContext); const { t } = useTranslation(); const [modal, contextHolder] = Modal.useModal(); @@ -76,8 +78,8 @@ const FlowCard: React.FC = ({ flow, onCopy, deleteCallback }) => title={flow.name} desc={flow.description} tags={[ - { text: flow.source, color: flow.source === 'DBGPT-WEB' ? 'green' : 'blue', border: true }, - { text: flow.editable ? 'Editable' : 'Can not Edit', color: flow.editable ? 'green' : 'gray', border: true }, + { text: flow.source, border: true, color: flow.source === 'DBGPT-WEB' ? 'green' : 'blue' }, + { text: flow.editable ? 'Editable' : 'Can not Edit', color: flow.editable ? 'green' : 'gray' }, { text: ( <> @@ -120,7 +122,7 @@ const FlowCard: React.FC = ({ flow, onCopy, deleteCallback }) => }, ]} > -
    +
    diff --git a/web/components/icons/split-screen-height.tsx b/web/components/icons/split-screen-height.tsx index b0f41b01c..a2ab9c835 100644 --- a/web/components/icons/split-screen-height.tsx +++ b/web/components/icons/split-screen-height.tsx @@ -1,12 +1,13 @@ function SplitScreenHeight() { - return ( - - - - ); + return ( + + + + ); } export default SplitScreenHeight; + \ No newline at end of file diff --git a/web/components/icons/split-screen-width.tsx b/web/components/icons/split-screen-width.tsx index 36fb5bbd2..d974cb0ec 100644 --- a/web/components/icons/split-screen-width.tsx +++ b/web/components/icons/split-screen-width.tsx @@ -10,3 +10,4 @@ function SplitScreenWeight() { } export default SplitScreenWeight; + \ No newline at end of file diff --git a/web_new/components/knowledge/RecallTestModal.tsx b/web/components/knowledge/RecallTestModal.tsx similarity index 100% rename from web_new/components/knowledge/RecallTestModal.tsx rename to web/components/knowledge/RecallTestModal.tsx diff --git a/web/components/knowledge/arguments-modal.tsx b/web/components/knowledge/arguments-modal.tsx index 5b2f0edda..f221020e4 100644 --- a/web/components/knowledge/arguments-modal.tsx +++ b/web/components/knowledge/arguments-modal.tsx @@ -43,7 +43,7 @@ export default function ArgumentsModal({ space, argumentsShow, setArgumentsShow label={t('recall_score')} name={['embedding', 'recall_score']} > - +
    diff --git a/web/components/knowledge/doc-icon.tsx b/web/components/knowledge/doc-icon.tsx index ad90f0186..6b0fd21c3 100644 --- a/web/components/knowledge/doc-icon.tsx +++ b/web/components/knowledge/doc-icon.tsx @@ -1,10 +1,12 @@ -import { FileTextFilled, FileWordTwoTone, IeCircleFilled } from '@ant-design/icons'; +import { FileTextFilled, FileWordTwoTone, IeCircleFilled, YuqueFilled } from '@ant-design/icons'; export default function DocIcon({ type }: { type: string }) { if (type === 'TEXT') { return ; } else if (type === 'DOCUMENT') { return ; + } else if (type === 'YUQUEURL') { + return ; } else { return ; } diff --git a/web/components/knowledge/doc-panel.tsx b/web/components/knowledge/doc-panel.tsx index d3bcdd133..e26529553 100644 --- a/web/components/knowledge/doc-panel.tsx +++ b/web/components/knowledge/doc-panel.tsx @@ -1,37 +1,101 @@ -import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { Button, Card, Space, Divider, Empty, Spin, Tag, Tooltip, Modal } from 'antd'; -import { DeleteFilled, InteractionFilled, PlusOutlined, ToolFilled, EyeFilled, WarningOutlined, DeploymentUnitOutlined} from '@ant-design/icons'; -import { apiInterceptors, delDocument, getDocumentList, syncDocument } from '@/client/api'; +import { + apiInterceptors, + delDocument, + editChunk, + getDocumentList, + // getKnowledgeAdmins, + searchDocumentList, + syncDocument, + updateKnowledgeAdmins, +} from '@/client/api'; import { IDocument, ISpace } from '@/types/knowledge'; +import { + DeleteOutlined, + EditOutlined, + EllipsisOutlined, + ExperimentOutlined, + EyeOutlined, + LoadingOutlined, + MinusCircleOutlined, + PlusOutlined, + SearchOutlined, + SyncOutlined, + ToolFilled, + WarningOutlined, + DeploymentUnitOutlined, +} from '@ant-design/icons'; +import { useRequest } from 'ahooks'; +import { Button, Card, Divider, Dropdown, Empty, Form, Input, Modal, Select, Space, Spin, Tag, Tooltip, message, notification } from 'antd'; +import cls from 'classnames'; import moment from 'moment'; -import ArgumentsModal from './arguments-modal'; -import { useTranslation } from 'react-i18next'; import { useRouter } from 'next/router'; +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import ArgumentsModal from './arguments-modal'; import DocIcon from './doc-icon'; +import RecallTestModal from './RecallTestModal'; interface IProps { space: ISpace; + addStatus?: string; onAddDoc: (spaceName: string) => void; onDeleteDoc: () => void; } const { confirm } = Modal; +const SyncContent: React.FC<{ name: string; id: number }> = ({ name, id }) => { + const [syncLoading, setSyncLoading] = useState(false); + const { t } = useTranslation(); + + const handleSync = async (spaceName: string, id: number) => { + setSyncLoading(true); + const res = await apiInterceptors(syncDocument(spaceName, { doc_ids: [id] })); + setSyncLoading(false); + if (res[2]?.success) { + message.success(t('Synchronization_initiated')); + } + }; + + if (syncLoading) { + return } />; + } + return ( + { + handleSync(name, id); + }} + > + + {t('Sync')} + + ); +}; + export default function DocPanel(props: IProps) { - const { space } = props; + const [form] = Form.useForm(); + const { space, addStatus } = props; const { t } = useTranslation(); const router = useRouter(); const page_size = 18; - const [isLoading, setIsLoading] = useState(false); + const [admins, setAdmins] = useState([]); const [documents, setDocuments] = useState([]); + const [searchDocuments, setSearchDocuments] = useState([]); const [argumentsShow, setArgumentsShow] = useState(false); const [total, setTotal] = useState(0); + + const [editOpen, setEditOpen] = useState(false); + const [curDoc, setCurDoc] = useState(); + + // 召回测试弹窗 + const [recallTestOpen, setRecallTestOpen] = useState(false); + const currentPageRef = useRef(1); const hasMore = useMemo(() => { - return documents.length < total; - }, [documents.length, total]); + return documents?.length < total; + }, [documents, total]); const showDeleteConfirm = (row: any) => { confirm({ @@ -47,24 +111,33 @@ export default function DocPanel(props: IProps) { }); }; - async function fetchDocuments() { - setIsLoading(true); - const [_, data] = await apiInterceptors( - getDocumentList(space.name, { - page: currentPageRef.current, - page_size, - }), - ); - setDocuments(data?.data); - setTotal(data?.total || 0); - setIsLoading(false); - } + const { + run: fetchDocuments, + refresh, + loading: isLoading, + } = useRequest( + async () => + await apiInterceptors( + getDocumentList(space.name, { + page: currentPageRef.current, + page_size, + }), + ), + { + manual: true, + onSuccess: (res) => { + const [, data] = res; + setDocuments(data?.data); + setSearchDocuments(data?.data); + setTotal(data?.total || 0); + }, + }, + ); const loadMoreDocuments = async () => { if (!hasMore) { return; } - setIsLoading(true); currentPageRef.current += 1; const [_, data] = await apiInterceptors( getDocumentList(space.name, { @@ -73,11 +146,7 @@ export default function DocPanel(props: IProps) { }), ); setDocuments([...documents, ...data!.data]); - setIsLoading(false); - }; - - const handleSync = async (spaceName: string, id: number) => { - await apiInterceptors(syncDocument(spaceName, { doc_ids: [id] })); + setSearchDocuments([...documents, ...data!.data]); }; const handleDelete = async (row: any) => { @@ -93,10 +162,10 @@ export default function DocPanel(props: IProps) { const handleArguments = () => { setArgumentsShow(true); }; - const openGraphVisualPage = () => { router.push(`/knowledge/graph/?spaceName=${space.name}`); } + const renderResultTag = (status: string, result: string) => { let color; switch (status) { @@ -122,90 +191,258 @@ export default function DocPanel(props: IProps) { ); }; + // const getAdmins = useCallback(async () => { + // const [err, data] = await apiInterceptors(getKnowledgeAdmins(space.id as string)); + + // if (!data || !data.length) return; + // setAdmins(data as string[]); + // }, [space.id]); useEffect(() => { fetchDocuments(); - }, [space]); + // getAdmins(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + useEffect(() => { + if (addStatus === 'finish') { + fetchDocuments(); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [addStatus]); + + const updateAdmins = useCallback( + async (options: string[]) => { + const { data } = await updateKnowledgeAdmins({ + space_id: space.id as string, + user_nos: options as any, + }); + if (!data.success) { + // getAdmins(); + notification.error({ description: data.err_msg, message: 'Update Error' }); + } else { + message.success(t('Edit_Success')); + } + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [space.id], + ); + const handleChange = (value: string[]) => { + updateAdmins(value); + setAdmins(value); + }; + + const { run: search, loading: searchLoading } = useRequest( + async (id, doc_name: string) => { + const [, res] = await apiInterceptors(searchDocumentList(space.name, { doc_name })); + return res; + }, + { + manual: true, + debounceWait: 500, + onSuccess: (data) => { + console.log(data); + setSearchDocuments(data?.data); + }, + }, + ); + + const { run: editChunkRun, loading: chunkLoading } = useRequest( + async (values: any) => { + return await editChunk(props.space.name, { + questions: values.questions?.map((item: any) => item.question), + doc_id: curDoc?.id || '', + doc_name: values.doc_name, + }); + }, + { + manual: true, + onSuccess: async (res) => { + if (res.data.success) { + message.success(t('Edit_Success')); + await fetchDocuments(); + setEditOpen(false); + } else { + message.error(res.data.err_msg); + } + }, + }, + ); const renderDocumentCard = () => { - if (documents?.length > 0) { - return ( -
    -
    - {documents.map((document: IDocument) => { - return ( - -
    - - {document.doc_name} -
    - - } - extra={ -
    - - { - router.push(`/knowledge/chunk/?spaceName=${space.name}&id=${document.id}`); - }} - /> - - - { - handleSync(space.name, document.id); - }} - /> - - - { - showDeleteConfirm(document); - }} - /> - -
    - } - > -

    {t('Size')}:

    -

    {document.chunk_size} chunks

    -

    {t('Last_Sync')}:

    -

    {moment(document.last_sync).format('YYYY-MM-DD HH:MM:SS')}

    -

    {renderResultTag(document.status, document.result)}

    -
    - ); - })} + return ( +
    +
    + {/*
    管理员(工号,去前缀0):
    */} +
    + {/* } + placeholder={t('please_enter_the_keywords')} + onChange={async (e) => { + await search(space.id, e.target.value); + }} + allowClear + /> + +
    + + <> + {searchDocuments.length > 0 ? ( +
    + {searchDocuments.map((document: IDocument) => { + return ( + +
    + + {document.doc_name} +
    + + } + extra={ + { + router.push(`/construct/knowledge/chunk/?spaceName=${space.name}&id=${document.id}`); + }} + > + + {t('detail')} + + ), + }, + { + key: `${t('Sync')}`, + label: , + }, + { + key: 'edit', + label: ( + { + setEditOpen(true); + setCurDoc(document); + }} + > + + {t('Edit')} + + ), + }, + { + key: 'del', + label: ( + { + showDeleteConfirm(document); + }} + > + + {t('Delete')} + + ), + }, + ], + }} + getPopupContainer={(node) => node.parentNode as HTMLElement} + placement="bottomRight" + autoAdjustOverflow={false} + className="bg-gray-100 rounded-md" + > + + + } + > +

    {t('Size')}:

    +

    {document.chunk_size} chunks

    +

    {t('Last_Sync')}:

    +

    {moment(document.last_sync).format('YYYY-MM-DD HH:MM:SS')}

    +

    {renderResultTag(document.status, document.result)}

    +
    + ); + })} +
    + ) : ( + + )} + + {hasMore && ( + + + {t('Load_more')} + + + )} +
    + + ) : ( + + + )}
    - ); - } - return ( - - - +
    ); }; + useEffect(() => { + if (!curDoc) { + return; + } + form.setFieldsValue({ + doc_name: curDoc.doc_name, + questions: curDoc.questions?.map((ques) => { + return { + question: ques, + }; + }), + }); + }, [curDoc, form]); + return ( -
    +
    ) } + {renderDocumentCard()} + {/* 编辑弹窗 */} + setEditOpen(false)} + destroyOnClose={true} + footer={[ + , + , + ]} + > + { + return { + question: ques, + }; + }), + }} + > + + + + + + {(fields, { add, remove }) => ( + <> + {fields.map(({ key, name }, index) => ( +
    + + + + + { + remove(name); + }} + /> + +
    + ))} + + + + + )} +
    +
    + +
    + {/* 召回测试弹窗 */} +
    ); } diff --git a/web/components/knowledge/doc-type-form.tsx b/web/components/knowledge/doc-type-form.tsx index 5eff13873..7f22471a6 100644 --- a/web/components/knowledge/doc-type-form.tsx +++ b/web/components/knowledge/doc-type-form.tsx @@ -29,6 +29,12 @@ export default function DocTypeForm(props: IProps) { subTitle: t('Upload_a_document'), iconType: 'DOCUMENT', }, + { + type: 'YUQUEURL', + title: t('yuque'), + subTitle: t('Get_yuque_document'), + iconType: 'YUQUEURL', + }, ]; return ( diff --git a/web/components/knowledge/doc-upload-form.tsx b/web/components/knowledge/doc-upload-form.tsx index 81ec91978..269d2efb2 100644 --- a/web/components/knowledge/doc-upload-form.tsx +++ b/web/components/knowledge/doc-upload-form.tsx @@ -1,12 +1,12 @@ -import { Button, Form, Input, Upload, Spin, message } from 'antd'; -import React, { useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { InboxOutlined } from '@ant-design/icons'; -import { apiInterceptors, addDocument, uploadDocument } from '@/client/api'; +import { addDocument, apiInterceptors, uploadDocument, addYuque } from '@/client/api'; +import { StepChangeParams } from '@/types/knowledge'; +import { InboxOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { Button, Form, Input, Spin, Upload, message } from 'antd'; import { RcFile, UploadChangeParam } from 'antd/es/upload'; -import { File, StepChangeParams } from '@/types/knowledge'; -import { UploadRequestOption as RcCustomRequestOptions } from 'rc-upload/lib/interface'; -import classNames from 'classnames'; +import { default as classNames, default as cls } from 'classnames'; +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Typography } from 'antd'; type FileParams = { file: RcFile; @@ -26,6 +26,8 @@ type FieldType = { originFileObj: FileParams; text: string; webPageUrl: string; + questions: Record[]; + doc_token?: string; }; const { Dragger } = Upload; @@ -36,11 +38,11 @@ export default function DocUploadForm(props: IProps) { const { t } = useTranslation(); const [form] = Form.useForm(); const [spinning, setSpinning] = useState(false); - const [files, setFiles] = useState>([]); + const [files, setFiles] = useState([]); const upload = async (data: FieldType) => { - const { docName, textSource, text, webPageUrl } = data; - let docId; + const { docName, textSource, text, webPageUrl, doc_token, questions = [], originFileObj } = data; + let docId: any; setSpinning(true); switch (docType) { case 'URL': @@ -49,6 +51,7 @@ export default function DocUploadForm(props: IProps) { doc_name: docName, content: webPageUrl, doc_type: 'URL', + questions: questions?.map((item) => item.question), }), ); break; @@ -59,9 +62,43 @@ export default function DocUploadForm(props: IProps) { source: textSource, content: text, doc_type: 'TEXT', + questions: questions.map((item) => item.question), }), ); break; + case 'YUQUEURL': + [, docId] = await apiInterceptors( + addYuque({ + doc_name: docName, + space_name: spaceName, + content: webPageUrl, + doc_type: 'YUQUEURL', + doc_token: doc_token || '', + questions: questions?.map((item) => item.question), + }), + ); + break; + case 'DOCUMENT': + const file = originFileObj as any; + const formData = new FormData(); + const filename = file?.name; + const ques = questions.map((item) => item.question); + formData.append('doc_name', filename); + formData.append('doc_file', file); + formData.append('doc_type', 'DOCUMENT'); + formData.append('questions', JSON.stringify(ques)); + [, docId] = await apiInterceptors(uploadDocument(spaceName, formData)); + console.log(docId); + if (Number.isInteger(docId)) { + setFiles((files: any) => { + files.push({ + name: filename, + doc_id: docId || -1, + }); + return files; + }); + } + break; } setSpinning(false); if (docType === 'DOCUMENT' && files.length < 1) { @@ -86,28 +123,8 @@ export default function DocUploadForm(props: IProps) { const handleFileChange = ({ file, fileList }: UploadChangeParam) => { if (fileList.length === 0) { form.setFieldValue('originFileObj', null); - } - }; - - const uploadFile = async (options: RcCustomRequestOptions) => { - const { onSuccess, onError, file } = options; - const formData = new FormData(); - const filename = file?.name; - formData.append('doc_name', filename); - formData.append('doc_file', file); - formData.append('doc_type', 'DOCUMENT'); - const [, docId] = await apiInterceptors(uploadDocument(spaceName, formData)); - if (Number.isInteger(docId)) { - onSuccess && onSuccess(docId || 0); - setFiles((files) => { - files.push({ - name: filename, - doc_id: docId || -1, - }); - return files; - }); } else { - onError && onError({ name: '', message: '' }); + form.setFieldValue('originFileObj', file); } }; @@ -127,6 +144,40 @@ export default function DocUploadForm(props: IProps) { label={`${t('Text')}:`} name="text" rules={[{ required: true, message: t('Please_input_the_description') }]}>