From d5361b8d09608dbb081981ecdec702a6a053e6f8 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Thu, 25 Jan 2024 12:36:55 +0800 Subject: [PATCH] feat: multiple model configuration (#2196) Co-authored-by: Joel --- web/app/components/app-sidebar/index.tsx | 10 + .../components/app/chat/citation/index.tsx | 4 +- web/app/components/app/chat/log/index.tsx | 3 +- .../debug-with-multiple-model/chat-item.tsx | 188 +++++++++ .../debug-with-multiple-model/context.tsx | 39 ++ .../debug-with-multiple-model/debug-item.tsx | 124 ++++++ .../debug/debug-with-multiple-model/index.tsx | 131 ++++++ .../model-parameter-trigger.tsx | 125 ++++++ .../publish-with-multiple-model.tsx | 103 +++++ .../text-generation-item.tsx | 153 +++++++ .../app/configuration/debug/hooks.tsx | 54 +++ .../app/configuration/debug/index.tsx | 290 +++++++++---- .../app/configuration/debug/types.ts | 18 + .../components/app/configuration/index.tsx | 102 ++++- .../app/text-generate/item/index.tsx | 11 +- .../base/chat/chat/answer/agent-content.tsx | 58 +++ .../base/chat/chat/answer/basic-content.tsx | 22 + .../base/chat/chat/answer/index.tsx | 99 +++++ .../components/base/chat/chat/answer/more.tsx | 45 ++ .../base/chat/chat/answer/operation.tsx | 54 +++ .../chat/chat/answer/suggested-questions.tsx | 35 ++ .../components/base/chat/chat/chat-input.tsx | 220 ++++++++++ web/app/components/base/chat/chat/context.tsx | 60 +++ web/app/components/base/chat/chat/hooks.ts | 395 ++++++++++++++++++ web/app/components/base/chat/chat/index.tsx | 129 ++++++ .../components/base/chat/chat/question.tsx | 62 +++ .../components/base/chat/chat/try-to-ask.tsx | 54 +++ web/app/components/base/chat/types.ts | 48 +++ web/app/components/base/dropdown/index.tsx | 97 +++++ .../communication/message-heart-circle.svg | 5 + .../vender/solid/communication/send-03.svg | 5 + .../vender/solid/general/answer-triangle.svg | 3 + .../solid/general/question-triangle.svg | 6 + .../assets/vender/solid/shapes/star-04.svg | 5 + .../communication/MessageHeartCircle.json | 38 ++ .../communication/MessageHeartCircle.tsx | 16 + .../vender/solid/communication/Send03.json | 36 ++ .../src/vender/solid/communication/Send03.tsx | 16 + .../src/vender/solid/communication/index.ts | 2 + .../vender/solid/general/AnswerTriangle.json | 27 ++ .../vender/solid/general/AnswerTriangle.tsx | 16 + .../solid/general/QuestionTriangle.json | 45 ++ .../vender/solid/general/QuestionTriangle.tsx | 16 + .../icons/src/vender/solid/general/index.ts | 2 + .../icons/src/vender/solid/shapes/Star04.json | 36 ++ .../icons/src/vender/solid/shapes/Star04.tsx | 16 + .../icons/src/vender/solid/shapes/index.ts | 1 + .../components/base/text-generation/hooks.ts | 61 +++ .../components/base/text-generation/types.ts | 41 ++ .../model-parameter-modal/index.tsx | 132 +++--- .../model-parameter-modal/trigger.tsx | 107 +++++ web/context/debug-configuration.ts | 4 +- web/i18n/lang/app-debug.en.ts | 4 + web/i18n/lang/app-debug.zh.ts | 4 + web/service/base.ts | 6 + web/service/debug.ts | 14 +- 56 files changed, 3209 insertions(+), 188 deletions(-) create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/context.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/debug-item.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/publish-with-multiple-model.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/text-generation-item.tsx create mode 100644 web/app/components/app/configuration/debug/hooks.tsx create mode 100644 web/app/components/app/configuration/debug/types.ts create mode 100644 web/app/components/base/chat/chat/answer/agent-content.tsx create mode 100644 web/app/components/base/chat/chat/answer/basic-content.tsx create mode 100644 web/app/components/base/chat/chat/answer/index.tsx create mode 100644 web/app/components/base/chat/chat/answer/more.tsx create mode 100644 web/app/components/base/chat/chat/answer/operation.tsx create mode 100644 web/app/components/base/chat/chat/answer/suggested-questions.tsx create mode 100644 web/app/components/base/chat/chat/chat-input.tsx create mode 100644 web/app/components/base/chat/chat/context.tsx create mode 100644 web/app/components/base/chat/chat/hooks.ts create mode 100644 web/app/components/base/chat/chat/index.tsx create mode 100644 web/app/components/base/chat/chat/question.tsx create mode 100644 web/app/components/base/chat/chat/try-to-ask.tsx create mode 100644 web/app/components/base/chat/types.ts create mode 100644 web/app/components/base/dropdown/index.tsx create mode 100644 web/app/components/base/icons/assets/vender/solid/communication/message-heart-circle.svg create mode 100644 web/app/components/base/icons/assets/vender/solid/communication/send-03.svg create mode 100644 web/app/components/base/icons/assets/vender/solid/general/answer-triangle.svg create mode 100644 web/app/components/base/icons/assets/vender/solid/general/question-triangle.svg create mode 100644 web/app/components/base/icons/assets/vender/solid/shapes/star-04.svg create mode 100644 web/app/components/base/icons/src/vender/solid/communication/MessageHeartCircle.json create mode 100644 web/app/components/base/icons/src/vender/solid/communication/MessageHeartCircle.tsx create mode 100644 web/app/components/base/icons/src/vender/solid/communication/Send03.json create mode 100644 web/app/components/base/icons/src/vender/solid/communication/Send03.tsx create mode 100644 web/app/components/base/icons/src/vender/solid/general/AnswerTriangle.json create mode 100644 web/app/components/base/icons/src/vender/solid/general/AnswerTriangle.tsx create mode 100644 web/app/components/base/icons/src/vender/solid/general/QuestionTriangle.json create mode 100644 web/app/components/base/icons/src/vender/solid/general/QuestionTriangle.tsx create mode 100644 web/app/components/base/icons/src/vender/solid/shapes/Star04.json create mode 100644 web/app/components/base/icons/src/vender/solid/shapes/Star04.tsx create mode 100644 web/app/components/base/icons/src/vender/solid/shapes/index.ts create mode 100644 web/app/components/base/text-generation/hooks.ts create mode 100644 web/app/components/base/text-generation/types.ts create mode 100644 web/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger.tsx diff --git a/web/app/components/app-sidebar/index.tsx b/web/app/components/app-sidebar/index.tsx index 73c812cc4b..163920321c 100644 --- a/web/app/components/app-sidebar/index.tsx +++ b/web/app/components/app-sidebar/index.tsx @@ -7,6 +7,8 @@ import { AlignLeft01, AlignRight01, } from '@/app/components/base/icons/src/vender/line/layout' +import { useEventEmitterContextContext } from '@/context/event-emitter' +import { APP_SIDEBAR_SHOULD_COLLAPSE } from '@/app/components/app/configuration/debug/types' export type IAppDetailNavProps = { iconType?: 'app' | 'dataset' | 'notion' @@ -39,6 +41,14 @@ const AppDetailNav = ({ title, desc, icon, icon_background, navigation, extraInf }) }, []) + const { eventEmitter } = useEventEmitterContextContext() + eventEmitter?.useSubscription((v: any) => { + if (v.type === APP_SIDEBAR_SHOULD_COLLAPSE) { + setModeState('collapse') + localStorage.setItem('app-detail-collapse-or-expand', 'collapse') + } + }) + return (
= ({ data, showHitInfo, + containerClassName = 'chat-answer-container', }) => { const { t } = useTranslation() const elesRef = useRef([]) @@ -46,7 +48,7 @@ const Citation: FC = ({ }, []), [data]) const handleAdjustResourcesLayout = () => { - const containerWidth = document.querySelector('.chat-answer-container')!.clientWidth - 40 + const containerWidth = document.querySelector(`.${containerClassName}`)!.clientWidth - 40 let totalWidth = 0 for (let i = 0; i < resources.length; i++) { totalWidth += elesRef.current[i].clientWidth diff --git a/web/app/components/app/chat/log/index.tsx b/web/app/components/app/chat/log/index.tsx index 23cc81da90..838eeaf35a 100644 --- a/web/app/components/app/chat/log/index.tsx +++ b/web/app/components/app/chat/log/index.tsx @@ -1,6 +1,7 @@ import type { Dispatch, FC, ReactNode, RefObject, SetStateAction } from 'react' import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' +import { uniqueId } from 'lodash-es' import { File02 } from '@/app/components/base/icons/src/vender/line/files' import PromptLogModal from '@/app/components/base/prompt-log-modal' import Tooltip from '@/app/components/base/tooltip' @@ -39,7 +40,7 @@ const Log: FC = ({ children ? children(setShowModal) : ( - +