Add triple update (#263)

* update add-triplet

* test fixes
This commit is contained in:
Preston Rasmussen 2025-02-12 12:04:43 -05:00 committed by GitHub
parent a99aad59de
commit 0e45d15462
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View file

@ -724,7 +724,7 @@ class Graphiti:
if edge.fact_embedding is None:
await edge.generate_embedding(self.embedder)
resolved_nodes, _ = await resolve_extracted_nodes(
resolved_nodes, uuid_map = await resolve_extracted_nodes(
self.llm_client,
[source_node, target_node],
[
@ -733,14 +733,16 @@ class Graphiti:
],
)
updated_edge = resolve_edge_pointers([edge], uuid_map)[0]
related_edges = await get_relevant_edges(
self.driver,
[edge],
[updated_edge],
source_node_uuid=resolved_nodes[0].uuid,
target_node_uuid=resolved_nodes[1].uuid,
)
resolved_edge = await dedupe_extracted_edge(self.llm_client, edge, related_edges)
resolved_edge = await dedupe_extracted_edge(self.llm_client, updated_edge, related_edges)
contradicting_edges = await get_edge_contradictions(self.llm_client, edge, related_edges)
invalidated_edges = resolve_edge_contradictions(resolved_edge, contradicting_edges)

View file

@ -79,8 +79,8 @@ def summarize_context(context: dict[str, Any]) -> list[Message]:
{json.dumps(context['episode_content'], indent=2)}
</MESSAGES>
Given the above MESSAGES and the following ENTITY name, create a summary for the ENTITY. Your summary must only use
information from the provided MESSAGES. Your summary should also only contain information relevant to the
Given the above MESSAGES and the following ENTITY name and ENTITY CONTEXT, create a summary for the ENTITY. Your summary must only use
information from the provided MESSAGES and from the ENTITY CONTEXT. Your summary should also only contain information relevant to the
provided ENTITY.
Summaries must be under 500 words.
@ -88,6 +88,9 @@ def summarize_context(context: dict[str, Any]) -> list[Message]:
<ENTITY>
{context['node_name']}
</ENTITY>
<ENTITY CONTEXT>
{context['node_summary']}
</ENTITY CONTEXT>
""",
),
]

View file

@ -268,6 +268,7 @@ async def resolve_extracted_node(
summary_context = {
'node_name': extracted_node.name,
'node_summary': extracted_node.summary,
'episode_content': episode.content if episode is not None else '',
'previous_episodes': [ep.content for ep in previous_episodes]
if previous_episodes is not None