File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
memories/textual/tree_text_memory/organize Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -114,14 +114,14 @@ def get_memory_count(self, memory_type: str) -> int:
114114 )
115115 return result .single ()["count" ]
116116
117- def count_nodes (self , scope : str ) -> int :
117+ def node_not_exist (self , scope : str ) -> int :
118118 query = """
119119 MATCH (n:Memory)
120120 WHERE n.memory_type = $scope
121121 """
122122 if not self .config .use_multi_db and self .config .user_name :
123123 query += "\n AND n.user_name = $user_name"
124- query += "\n RETURN count(n) AS count "
124+ query += "\n RETURN n LIMIT 1 "
125125
126126 with self .driver .session (database = self .db_name ) as session :
127127 result = session .run (
@@ -131,7 +131,7 @@ def count_nodes(self, scope: str) -> int:
131131 "user_name" : self .config .user_name if self .config .user_name else None ,
132132 },
133133 )
134- return result .single ()[ "count" ]
134+ return result .single () is None
135135
136136 def remove_oldest_memory (self , memory_type : str , keep_latest : int ) -> None :
137137 """
Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ def optimize_structure(
198198 logger .info (f"Already optimizing for { scope } . Skipping." )
199199 return
200200
201- if self .graph_store .count_nodes (scope ) == 0 :
201+ if self .graph_store .node_not_exist (scope ):
202202 logger .debug (f"[GraphStructureReorganize] No nodes for scope={ scope } . Skip." )
203203 return
204204
You can’t perform that action at this time.
0 commit comments