-
-
-
-
{title} {required && *}
- {titleTooltip &&
}
-
-
-
{value?.length || 0}
- {isSupportPromptGenerator && (
-
- )}
-
-
- {/* Operations */}
-
- }
- >
-
-
- {
- onEditionTypeChange?.(checked ? EditionType.jinja2 : EditionType.basic)
- }}
- />
-
-
-
- )}
- {!readOnly && (
-
-
-
-
-
- )}
- {showRemove && (
-
-
-
- )}
- {!isCopied
- ? (
-
-
-
- )
- : (
-
-
-
- )
- }
-
+ <>
+
+
+
+
+
+
{title} {required && *}
+ {titleTooltip &&
}
-
-
-
-
- {/* Min: 80 Max: 560. Header: 24 */}
-
- {!(isSupportJinja && editionType === EditionType.jinja2)
- ? (
- <>
-
-
{
- acc[node.id] = {
- title: node.data.title,
- type: node.data.type,
- width: node.width,
- height: node.height,
- position: node.position,
- }
- if (node.data.type === BlockEnum.Start) {
- acc.sys = {
- title: t('workflow.blocks.start'),
- type: BlockEnum.Start,
- }
- }
- return acc
- }, {} as any),
- showManageInputField: !!pipelineId,
- onManageInputField: () => setShowInputFieldPanel?.(true),
- }}
- onChange={onChange}
- onBlur={setBlur}
- onFocus={setFocus}
- editable={!readOnly}
- isSupportFileVar={isSupportFileVar}
- isMemorySupported
- memoryVarInNode={memoryVarInNode}
- memoryVarInApp={memoryVarInApp}
- />
- {/* to patch Editor not support dynamic change editable status */}
- {readOnly && }
-
- {isMemorySupported &&
}
- >
- )
- : (
-
-
+ {value?.length || 0}
+ {isSupportPromptGenerator && (
+
+ )}
+
+
+ {/* Operations */}
+
+ }
+ >
+
+
+ {
+ onEditionTypeChange?.(checked ? EditionType.jinja2 : EditionType.basic)
+ }}
+ />
+
+
+
+ )}
+ {!readOnly && (
+
+
+
+
+
+ )}
+ {showRemove && (
+
+
+
+ )}
+ {!isCopied
+ ? (
+
+
+
+ )
+ : (
+
+
+
+ )
+ }
+
- )}
+
+
+
+
+ {/* Min: 80 Max: 560. Header: 24 */}
+
+ {!(isSupportJinja && editionType === EditionType.jinja2)
+ ? (
+ <>
+
+
{
+ acc[node.id] = {
+ title: node.data.title,
+ type: node.data.type,
+ width: node.width,
+ height: node.height,
+ position: node.position,
+ }
+ if (node.data.type === BlockEnum.Start) {
+ acc.sys = {
+ title: t('workflow.blocks.start'),
+ type: BlockEnum.Start,
+ }
+ }
+ return acc
+ }, {} as any),
+ showManageInputField: !!pipelineId,
+ onManageInputField: () => setShowInputFieldPanel?.(true),
+ }}
+ onChange={onChange}
+ onBlur={setBlur}
+ onFocus={setFocus}
+ editable={!readOnly}
+ isSupportFileVar={isSupportFileVar}
+ isMemorySupported
+ memoryVarInNode={memoryVarInNode}
+ memoryVarInApp={memoryVarInApp}
+ />
+ {/* to patch Editor not support dynamic change editable status */}
+ {readOnly && }
+
+ {isMemorySupported &&
}
+ >
+ )
+ : (
+
+
+
+ )}
+
-
-
+
+ {isMemorySupported &&
}
+ >
)
}
diff --git a/web/app/components/workflow/nodes/_base/components/prompt/type.ts b/web/app/components/workflow/nodes/_base/components/prompt/type.ts
new file mode 100644
index 0000000000..a10c405b32
--- /dev/null
+++ b/web/app/components/workflow/nodes/_base/components/prompt/type.ts
@@ -0,0 +1,3 @@
+export const MEMORY_POPUP_SHOW_BY_EVENT_EMITTER = 'MEMORY_POPUP_SHOW_BY_EVENT_EMITTER'
+export const MEMORY_VAR_MODAL_SHOW_BY_EVENT_EMITTER = 'MEMORY_VAR_MODAL_SHOW_BY_EVENT_EMITTER'
+export const MEMORY_VAR_CREATED_BY_MODAL_BY_EVENT_EMITTER = 'MEMORY_VAR_CREATED_BY_MODAL_BY_EVENT_EMITTER'
diff --git a/web/app/components/workflow/nodes/llm/components/memory-system/memory-create-button.tsx b/web/app/components/workflow/nodes/llm/components/memory-system/memory-create-button.tsx
index b55fae28ea..1a6125f7cc 100644
--- a/web/app/components/workflow/nodes/llm/components/memory-system/memory-create-button.tsx
+++ b/web/app/components/workflow/nodes/llm/components/memory-system/memory-create-button.tsx
@@ -1,6 +1,7 @@
import { useCallback, useState } from 'react'
import { RiAddLine } from '@remixicon/react'
import VariableModal from '@/app/components/workflow/panel/chat-variable-panel/components/variable-modal'
+import type { OffsetOptions, Placement } from '@floating-ui/react'
import {
PortalToFollowElem,
PortalToFollowElemContent,
@@ -11,8 +12,23 @@ import type { ConversationVariable } from '@/app/components/workflow/types'
import { useStore } from '@/app/components/workflow/store'
import { useNodesSyncDraft } from '@/app/components/workflow/hooks/use-nodes-sync-draft'
import useInspectVarsCrud from '@/app/components/workflow/hooks/use-inspect-vars-crud'
+import { useEventEmitterContextContext } from '@/context/event-emitter'
+import { MEMORY_VAR_CREATED_BY_MODAL_BY_EVENT_EMITTER, MEMORY_VAR_MODAL_SHOW_BY_EVENT_EMITTER } from '@/app/components/workflow/nodes/_base/components/prompt/type'
-const MemoryCreateButton = () => {
+type Props = {
+ placement?: Placement
+ offset?: number | OffsetOptions
+ hideTrigger?: boolean
+ instanceId?: string
+}
+
+const MemoryCreateButton = ({
+ placement,
+ offset,
+ hideTrigger,
+ instanceId,
+}: Props) => {
+ const { eventEmitter } = useEventEmitterContextContext()
const [open, setOpen] = useState(false)
const varList = useStore(s => s.conversationVariables) as ConversationVariable[]
const updateChatVarList = useStore(s => s.setConversationVariables)
@@ -34,19 +50,30 @@ const MemoryCreateButton = () => {
updateChatVarList(newList)
handleVarChanged()
setOpen(false)
- }, [varList, updateChatVarList, handleVarChanged, setOpen])
+ if (instanceId)
+ eventEmitter?.emit({ type: MEMORY_VAR_CREATED_BY_MODAL_BY_EVENT_EMITTER, instanceId, variable: ['conversation', newChatVar.name] } as any)
+ }, [varList, updateChatVarList, handleVarChanged, setOpen, eventEmitter, instanceId])
+
+ eventEmitter?.useSubscription((v: any) => {
+ if (v.type === MEMORY_VAR_MODAL_SHOW_BY_EVENT_EMITTER && v.instanceId === instanceId)
+ setOpen(true)
+ })
return (
<>
setOpen(v => !v)}>
-
-
-
+ {hideTrigger && }
+ {!hideTrigger && (
+
+
+
+ )}