mirror of https://github.com/langgenius/dify.git
Merge branch 'feat/rag-pipeline' into deploy/rag-dev
This commit is contained in:
commit
e3b3a6d040
|
|
@ -12,8 +12,6 @@ import {
|
|||
DSLImportMode,
|
||||
DSLImportStatus,
|
||||
} from '@/models/app'
|
||||
import { useProviderContextSelector } from '@/context/provider-context'
|
||||
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
|
||||
import { usePluginDependencies } from '@/app/components/workflow/plugin-dependency/hooks'
|
||||
import { noop } from 'lodash-es'
|
||||
import Uploader from './uploader'
|
||||
|
|
@ -70,9 +68,10 @@ const CreateFromDSLModal = ({
|
|||
setFileContent('')
|
||||
}
|
||||
|
||||
const plan = useProviderContextSelector(state => state.plan)
|
||||
const enableBilling = useProviderContextSelector(state => state.enableBilling)
|
||||
const isAppsFull = (enableBilling && plan.usage.buildApps >= plan.total.buildApps)
|
||||
// todo: TBD billing plan
|
||||
// const plan = useProviderContextSelector(state => state.plan)
|
||||
// const enableBilling = useProviderContextSelector(state => state.enableBilling)
|
||||
// const isAppsFull = (enableBilling && plan.usage.buildApps >= plan.total.buildApps)
|
||||
|
||||
const isCreatingRef = useRef(false)
|
||||
|
||||
|
|
@ -182,14 +181,12 @@ const CreateFromDSLModal = ({
|
|||
}
|
||||
|
||||
const buttonDisabled = useMemo(() => {
|
||||
if (isAppsFull)
|
||||
return true
|
||||
if (currentTab === CreateFromDSLModalTab.FROM_FILE)
|
||||
return !currentFile
|
||||
if (currentTab === CreateFromDSLModalTab.FROM_URL)
|
||||
return !dslUrlValue
|
||||
return false
|
||||
}, [isAppsFull, currentTab, currentFile, dslUrlValue])
|
||||
}, [currentTab, currentFile, dslUrlValue])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -226,11 +223,6 @@ const CreateFromDSLModal = ({
|
|||
)
|
||||
}
|
||||
</div>
|
||||
{isAppsFull && (
|
||||
<div className='px-6'>
|
||||
<AppsFull className='mt-0' loc='app-create-dsl' />
|
||||
</div>
|
||||
)}
|
||||
<div className='flex justify-end gap-x-2 p-6 pt-5'>
|
||||
<Button onClick={onClose}>
|
||||
{t('app.newApp.Cancel')}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ import { usePublishedPipelineProcessingParams } from '@/service/use-pipeline'
|
|||
import { PipelineInputVarType } from '@/models/pipeline'
|
||||
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
||||
|
||||
type PartialInputVarType = PipelineInputVarType.textInput | PipelineInputVarType.number | PipelineInputVarType.select | PipelineInputVarType.checkbox
|
||||
|
||||
const VAR_TYPE_MAP: Record<PartialInputVarType, BaseFieldType> = {
|
||||
const VAR_TYPE_MAP: Record<PipelineInputVarType, BaseFieldType> = {
|
||||
[PipelineInputVarType.textInput]: BaseFieldType.textInput,
|
||||
[PipelineInputVarType.number]: BaseFieldType.numberInput,
|
||||
[PipelineInputVarType.paragraph]: BaseFieldType.paragraph,
|
||||
[PipelineInputVarType.select]: BaseFieldType.select,
|
||||
[PipelineInputVarType.singleFile]: BaseFieldType.file,
|
||||
[PipelineInputVarType.multiFiles]: BaseFieldType.fileList,
|
||||
[PipelineInputVarType.number]: BaseFieldType.numberInput,
|
||||
[PipelineInputVarType.checkbox]: BaseFieldType.checkbox,
|
||||
}
|
||||
|
||||
|
|
@ -23,15 +24,15 @@ export const useConfigurations = (datasourceNodeId: string) => {
|
|||
const initialData = useMemo(() => {
|
||||
const variables = paramsConfig?.variables || []
|
||||
return variables.reduce((acc, item) => {
|
||||
const type = VAR_TYPE_MAP[item.type as PartialInputVarType]
|
||||
if (type === BaseFieldType.textInput)
|
||||
acc[item.variable] = ''
|
||||
const type = VAR_TYPE_MAP[item.type]
|
||||
if ([BaseFieldType.textInput, BaseFieldType.paragraph, BaseFieldType.select].includes(type))
|
||||
acc[item.variable] = item.default_value ?? ''
|
||||
if (type === BaseFieldType.numberInput)
|
||||
acc[item.variable] = 0
|
||||
if (type === BaseFieldType.select)
|
||||
acc[item.variable] = item.options?.[0] || ''
|
||||
acc[item.variable] = item.default_value ?? 0
|
||||
if (type === BaseFieldType.checkbox)
|
||||
acc[item.variable] = true
|
||||
if ([BaseFieldType.file, BaseFieldType.fileList].includes(type))
|
||||
acc[item.variable] = []
|
||||
return acc
|
||||
}, {} as Record<string, any>)
|
||||
}, [paramsConfig])
|
||||
|
|
@ -39,7 +40,7 @@ export const useConfigurations = (datasourceNodeId: string) => {
|
|||
const configurations = useMemo(() => {
|
||||
const variables = paramsConfig?.variables || []
|
||||
const configs = variables.map(item => ({
|
||||
type: VAR_TYPE_MAP[item.type as PartialInputVarType],
|
||||
type: VAR_TYPE_MAP[item.type],
|
||||
variable: item.variable,
|
||||
label: item.label,
|
||||
required: item.required,
|
||||
|
|
@ -49,7 +50,12 @@ export const useConfigurations = (datasourceNodeId: string) => {
|
|||
value: option,
|
||||
})),
|
||||
showConditions: [],
|
||||
default: item.default_value,
|
||||
placeholder: item.placeholder,
|
||||
tooltip: item.tooltips,
|
||||
unit: item.unit,
|
||||
allowedFileTypes: item.allowed_file_types,
|
||||
allowedFileExtensions: item.allowed_file_extensions,
|
||||
allowedFileUploadMethods: item.allowed_file_upload_methods,
|
||||
}))
|
||||
return configs
|
||||
}, [paramsConfig])
|
||||
|
|
|
|||
|
|
@ -25,23 +25,34 @@ export const convertToInputFieldFormData = (data?: InputVar): FormData => {
|
|||
allowed_file_extensions,
|
||||
} = data || getNewInputVarInRagPipeline()
|
||||
|
||||
return {
|
||||
const formData: FormData = {
|
||||
type,
|
||||
label,
|
||||
variable,
|
||||
maxLength: max_length,
|
||||
default: default_value,
|
||||
required,
|
||||
tooltips,
|
||||
options,
|
||||
placeholder,
|
||||
unit,
|
||||
allowedFileUploadMethods: allowed_file_upload_methods,
|
||||
allowedTypesAndExtensions: {
|
||||
allowedTypesAndExtensions: {},
|
||||
}
|
||||
|
||||
if (default_value !== undefined && default_value !== null)
|
||||
formData.default = default_value
|
||||
if (tooltips !== undefined && tooltips !== null)
|
||||
formData.tooltips = tooltips
|
||||
if (placeholder !== undefined && placeholder !== null)
|
||||
formData.placeholder = placeholder
|
||||
if (unit !== undefined && unit !== null)
|
||||
formData.unit = unit
|
||||
if (allowed_file_upload_methods)
|
||||
formData.allowedFileUploadMethods = allowed_file_upload_methods
|
||||
if (allowed_file_types && allowed_file_extensions) {
|
||||
formData.allowedTypesAndExtensions = {
|
||||
allowedFileTypes: allowed_file_types,
|
||||
allowedFileExtensions: allowed_file_extensions,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
export const convertFormDataToINputField = (data: FormData): InputVar => {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const DialogWrapper = ({
|
|||
const close = useCallback(() => onClose?.(), [onClose])
|
||||
return (
|
||||
<Transition appear show={show} as={Fragment}>
|
||||
<Dialog as='div' className='relative z-40' onClose={close}>
|
||||
<Dialog as='div' className='relative z-[1000001]' onClose={close}>
|
||||
<TransitionChild>
|
||||
<div className={cn(
|
||||
'fixed inset-0 bg-black/25',
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const VAR_TYPE_MAP: Record<PipelineInputVarType, BaseFieldType> = {
|
|||
[PipelineInputVarType.number]: BaseFieldType.numberInput,
|
||||
[PipelineInputVarType.checkbox]: BaseFieldType.checkbox,
|
||||
}
|
||||
|
||||
export const useConfigurations = (datasourceNodeId: string) => {
|
||||
const pipelineId = useStore(state => state.pipelineId)
|
||||
const { data: paramsConfig } = useDraftPipelineProcessingParams({
|
||||
|
|
@ -50,7 +51,6 @@ export const useConfigurations = (datasourceNodeId: string) => {
|
|||
value: option,
|
||||
})),
|
||||
showConditions: [],
|
||||
default: item.default_value,
|
||||
placeholder: item.placeholder,
|
||||
tooltip: item.tooltips,
|
||||
unit: item.unit,
|
||||
|
|
|
|||
Loading…
Reference in New Issue