mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +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 { 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<ChatItemProps> = ({
|
|||
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,
|
||||
|
|
|
@ -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 (
|
||||
<div className='flex flex-col h-full'>
|
||||
<div
|
||||
|
@ -121,18 +125,17 @@ const DebugWithMultipleModel = () => {
|
|||
))
|
||||
}
|
||||
</div>
|
||||
{/* ##TODO## */}
|
||||
{
|
||||
isChatMode && (
|
||||
<div className='shrink-0 pb-4 px-6'>
|
||||
<ChatInput
|
||||
onSend={handleSend}
|
||||
speechToTextConfig={speechToTextConfig}
|
||||
visionConfig={visionConfig}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{isChatMode && (
|
||||
<div className='shrink-0 pb-0 px-6'>
|
||||
<ChatInputArea
|
||||
showFeatureBar
|
||||
onFeatureBarClick={setShowAppConfigureFeaturesModal}
|
||||
onSend={handleSend}
|
||||
speechToTextConfig={speech2text as any}
|
||||
visionConfig={visionConfig}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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<TextGenerationItemProps> = ({
|
|||
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<TextGenerationItemProps> = ({
|
|||
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<TextGenerationItemProps> = ({
|
|||
datasets: [...postDatasets],
|
||||
} as any,
|
||||
},
|
||||
file_upload: {
|
||||
image: visionConfig,
|
||||
},
|
||||
}
|
||||
const {
|
||||
completion,
|
||||
|
@ -146,6 +143,7 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
|
|||
isLoading={!completion && isResponding}
|
||||
isResponding={isResponding}
|
||||
isInstalledApp={false}
|
||||
siteInfo={null}
|
||||
messageId={messageId}
|
||||
isError={false}
|
||||
onRetry={() => { }}
|
||||
|
|
|
@ -445,7 +445,7 @@ const Debug: FC<IDebug> = ({
|
|||
</div>
|
||||
</div>
|
||||
{mode !== AppType.completion && expanded && (
|
||||
<div className='mx-3 mt-1'>
|
||||
<div className='mx-3'>
|
||||
<ChatUserInput inputs={inputs} />
|
||||
</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 && (
|
||||
<ChatInputArea
|
||||
|
|
|
@ -3,7 +3,7 @@ import type {
|
|||
VisionFile,
|
||||
VisionSettings,
|
||||
} from '@/types/app'
|
||||
|
||||
import type { ExternalDataTool } from '@/models/common'
|
||||
export type { VisionFile } from '@/types/app'
|
||||
export { TransferMethod } from '@/types/app'
|
||||
|
||||
|
@ -36,6 +36,8 @@ export type EnableType = {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user