From 04203506d962fe9dfa48ed83b7111590446e8dfa Mon Sep 17 00:00:00 2001 From: Preston Rasmussen <109292228+prasmussen15@users.noreply.github.com> Date: Wed, 26 Mar 2025 12:37:48 -0400 Subject: [PATCH] fix bug with updating node type attributes (#305) fix bug with saving new properties --- graphiti_core/prompts/summarize_nodes.py | 6 ++++-- graphiti_core/utils/maintenance/node_operations.py | 9 +++++++-- pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/graphiti_core/prompts/summarize_nodes.py b/graphiti_core/prompts/summarize_nodes.py index 80c3b0e8..172cb001 100644 --- a/graphiti_core/prompts/summarize_nodes.py +++ b/graphiti_core/prompts/summarize_nodes.py @@ -85,8 +85,10 @@ def summarize_context(context: dict[str, Any]) -> list[Message]: provided ENTITY. Summaries must be under 500 words. In addition, extract any values for the provided entity properties based on their descriptions. - If the value of the entity property cannot be found in the current context, set the value of the property to None. - Do not hallucinate entity property values if they cannot be found in the current context. + If the value of the entity property cannot be found in the current context, set the value of the property to the Python value None. + + Guidelines: + 1. Do not hallucinate entity property values if they cannot be found in the current context. {context['node_name']} diff --git a/graphiti_core/utils/maintenance/node_operations.py b/graphiti_core/utils/maintenance/node_operations.py index 751ba3ac..6e3f9021 100644 --- a/graphiti_core/utils/maintenance/node_operations.py +++ b/graphiti_core/utils/maintenance/node_operations.py @@ -364,7 +364,11 @@ async def resolve_extracted_node( ) extracted_node.summary = node_attributes_response.get('summary', '') - extracted_node.attributes.update(node_attributes_response) + node_attributes = { + key: value if value != 'None' else None for key, value in node_attributes_response.items() + } + + extracted_node.attributes.update(node_attributes) is_duplicate: bool = llm_response.get('is_duplicate', False) uuid: str | None = llm_response.get('uuid', None) @@ -386,11 +390,12 @@ async def resolve_extracted_node( node.name = name node.summary = summary_response.get('summary', '') - new_attributes = existing_node.attributes + new_attributes = extracted_node.attributes existing_attributes = existing_node.attributes for attribute_name, attribute_value in existing_attributes.items(): if new_attributes.get(attribute_name) is None: new_attributes[attribute_name] = attribute_value + node.attributes = new_attributes uuid_map[extracted_node.uuid] = existing_node.uuid diff --git a/pyproject.toml b/pyproject.toml index 46faffe6..b39c6d49 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "graphiti-core" -version = "0.8.2" +version = "0.8.3" description = "A temporal graph building library" authors = [ "Paul Paliychuk ",