mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
feat: add MemoryBlock to VariablePool
This commit is contained in:
parent
0c97bbf137
commit
bbb640c9a2
@ -46,6 +46,10 @@ class VariablePool(BaseModel):
|
|||||||
description="Conversation variables.",
|
description="Conversation variables.",
|
||||||
default_factory=list,
|
default_factory=list,
|
||||||
)
|
)
|
||||||
|
memory_blocks: Mapping[str, str] = Field(
|
||||||
|
description="Memory blocks.",
|
||||||
|
default_factory=dict,
|
||||||
|
)
|
||||||
|
|
||||||
def model_post_init(self, context: Any, /) -> None:
|
def model_post_init(self, context: Any, /) -> None:
|
||||||
# Create a mapping from field names to SystemVariableKey enum values
|
# Create a mapping from field names to SystemVariableKey enum values
|
||||||
@ -56,6 +60,9 @@ class VariablePool(BaseModel):
|
|||||||
# Add conversation variables to the variable pool
|
# Add conversation variables to the variable pool
|
||||||
for var in self.conversation_variables:
|
for var in self.conversation_variables:
|
||||||
self.add((CONVERSATION_VARIABLE_NODE_ID, var.name), var)
|
self.add((CONVERSATION_VARIABLE_NODE_ID, var.name), var)
|
||||||
|
# Add memory blocks to the variable pool
|
||||||
|
for memory_id, memory_value in self.memory_blocks.items():
|
||||||
|
self.add(['memory_block', memory_id], memory_value)
|
||||||
|
|
||||||
def add(self, selector: Sequence[str], value: Any, /) -> None:
|
def add(self, selector: Sequence[str], value: Any, /) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user