mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 16:09:11 +08:00
multiple model message sending
This commit is contained in:
parent
67a34bdd7a
commit
fe94c876fb
@ -16,7 +16,7 @@ import {
|
|||||||
import Chat from '@/app/components/base/chat/chat'
|
import Chat from '@/app/components/base/chat/chat'
|
||||||
import { useChat } from '@/app/components/base/chat/chat/hooks'
|
import { useChat } from '@/app/components/base/chat/chat/hooks'
|
||||||
import { useDebugConfigurationContext } from '@/context/debug-configuration'
|
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 { useEventEmitterContextContext } from '@/context/event-emitter'
|
||||||
import { useProviderContext } from '@/context/provider-context'
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
import {
|
import {
|
||||||
@ -27,6 +27,7 @@ import {
|
|||||||
import Avatar from '@/app/components/base/avatar'
|
import Avatar from '@/app/components/base/avatar'
|
||||||
import { useAppContext } from '@/context/app-context'
|
import { useAppContext } from '@/context/app-context'
|
||||||
import { ModelFeatureEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
import { ModelFeatureEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||||
|
import { useFeatures } from '@/app/components/base/features/hooks'
|
||||||
|
|
||||||
type ChatItemProps = {
|
type ChatItemProps = {
|
||||||
modelAndParameter: ModelAndParameter
|
modelAndParameter: ModelAndParameter
|
||||||
@ -43,7 +44,23 @@ const ChatItem: FC<ChatItemProps> = ({
|
|||||||
collectionList,
|
collectionList,
|
||||||
} = useDebugConfigurationContext()
|
} = useDebugConfigurationContext()
|
||||||
const { textGenerationModelList } = useProviderContext()
|
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 {
|
const {
|
||||||
chatList,
|
chatList,
|
||||||
isResponding,
|
isResponding,
|
||||||
|
@ -12,16 +12,18 @@ import {
|
|||||||
} from './context'
|
} from './context'
|
||||||
import type { DebugWithMultipleModelContextType } from './context'
|
import type { DebugWithMultipleModelContextType } from './context'
|
||||||
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
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 type { VisionFile } from '@/app/components/base/chat/types'
|
||||||
import { useDebugConfigurationContext } from '@/context/debug-configuration'
|
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 DebugWithMultipleModel = () => {
|
||||||
const {
|
const {
|
||||||
mode,
|
mode,
|
||||||
speechToTextConfig,
|
|
||||||
visionConfig,
|
visionConfig,
|
||||||
} = useDebugConfigurationContext()
|
} = useDebugConfigurationContext()
|
||||||
|
const speech2text = useFeatures(s => s.features.speech2text)
|
||||||
const {
|
const {
|
||||||
multipleModelConfigs,
|
multipleModelConfigs,
|
||||||
checkCanSend,
|
checkCanSend,
|
||||||
@ -92,6 +94,8 @@ const DebugWithMultipleModel = () => {
|
|||||||
}
|
}
|
||||||
}, [twoLine, threeLine, fourLine])
|
}, [twoLine, threeLine, fourLine])
|
||||||
|
|
||||||
|
const setShowAppConfigureFeaturesModal = useAppStore(s => s.setShowAppConfigureFeaturesModal)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col h-full'>
|
<div className='flex flex-col h-full'>
|
||||||
<div
|
<div
|
||||||
@ -121,18 +125,17 @@ const DebugWithMultipleModel = () => {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
{/* ##TODO## */}
|
{isChatMode && (
|
||||||
{
|
<div className='shrink-0 pb-0 px-6'>
|
||||||
isChatMode && (
|
<ChatInputArea
|
||||||
<div className='shrink-0 pb-4 px-6'>
|
showFeatureBar
|
||||||
<ChatInput
|
onFeatureBarClick={setShowAppConfigureFeaturesModal}
|
||||||
onSend={handleSend}
|
onSend={handleSend}
|
||||||
speechToTextConfig={speechToTextConfig}
|
speechToTextConfig={speech2text as any}
|
||||||
visionConfig={visionConfig}
|
visionConfig={visionConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)}
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import { promptVariablesToUserInputsForm } from '@/utils/model-config'
|
|||||||
import { TransferMethod } from '@/app/components/base/chat/types'
|
import { TransferMethod } from '@/app/components/base/chat/types'
|
||||||
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
||||||
import { useProviderContext } from '@/context/provider-context'
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
|
import { useFeatures } from '@/app/components/base/features/hooks'
|
||||||
|
|
||||||
type TextGenerationItemProps = {
|
type TextGenerationItemProps = {
|
||||||
modelAndParameter: ModelAndParameter
|
modelAndParameter: ModelAndParameter
|
||||||
@ -30,16 +31,15 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
|
|||||||
introduction,
|
introduction,
|
||||||
suggestedQuestionsAfterAnswerConfig,
|
suggestedQuestionsAfterAnswerConfig,
|
||||||
citationConfig,
|
citationConfig,
|
||||||
moderationConfig,
|
|
||||||
externalDataToolsConfig,
|
externalDataToolsConfig,
|
||||||
chatPromptConfig,
|
chatPromptConfig,
|
||||||
completionPromptConfig,
|
completionPromptConfig,
|
||||||
dataSets,
|
dataSets,
|
||||||
datasetConfigs,
|
datasetConfigs,
|
||||||
visionConfig,
|
visionConfig,
|
||||||
moreLikeThisConfig,
|
|
||||||
} = useDebugConfigurationContext()
|
} = useDebugConfigurationContext()
|
||||||
const { textGenerationModelList } = useProviderContext()
|
const { textGenerationModelList } = useProviderContext()
|
||||||
|
const features = useFeatures(s => s.features)
|
||||||
const postDatasets = dataSets.map(({ id }) => ({
|
const postDatasets = dataSets.map(({ id }) => ({
|
||||||
dataset: {
|
dataset: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@ -54,18 +54,18 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
|
|||||||
completion_prompt_config: isAdvancedMode ? completionPromptConfig : {},
|
completion_prompt_config: isAdvancedMode ? completionPromptConfig : {},
|
||||||
user_input_form: promptVariablesToUserInputsForm(modelConfig.configs.prompt_variables),
|
user_input_form: promptVariablesToUserInputsForm(modelConfig.configs.prompt_variables),
|
||||||
dataset_query_variable: contextVar || '',
|
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,
|
opening_statement: introduction,
|
||||||
suggested_questions_after_answer: suggestedQuestionsAfterAnswerConfig,
|
file_upload: {
|
||||||
speech_to_text: speechToTextConfig,
|
image: visionConfig,
|
||||||
retriever_resource: citationConfig,
|
|
||||||
sensitive_word_avoidance: moderationConfig,
|
|
||||||
external_data_tools: externalDataToolsConfig,
|
|
||||||
more_like_this: moreLikeThisConfig,
|
|
||||||
text_to_speech: {
|
|
||||||
enabled: false,
|
|
||||||
voice: '',
|
|
||||||
language: '',
|
|
||||||
},
|
},
|
||||||
|
speech_to_text: speechToTextConfig,
|
||||||
|
suggested_questions_after_answer: suggestedQuestionsAfterAnswerConfig,
|
||||||
|
retriever_resource: citationConfig,
|
||||||
|
external_data_tools: externalDataToolsConfig,
|
||||||
agent_mode: {
|
agent_mode: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
tools: [],
|
tools: [],
|
||||||
@ -76,9 +76,6 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
|
|||||||
datasets: [...postDatasets],
|
datasets: [...postDatasets],
|
||||||
} as any,
|
} as any,
|
||||||
},
|
},
|
||||||
file_upload: {
|
|
||||||
image: visionConfig,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
const {
|
const {
|
||||||
completion,
|
completion,
|
||||||
@ -146,6 +143,7 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
|
|||||||
isLoading={!completion && isResponding}
|
isLoading={!completion && isResponding}
|
||||||
isResponding={isResponding}
|
isResponding={isResponding}
|
||||||
isInstalledApp={false}
|
isInstalledApp={false}
|
||||||
|
siteInfo={null}
|
||||||
messageId={messageId}
|
messageId={messageId}
|
||||||
isError={false}
|
isError={false}
|
||||||
onRetry={() => { }}
|
onRetry={() => { }}
|
||||||
|
@ -445,7 +445,7 @@ const Debug: FC<IDebug> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{mode !== AppType.completion && expanded && (
|
{mode !== AppType.completion && expanded && (
|
||||||
<div className='mx-3 mt-1'>
|
<div className='mx-3'>
|
||||||
<ChatUserInput inputs={inputs} />
|
<ChatUserInput inputs={inputs} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -263,16 +263,6 @@ const Chat: FC<ChatProps> = ({
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
{/* {
|
|
||||||
!noChatInput && (
|
|
||||||
<ChatInput
|
|
||||||
visionConfig={config?.file_upload?.image}
|
|
||||||
speechToTextConfig={config?.speech_to_text}
|
|
||||||
onSend={onSend}
|
|
||||||
theme={themeBuilder?.theme}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
} */}
|
|
||||||
{
|
{
|
||||||
!noChatInput && (
|
!noChatInput && (
|
||||||
<ChatInputArea
|
<ChatInputArea
|
||||||
|
@ -3,7 +3,7 @@ import type {
|
|||||||
VisionFile,
|
VisionFile,
|
||||||
VisionSettings,
|
VisionSettings,
|
||||||
} from '@/types/app'
|
} from '@/types/app'
|
||||||
|
import type { ExternalDataTool } from '@/models/common'
|
||||||
export type { VisionFile } from '@/types/app'
|
export type { VisionFile } from '@/types/app'
|
||||||
export { TransferMethod } from '@/types/app'
|
export { TransferMethod } from '@/types/app'
|
||||||
|
|
||||||
@ -36,6 +36,8 @@ export type EnableType = {
|
|||||||
enabled: boolean
|
enabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TextGenerationConfig = Omit<ModelConfig, 'model'>
|
export type TextGenerationConfig = Omit<ModelConfig, 'model'> & {
|
||||||
|
external_data_tools: ExternalDataTool[]
|
||||||
|
}
|
||||||
|
|
||||||
export type OnSend = (message: string, files?: VisionFile[]) => void
|
export type OnSend = (message: string, files?: VisionFile[]) => void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user