mirror of https://github.com/langgenius/dify.git
fix: memory type
This commit is contained in:
parent
257e43e2c2
commit
f8097b20c8
|
|
@ -14,7 +14,7 @@ export const useMemory = (
|
|||
id: string,
|
||||
data: LLMNodeType,
|
||||
) => {
|
||||
const { memory = {} as Memory } = data
|
||||
const { memory } = data
|
||||
const initCollapsed = useMemo(() => {
|
||||
if (!memory?.enabled)
|
||||
return true
|
||||
|
|
@ -74,16 +74,19 @@ export const useMemory = (
|
|||
}, [handleNodeDataUpdate])
|
||||
|
||||
const memoryType = useMemo(() => {
|
||||
if (memory?.enabled) {
|
||||
if (!memory)
|
||||
return 'disabled'
|
||||
|
||||
if (!('enabled' in memory))
|
||||
return 'linear'
|
||||
|
||||
if (memory.enabled) {
|
||||
if (memory.mode === 'linear')
|
||||
return 'linear'
|
||||
if (memory.mode === 'block')
|
||||
return 'block'
|
||||
}
|
||||
else {
|
||||
if (memory?.window?.enabled)
|
||||
return 'linear'
|
||||
|
||||
return 'disabled'
|
||||
}
|
||||
}, [memory])
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import LinearMemory from './linear-memory'
|
|||
import type { Memory } from '@/app/components/workflow/types'
|
||||
import type { LLMNodeType } from '../../types'
|
||||
import { useMemory } from './hooks'
|
||||
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
||||
|
||||
type MemoryProps = Pick<Node, 'id' | 'data'> & {
|
||||
readonly?: boolean
|
||||
|
|
@ -37,7 +38,7 @@ const MemorySystem = ({
|
|||
|
||||
return (
|
||||
<>
|
||||
<div className='py-4'>
|
||||
<div className=''>
|
||||
<Collapse
|
||||
disabled={!memory?.enabled}
|
||||
collapsed={collapsed}
|
||||
|
|
@ -83,6 +84,7 @@ const MemorySystem = ({
|
|||
}
|
||||
</>
|
||||
</Collapse>
|
||||
<Split className='mt-4' />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -41,11 +41,7 @@ const MemoryCreateButton = () => {
|
|||
<PortalToFollowElem
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
placement='left-start'
|
||||
offset={{
|
||||
mainAxis: 128,
|
||||
alignmentAxis: -48,
|
||||
}}
|
||||
placement='left'
|
||||
>
|
||||
<PortalToFollowElemTrigger onClick={() => setOpen(v => !v)}>
|
||||
<ActionButton className='shrink-0'>
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
|||
)}
|
||||
|
||||
{/* Memory put place examples. */}
|
||||
{isChatMode && isChatModel && !!inputs.memory && (
|
||||
{isChatMode && isChatModel && !!inputs.memory?.enabled && (
|
||||
<div className='mt-4'>
|
||||
<div className='flex h-8 items-center justify-between rounded-lg bg-components-input-bg-normal pl-3 pr-2'>
|
||||
<div className='flex items-center space-x-1'>
|
||||
|
|
@ -218,7 +218,6 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
|||
{/* Memory */}
|
||||
{isChatMode && (
|
||||
<>
|
||||
<Split />
|
||||
<MemorySystem
|
||||
id={id}
|
||||
data={data}
|
||||
|
|
|
|||
Loading…
Reference in New Issue