feat: introduce trigger functionality (#27644)
Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zhsama <torvalds@linux.do> Co-authored-by: Harry <xh001x@hotmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: yessenia <yessenia.contact@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WTW0313 <twwu@dify.ai> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -65,7 +65,6 @@ const PromptEditor: FC<PromptEditorProps> = ({
|
||||
portalToFollowElemContentClassName='z-[1000]'
|
||||
isAdvancedMode={true}
|
||||
provider={model.provider}
|
||||
mode={model.mode}
|
||||
completionParams={model.completion_params}
|
||||
modelId={model.name}
|
||||
setModel={onModelChange}
|
||||
|
||||
@@ -6,7 +6,7 @@ import cn from 'classnames'
|
||||
import { Generator } from '@/app/components/base/icons/src/vender/other'
|
||||
import { ActionButton } from '@/app/components/base/action-button'
|
||||
import GetAutomaticResModal from '@/app/components/app/configuration/config/automatic/get-automatic-res'
|
||||
import { AppType } from '@/types/app'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import type { GenRes } from '@/service/debug'
|
||||
import type { ModelConfig } from '@/app/components/workflow/types'
|
||||
import { useHooksStore } from '../../../hooks-store'
|
||||
@@ -42,7 +42,7 @@ const PromptGeneratorBtn: FC<Props> = ({
|
||||
</ActionButton>
|
||||
{showAutomatic && (
|
||||
<GetAutomaticResModal
|
||||
mode={AppType.chat}
|
||||
mode={AppModeEnum.CHAT}
|
||||
isShow={showAutomatic}
|
||||
onClose={showAutomaticFalse}
|
||||
onFinished={handleAutomaticRes}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// import { RETRIEVAL_OUTPUT_STRUCT } from '../../constants'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { BlockEnum, EditionType } from '../../types'
|
||||
import { type NodeDefault, type PromptItem, PromptRole } from '../../types'
|
||||
import type { LLMNodeType } from './types'
|
||||
@@ -36,7 +37,7 @@ const nodeDefault: NodeDefault<LLMNodeType> = {
|
||||
model: {
|
||||
provider: '',
|
||||
name: '',
|
||||
mode: 'chat',
|
||||
mode: AppModeEnum.CHAT,
|
||||
completion_params: {
|
||||
temperature: 0.7,
|
||||
},
|
||||
@@ -63,7 +64,7 @@ const nodeDefault: NodeDefault<LLMNodeType> = {
|
||||
errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t(`${i18nPrefix}.fields.model`) })
|
||||
|
||||
if (!errorMessages && !payload.memory) {
|
||||
const isChatModel = payload.model.mode === 'chat'
|
||||
const isChatModel = payload.model.mode === AppModeEnum.CHAT
|
||||
const isPromptEmpty = isChatModel
|
||||
? !(payload.prompt_template as PromptItem[]).some((t) => {
|
||||
if (t.edition_type === EditionType.jinja2)
|
||||
@@ -77,14 +78,14 @@ const nodeDefault: NodeDefault<LLMNodeType> = {
|
||||
}
|
||||
|
||||
if (!errorMessages && !!payload.memory) {
|
||||
const isChatModel = payload.model.mode === 'chat'
|
||||
const isChatModel = payload.model.mode === AppModeEnum.CHAT
|
||||
// payload.memory.query_prompt_template not pass is default: {{#sys.query#}}
|
||||
if (isChatModel && !!payload.memory.query_prompt_template && !payload.memory.query_prompt_template.includes('{{#sys.query#}}'))
|
||||
errorMessages = t('workflow.nodes.llm.sysQueryInUser')
|
||||
}
|
||||
|
||||
if (!errorMessages) {
|
||||
const isChatModel = payload.model.mode === 'chat'
|
||||
const isChatModel = payload.model.mode === AppModeEnum.CHAT
|
||||
const isShowVars = (() => {
|
||||
if (isChatModel)
|
||||
return (payload.prompt_template as PromptItem[]).some(item => item.edition_type === EditionType.jinja2)
|
||||
|
||||
@@ -94,7 +94,6 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
||||
}
|
||||
})()
|
||||
}, [inputs.model.completion_params])
|
||||
|
||||
return (
|
||||
<div className='mt-2'>
|
||||
<div className='space-y-4 px-4 pb-4'>
|
||||
@@ -106,7 +105,6 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
||||
popupClassName='!w-[387px]'
|
||||
isInWorkflow
|
||||
isAdvancedMode={true}
|
||||
mode={model?.mode}
|
||||
provider={model?.provider}
|
||||
completionParams={model?.completion_params}
|
||||
modelId={model?.name}
|
||||
|
||||
@@ -30,6 +30,7 @@ export enum Type {
|
||||
arrayNumber = 'array[number]',
|
||||
arrayObject = 'array[object]',
|
||||
file = 'file',
|
||||
enumType = 'enum',
|
||||
}
|
||||
|
||||
export enum ArrayType {
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||
import { checkHasContextBlock, checkHasHistoryBlock, checkHasQueryBlock } from '@/app/components/base/prompt-editor/constants'
|
||||
import useInspectVarsCrud from '@/app/components/workflow/hooks/use-inspect-vars-crud'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
|
||||
const useConfig = (id: string, payload: LLMNodeType) => {
|
||||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||
@@ -49,7 +50,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
||||
// model
|
||||
const model = inputs.model
|
||||
const modelMode = inputs.model?.mode
|
||||
const isChatModel = modelMode === 'chat'
|
||||
const isChatModel = modelMode === AppModeEnum.CHAT
|
||||
|
||||
const isCompletionModel = !isChatModel
|
||||
|
||||
@@ -134,7 +135,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
||||
draft.model.mode = model.mode!
|
||||
const isModeChange = model.mode !== inputRef.current.model.mode
|
||||
if (isModeChange && defaultConfig && Object.keys(defaultConfig).length > 0)
|
||||
appendDefaultPromptConfig(draft, defaultConfig, model.mode === 'chat')
|
||||
appendDefaultPromptConfig(draft, defaultConfig, model.mode === AppModeEnum.CHAT)
|
||||
})
|
||||
setInputs(newInputs)
|
||||
setModelChanged(true)
|
||||
|
||||
@@ -12,6 +12,7 @@ import useConfigVision from '../../hooks/use-config-vision'
|
||||
import { noop } from 'lodash-es'
|
||||
import { findVariableWhenOnLLMVision } from '../utils'
|
||||
import useAvailableVarList from '../_base/hooks/use-available-var-list'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.llm'
|
||||
type Params = {
|
||||
@@ -56,7 +57,7 @@ const useSingleRunFormParams = ({
|
||||
// model
|
||||
const model = inputs.model
|
||||
const modelMode = inputs.model?.mode
|
||||
const isChatModel = modelMode === 'chat'
|
||||
const isChatModel = modelMode === AppModeEnum.CHAT
|
||||
const {
|
||||
isVisionModel,
|
||||
} = useConfigVision(model, {
|
||||
|
||||
@@ -9,8 +9,9 @@ export const checkNodeValid = (_payload: LLMNodeType) => {
|
||||
}
|
||||
|
||||
export const getFieldType = (field: Field) => {
|
||||
const { type, items } = field
|
||||
if(field.schemaType === 'file') return Type.file
|
||||
const { type, items, enum: enums } = field
|
||||
if (field.schemaType === 'file') return Type.file
|
||||
if (enums && enums.length > 0) return Type.enumType
|
||||
if (type !== Type.array || !items)
|
||||
return type
|
||||
|
||||
|
||||
Reference in New Issue
Block a user