mirror of https://github.com/langgenius/dify.git
fix: fix bugs check by Claude Code
This commit is contained in:
parent
48f3c69c69
commit
05d231ad33
|
|
@ -29,7 +29,7 @@ class MemoryEditApi(Resource):
|
|||
def put(self, app_model):
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('id', type=str, required=True)
|
||||
parser.add_argument('node_id', type=str, required=False)
|
||||
parser.add_argument('node_id', type=str, required=False, default=None)
|
||||
parser.add_argument('update', type=str, required=True)
|
||||
args = parser.parse_args()
|
||||
workflow = WorkflowService().get_published_workflow(app_model)
|
||||
|
|
@ -39,18 +39,27 @@ class MemoryEditApi(Resource):
|
|||
if not memory_spec:
|
||||
return {'error': 'Memory not found'}, 404
|
||||
with Session(db.engine) as session:
|
||||
session.merge(
|
||||
ChatflowMemoryVariable(
|
||||
tenant_id=app_model.tenant_id,
|
||||
app_id=app_model.id,
|
||||
node_id=args['node_id'],
|
||||
memory_id=args['id'],
|
||||
name=memory_spec.name,
|
||||
value=args['update'],
|
||||
scope=memory_spec.scope,
|
||||
term=memory_spec.term,
|
||||
existing = session.query(ChatflowMemoryVariable).filter_by(
|
||||
memory_id=args['id'],
|
||||
tenant_id=app_model.tenant_id,
|
||||
app_id=app_model.id,
|
||||
node_id=args['node_id']
|
||||
).first()
|
||||
if existing:
|
||||
existing.value = args['update']
|
||||
else:
|
||||
session.add(
|
||||
ChatflowMemoryVariable(
|
||||
tenant_id=app_model.tenant_id,
|
||||
app_id=app_model.id,
|
||||
node_id=args['node_id'],
|
||||
memory_id=args['id'],
|
||||
name=memory_spec.name,
|
||||
value=args['update'],
|
||||
scope=memory_spec.scope,
|
||||
term=memory_spec.term,
|
||||
)
|
||||
)
|
||||
)
|
||||
session.commit()
|
||||
return '', 204
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class MemoryEditApi(WebApiResource):
|
|||
def put(self, app_model):
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('id', type=str, required=True)
|
||||
parser.add_argument('node_id', type=str, required=False)
|
||||
parser.add_argument('node_id', type=str, required=False, default=None)
|
||||
parser.add_argument('update', type=str, required=True)
|
||||
args = parser.parse_args()
|
||||
workflow = WorkflowService().get_published_workflow(app_model)
|
||||
|
|
@ -39,18 +39,27 @@ class MemoryEditApi(WebApiResource):
|
|||
if not memory_spec.end_user_editable:
|
||||
return {'error': 'Memory not editable'}, 403
|
||||
with Session(db.engine) as session:
|
||||
session.merge(
|
||||
ChatflowMemoryVariable(
|
||||
tenant_id=app_model.tenant_id,
|
||||
app_id=app_model.id,
|
||||
node_id=args['node_id'],
|
||||
memory_id=args['id'],
|
||||
name=memory_spec.name,
|
||||
value=args['update'],
|
||||
scope=memory_spec.scope,
|
||||
term=memory_spec.term,
|
||||
existing = session.query(ChatflowMemoryVariable).filter_by(
|
||||
memory_id=args['id'],
|
||||
tenant_id=app_model.tenant_id,
|
||||
app_id=app_model.id,
|
||||
node_id=args['node_id']
|
||||
).first()
|
||||
if existing:
|
||||
existing.value = args['update']
|
||||
else:
|
||||
session.add(
|
||||
ChatflowMemoryVariable(
|
||||
tenant_id=app_model.tenant_id,
|
||||
app_id=app_model.id,
|
||||
node_id=args['node_id'],
|
||||
memory_id=args['id'],
|
||||
name=memory_spec.name,
|
||||
value=args['update'],
|
||||
scope=memory_spec.scope,
|
||||
term=memory_spec.term,
|
||||
)
|
||||
)
|
||||
)
|
||||
session.commit()
|
||||
return '', 204
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class VariablePool(BaseModel):
|
|||
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)
|
||||
self.add([CONVERSATION_VARIABLE_NODE_ID, memory_id], memory_value)
|
||||
|
||||
def add(self, selector: Sequence[str], value: Any, /) -> None:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class ChatflowMemoryService:
|
|||
|
||||
@staticmethod
|
||||
def save_memory(memory: MemoryBlock, variable_pool: VariablePool, is_draft: bool) -> None:
|
||||
key = f"{memory.node_id}:{memory.spec.id}" if memory.node_id else memory.spec.id
|
||||
key = f"{memory.node_id}.{memory.spec.id}" if memory.node_id else memory.spec.id
|
||||
variable_pool.add([MEMORY_BLOCK_VARIABLE_NODE_ID, key], memory.value)
|
||||
|
||||
with Session(db.engine) as session:
|
||||
|
|
@ -280,13 +280,13 @@ class ChatflowMemoryService:
|
|||
return True
|
||||
|
||||
@staticmethod
|
||||
def wait_for_sync_memory_completion(workflow, conversation_id: str):
|
||||
def wait_for_sync_memory_completion(workflow: Workflow, conversation_id: str):
|
||||
"""Wait for sync memory update to complete, maximum 50 seconds"""
|
||||
|
||||
memory_blocks = workflow.memory_blocks
|
||||
sync_memory_blocks = [
|
||||
block for block in memory_blocks
|
||||
if block.scope == MemoryScope.APP and block.update_mode == "sync"
|
||||
if block.scope == MemoryScope.APP and block.schedule_mode == MemoryScheduleMode.SYNC
|
||||
]
|
||||
|
||||
if not sync_memory_blocks:
|
||||
|
|
|
|||
Loading…
Reference in New Issue