mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
app publish with new features
This commit is contained in:
26
web/app/components/app/app-publisher/features-wrapper.tsx
Normal file
26
web/app/components/app/app-publisher/features-wrapper.tsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import React, { useCallback } from 'react'
|
||||||
|
import type { AppPublisherProps } from '@/app/components/app/app-publisher'
|
||||||
|
import AppPublisher from '@/app/components/app/app-publisher'
|
||||||
|
import { useFeatures } from '@/app/components/base/features/hooks'
|
||||||
|
import type { ModelAndParameter } from '@/app/components/app/configuration/debug/types'
|
||||||
|
|
||||||
|
type Props = Omit<AppPublisherProps, 'onPublish'> & {
|
||||||
|
onPublish?: (modelAndParameter?: ModelAndParameter, features?: any) => Promise<any> | any
|
||||||
|
}
|
||||||
|
|
||||||
|
const FeaturesWrappedAppPublisher = (props: Props) => {
|
||||||
|
const features = useFeatures(s => s.features)
|
||||||
|
|
||||||
|
const handlePublish = useCallback((modelAndParameter?: ModelAndParameter) => {
|
||||||
|
return props.onPublish?.(modelAndParameter, features)
|
||||||
|
}, [features, props])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppPublisher {...{
|
||||||
|
...props,
|
||||||
|
onPublish: handlePublish,
|
||||||
|
}}/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FeaturesWrappedAppPublisher
|
||||||
@ -19,7 +19,7 @@ import {
|
|||||||
import type { ModelAndParameter } from '@/app/components/app/configuration/debug/types'
|
import type { ModelAndParameter } from '@/app/components/app/configuration/debug/types'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import Loading from '@/app/components/base/loading'
|
import Loading from '@/app/components/base/loading'
|
||||||
import AppPublisher from '@/app/components/app/app-publisher'
|
import AppPublisher from '@/app/components/app/app-publisher/features-wrapper'
|
||||||
import type {
|
import type {
|
||||||
AnnotationReplyConfig,
|
AnnotationReplyConfig,
|
||||||
DatasetConfigs,
|
DatasetConfigs,
|
||||||
@ -638,7 +638,7 @@ const Configuration: FC = () => {
|
|||||||
else { return promptEmpty }
|
else { return promptEmpty }
|
||||||
})()
|
})()
|
||||||
const contextVarEmpty = mode === AppType.completion && dataSets.length > 0 && !hasSetContextVar
|
const contextVarEmpty = mode === AppType.completion && dataSets.length > 0 && !hasSetContextVar
|
||||||
const onPublish = async (modelAndParameter?: ModelAndParameter) => {
|
const onPublish = async (modelAndParameter?: ModelAndParameter, features?: FeaturesData) => {
|
||||||
const modelId = modelAndParameter?.model || modelConfig.model_id
|
const modelId = modelAndParameter?.model || modelConfig.model_id
|
||||||
const promptTemplate = modelConfig.configs.prompt_template
|
const promptTemplate = modelConfig.configs.prompt_template
|
||||||
const promptVariables = modelConfig.configs.prompt_variables
|
const promptVariables = modelConfig.configs.prompt_variables
|
||||||
@ -679,14 +679,19 @@ const Configuration: FC = () => {
|
|||||||
completion_prompt_config: {},
|
completion_prompt_config: {},
|
||||||
user_input_form: promptVariablesToUserInputsForm(promptVariables),
|
user_input_form: promptVariablesToUserInputsForm(promptVariables),
|
||||||
dataset_query_variable: contextVar || '',
|
dataset_query_variable: contextVar || '',
|
||||||
opening_statement: introduction || '',
|
// features
|
||||||
suggested_questions: suggestedQuestions || [],
|
more_like_this: features?.moreLikeThis as any,
|
||||||
more_like_this: moreLikeThisConfig,
|
opening_statement: features?.opening?.opening_statement || '',
|
||||||
suggested_questions_after_answer: suggestedQuestionsAfterAnswerConfig,
|
suggested_questions: features?.opening?.suggested_questions || [],
|
||||||
speech_to_text: speechToTextConfig,
|
sensitive_word_avoidance: features?.moderation as any,
|
||||||
text_to_speech: textToSpeechConfig,
|
speech_to_text: features?.speech2text as any,
|
||||||
retriever_resource: citationConfig,
|
text_to_speech: features?.text2speech as any,
|
||||||
sensitive_word_avoidance: moderationConfig,
|
// ##TODO## file_upload
|
||||||
|
file_upload: {
|
||||||
|
image: visionConfig,
|
||||||
|
},
|
||||||
|
suggested_questions_after_answer: features?.suggested as any,
|
||||||
|
retriever_resource: features?.citation as any,
|
||||||
agent_mode: {
|
agent_mode: {
|
||||||
...modelConfig.agentConfig,
|
...modelConfig.agentConfig,
|
||||||
strategy: isFunctionCall ? AgentStrategy.functionCall : AgentStrategy.react,
|
strategy: isFunctionCall ? AgentStrategy.functionCall : AgentStrategy.react,
|
||||||
@ -703,9 +708,6 @@ const Configuration: FC = () => {
|
|||||||
datasets: [...postDatasets],
|
datasets: [...postDatasets],
|
||||||
} as any,
|
} as any,
|
||||||
},
|
},
|
||||||
file_upload: {
|
|
||||||
image: visionConfig,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdvancedMode) {
|
if (isAdvancedMode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user