From fe94c876fbd9f5452842b9dbea6be7e0095e3b98 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Sun, 1 Sep 2024 13:37:21 +0800 Subject: [PATCH] multiple model message sending --- .../debug-with-multiple-model/chat-item.tsx | 21 +++++++++++-- .../debug/debug-with-multiple-model/index.tsx | 31 ++++++++++--------- .../text-generation-item.tsx | 28 ++++++++--------- .../app/configuration/debug/index.tsx | 2 +- web/app/components/base/chat/chat/index.tsx | 10 ------ .../components/base/text-generation/types.ts | 6 ++-- 6 files changed, 54 insertions(+), 44 deletions(-) diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx index e79cdf4793..b56e08333f 100644 --- a/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx +++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx @@ -16,7 +16,7 @@ import { import Chat from '@/app/components/base/chat/chat' import { useChat } from '@/app/components/base/chat/chat/hooks' import { useDebugConfigurationContext } from '@/context/debug-configuration' -import type { OnSend } from '@/app/components/base/chat/types' +import type { ChatConfig, OnSend } from '@/app/components/base/chat/types' import { useEventEmitterContextContext } from '@/context/event-emitter' import { useProviderContext } from '@/context/provider-context' import { @@ -27,6 +27,7 @@ import { import Avatar from '@/app/components/base/avatar' import { useAppContext } from '@/context/app-context' import { ModelFeatureEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' +import { useFeatures } from '@/app/components/base/features/hooks' type ChatItemProps = { modelAndParameter: ModelAndParameter @@ -43,7 +44,23 @@ const ChatItem: FC = ({ collectionList, } = useDebugConfigurationContext() const { textGenerationModelList } = useProviderContext() - const config = useConfigFromDebugContext() + const features = useFeatures(s => s.features) + const configTemplate = useConfigFromDebugContext() + const config = useMemo(() => { + return { + ...configTemplate, + more_like_this: features.moreLikeThis, + opening_statement: features.opening?.opening_statement || '', + suggested_questions: features.opening?.suggested_questions || [], + sensitive_word_avoidance: features.moderation, + speech_to_text: features.speech2text, + text_to_speech: features.text2speech, + file_upload: features.file, + suggested_questions_after_answer: features.suggested, + retriever_resource: features.citation, + // ##TODO## annotation_reply + } as ChatConfig + }, [configTemplate, features]) const { chatList, isResponding, diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx index 7ad534d77a..30356b2b1b 100644 --- a/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx +++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx @@ -12,16 +12,18 @@ import { } from './context' import type { DebugWithMultipleModelContextType } from './context' import { useEventEmitterContextContext } from '@/context/event-emitter' -import ChatInput from '@/app/components/base/chat/chat/chat-input' +import ChatInputArea from '@/app/components/base/chat/chat/chat-input-area' import type { VisionFile } from '@/app/components/base/chat/types' import { useDebugConfigurationContext } from '@/context/debug-configuration' +import { useFeatures } from '@/app/components/base/features/hooks' +import { useStore as useAppStore } from '@/app/components/app/store' const DebugWithMultipleModel = () => { const { mode, - speechToTextConfig, visionConfig, } = useDebugConfigurationContext() + const speech2text = useFeatures(s => s.features.speech2text) const { multipleModelConfigs, checkCanSend, @@ -92,6 +94,8 @@ const DebugWithMultipleModel = () => { } }, [twoLine, threeLine, fourLine]) + const setShowAppConfigureFeaturesModal = useAppStore(s => s.setShowAppConfigureFeaturesModal) + return (
{ )) }
- {/* ##TODO## */} - { - isChatMode && ( -
- -
- ) - } + {isChatMode && ( +
+ +
+ )}
) } diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/text-generation-item.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/text-generation-item.tsx index 15a425b5b4..289504f72c 100644 --- a/web/app/components/app/configuration/debug/debug-with-multiple-model/text-generation-item.tsx +++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/text-generation-item.tsx @@ -13,6 +13,7 @@ import { promptVariablesToUserInputsForm } from '@/utils/model-config' import { TransferMethod } from '@/app/components/base/chat/types' import { useEventEmitterContextContext } from '@/context/event-emitter' import { useProviderContext } from '@/context/provider-context' +import { useFeatures } from '@/app/components/base/features/hooks' type TextGenerationItemProps = { modelAndParameter: ModelAndParameter @@ -30,16 +31,15 @@ const TextGenerationItem: FC = ({ introduction, suggestedQuestionsAfterAnswerConfig, citationConfig, - moderationConfig, externalDataToolsConfig, chatPromptConfig, completionPromptConfig, dataSets, datasetConfigs, visionConfig, - moreLikeThisConfig, } = useDebugConfigurationContext() const { textGenerationModelList } = useProviderContext() + const features = useFeatures(s => s.features) const postDatasets = dataSets.map(({ id }) => ({ dataset: { enabled: true, @@ -54,18 +54,18 @@ const TextGenerationItem: FC = ({ completion_prompt_config: isAdvancedMode ? completionPromptConfig : {}, user_input_form: promptVariablesToUserInputsForm(modelConfig.configs.prompt_variables), dataset_query_variable: contextVar || '', + // features + more_like_this: features.moreLikeThis as any, + sensitive_word_avoidance: features.moderation as any, + text_to_speech: features.text2speech as any, opening_statement: introduction, - suggested_questions_after_answer: suggestedQuestionsAfterAnswerConfig, - speech_to_text: speechToTextConfig, - retriever_resource: citationConfig, - sensitive_word_avoidance: moderationConfig, - external_data_tools: externalDataToolsConfig, - more_like_this: moreLikeThisConfig, - text_to_speech: { - enabled: false, - voice: '', - language: '', + file_upload: { + image: visionConfig, }, + speech_to_text: speechToTextConfig, + suggested_questions_after_answer: suggestedQuestionsAfterAnswerConfig, + retriever_resource: citationConfig, + external_data_tools: externalDataToolsConfig, agent_mode: { enabled: false, tools: [], @@ -76,9 +76,6 @@ const TextGenerationItem: FC = ({ datasets: [...postDatasets], } as any, }, - file_upload: { - image: visionConfig, - }, } const { completion, @@ -146,6 +143,7 @@ const TextGenerationItem: FC = ({ isLoading={!completion && isResponding} isResponding={isResponding} isInstalledApp={false} + siteInfo={null} messageId={messageId} isError={false} onRetry={() => { }} diff --git a/web/app/components/app/configuration/debug/index.tsx b/web/app/components/app/configuration/debug/index.tsx index 3d40ff23c0..f0d164590b 100644 --- a/web/app/components/app/configuration/debug/index.tsx +++ b/web/app/components/app/configuration/debug/index.tsx @@ -445,7 +445,7 @@ const Debug: FC = ({ {mode !== AppType.completion && expanded && ( -
+
)} diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsx index 32a462f1a4..601b7ec7dd 100644 --- a/web/app/components/base/chat/chat/index.tsx +++ b/web/app/components/base/chat/chat/index.tsx @@ -263,16 +263,6 @@ const Chat: FC = ({ /> ) } - {/* { - !noChatInput && ( - - ) - } */} { !noChatInput && ( +export type TextGenerationConfig = Omit & { + external_data_tools: ExternalDataTool[] +} export type OnSend = (message: string, files?: VisionFile[]) => void