Entity attributes in prompts (#284)

* add node attributes to prompts

* tested

* attribute update
This commit is contained in:
Preston Rasmussen 2025-03-04 16:34:19 -05:00 committed by GitHub
parent a18dde36be
commit 7f20b21572
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View file

@ -64,7 +64,7 @@ def node(context: dict[str, Any]) -> list[Message]:
{json.dumps(context['existing_nodes'], indent=2)}
</EXISTING NODES>
Given the above EXISTING NODES, MESSAGE, and PREVIOUS MESSAGES. Determine if the NEW NODE extracted from the conversation
Given the above EXISTING NODES and their attributes, MESSAGE, and PREVIOUS MESSAGES. Determine if the NEW NODE extracted from the conversation
is a duplicate entity of one of the EXISTING NODES.
<NEW NODE>

View file

@ -55,7 +55,7 @@ def node_search_filter_query_constructor(
filter_params: dict[str, Any] = {}
if filters.node_labels is not None:
node_labels = ':'.join(filters.node_labels)
node_labels = '|'.join(filters.node_labels)
node_label_filter = ' AND n:' + node_labels
filter_query += node_label_filter

View file

@ -289,7 +289,10 @@ async def resolve_extracted_node(
start = time()
# Prepare context for LLM
existing_nodes_context = [{'uuid': node.uuid, 'name': node.name} for node in existing_nodes]
existing_nodes_context = [
{'uuid': node.uuid, 'name': node.name, 'attributes': node.attributes}
for node in existing_nodes
]
extracted_node_context = {
'uuid': extracted_node.uuid,
@ -366,6 +369,13 @@ async def resolve_extracted_node(
node = existing_node
node.name = name
node.summary = summary_response.get('summary', '')
new_attributes = existing_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
uuid_map[extracted_node.uuid] = existing_node.uuid
end = time()

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "graphiti-core"
version = "0.7.6"
version = "0.7.7"
description = "A temporal graph building library"
authors = [
"Paul Paliychuk <paul@getzep.com>",