mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 07:59:10 +08:00
fix features update by DSL import
This commit is contained in:
parent
f0285a53d2
commit
e2b1464db2
@ -1,6 +1,6 @@
|
|||||||
import { createStore } from 'zustand'
|
import { createStore } from 'zustand'
|
||||||
import type { Features } from './types'
|
import type { Features } from './types'
|
||||||
import { TransferMethod } from '@/types/app'
|
import { Resolution, TransferMethod } from '@/types/app'
|
||||||
|
|
||||||
export type FeaturesModal = {
|
export type FeaturesModal = {
|
||||||
showFeaturesModal: boolean
|
showFeaturesModal: boolean
|
||||||
@ -46,7 +46,7 @@ export const createFeaturesStore = (initProps?: Partial<FeaturesState>) => {
|
|||||||
file: {
|
file: {
|
||||||
image: {
|
image: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
detail: 'high',
|
detail: Resolution.high,
|
||||||
number_limits: 3,
|
number_limits: 3,
|
||||||
transfer_methods: [TransferMethod.local_file, TransferMethod.remote_url],
|
transfer_methods: [TransferMethod.local_file, TransferMethod.remote_url],
|
||||||
},
|
},
|
||||||
|
@ -14,6 +14,9 @@ import {
|
|||||||
RiCloseLine,
|
RiCloseLine,
|
||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import { WORKFLOW_DATA_UPDATE } from './constants'
|
import { WORKFLOW_DATA_UPDATE } from './constants'
|
||||||
|
import {
|
||||||
|
SupportUploadFileTypes,
|
||||||
|
} from './types'
|
||||||
import {
|
import {
|
||||||
initialEdges,
|
initialEdges,
|
||||||
initialNodes,
|
initialNodes,
|
||||||
@ -25,6 +28,7 @@ import { ToastContext } from '@/app/components/base/toast'
|
|||||||
import { updateWorkflowDraftFromDSL } from '@/service/workflow'
|
import { updateWorkflowDraftFromDSL } from '@/service/workflow'
|
||||||
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||||
|
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||||
|
|
||||||
type UpdateDSLModalProps = {
|
type UpdateDSLModalProps = {
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
@ -78,13 +82,37 @@ const UpdateDSLModal = ({
|
|||||||
hash,
|
hash,
|
||||||
} = await updateWorkflowDraftFromDSL(appDetail.id, fileContent)
|
} = await updateWorkflowDraftFromDSL(appDetail.id, fileContent)
|
||||||
const { nodes, edges, viewport } = graph
|
const { nodes, edges, viewport } = graph
|
||||||
|
const newFeatures = {
|
||||||
|
file: {
|
||||||
|
image: {
|
||||||
|
enabled: !!features.file_upload?.image?.enabled,
|
||||||
|
number_limits: features.file_upload?.image?.number_limits || 3,
|
||||||
|
transfer_methods: features.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
||||||
|
},
|
||||||
|
enabled: !!(features.file_upload?.enabled || features.file_upload?.image?.enabled),
|
||||||
|
allowed_file_types: features.file_upload?.allowed_file_types || [SupportUploadFileTypes.image],
|
||||||
|
allowed_file_extensions: features.file_upload?.allowed_file_extensions || FILE_EXTS[SupportUploadFileTypes.image].map(ext => `.${ext}`),
|
||||||
|
allowed_file_upload_methods: features.file_upload?.allowed_file_upload_methods || features.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
||||||
|
number_limits: features.file_upload?.number_limits || features.file_upload?.image?.number_limits || 3,
|
||||||
|
},
|
||||||
|
opening: {
|
||||||
|
enabled: !!features.opening_statement,
|
||||||
|
opening_statement: features.opening_statement,
|
||||||
|
suggested_questions: features.suggested_questions,
|
||||||
|
},
|
||||||
|
suggested: features.suggested_questions_after_answer || { enabled: false },
|
||||||
|
speech2text: features.speech_to_text || { enabled: false },
|
||||||
|
text2speech: features.text_to_speech || { enabled: false },
|
||||||
|
citation: features.retriever_resource || { enabled: false },
|
||||||
|
moderation: features.sensitive_word_avoidance || { enabled: false },
|
||||||
|
}
|
||||||
eventEmitter?.emit({
|
eventEmitter?.emit({
|
||||||
type: WORKFLOW_DATA_UPDATE,
|
type: WORKFLOW_DATA_UPDATE,
|
||||||
payload: {
|
payload: {
|
||||||
nodes: initialNodes(nodes, edges),
|
nodes: initialNodes(nodes, edges),
|
||||||
edges: initialEdges(edges, nodes),
|
edges: initialEdges(edges, nodes),
|
||||||
viewport,
|
viewport,
|
||||||
features,
|
features: newFeatures,
|
||||||
hash,
|
hash,
|
||||||
},
|
},
|
||||||
} as any)
|
} as any)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user