This commit is contained in:
Daniel Chalef 2025-10-02 15:07:09 -07:00
parent 5ab8eee576
commit c8d2f147ea
4 changed files with 7 additions and 19 deletions

View file

@ -552,9 +552,7 @@ class Graphiti:
if update_communities:
communities, community_edges = await semaphore_gather(
*[
update_community(
self.driver, self.llm_client, self.embedder, node
)
update_community(self.driver, self.llm_client, self.embedder, node)
for node in nodes
],
max_coroutines=self.max_coroutines,

View file

@ -24,9 +24,7 @@ def format_edge_date_range(edge: EntityEdge) -> str:
return f'{edge.valid_at if edge.valid_at else "date unknown"} - {(edge.invalid_at if edge.invalid_at else "present")}'
def search_results_to_context_string(
search_results: SearchResults
) -> str:
def search_results_to_context_string(search_results: SearchResults) -> str:
"""Reformats a set of SearchResults into a single string to pass directly to an LLM as context"""
fact_json = [
{

View file

@ -131,9 +131,7 @@ def label_propagation(projection: dict[str, list[Neighbor]]) -> list[list[str]]:
return clusters
async def summarize_pair(
llm_client: LLMClient, summary_pair: tuple[str, str]
) -> str:
async def summarize_pair(llm_client: LLMClient, summary_pair: tuple[str, str]) -> str:
# Prepare context for LLM
context = {
'node_summaries': [{'summary': summary} for summary in summary_pair],
@ -148,9 +146,7 @@ async def summarize_pair(
return pair_summary
async def generate_summary_description(
llm_client: LLMClient, summary: str
) -> str:
async def generate_summary_description(llm_client: LLMClient, summary: str) -> str:
context = {
'summary': summary,
}
@ -178,9 +174,7 @@ async def build_community(
new_summaries: list[str] = list(
await semaphore_gather(
*[
summarize_pair(
llm_client, (str(left_summary), str(right_summary))
)
summarize_pair(llm_client, (str(left_summary), str(right_summary)))
for left_summary, right_summary in zip(
summaries[: int(length / 2)], summaries[int(length / 2) :], strict=False
)
@ -315,9 +309,7 @@ async def update_community(
if community is None:
return [], []
new_summary = await summarize_pair(
llm_client, (entity.summary, community.summary)
)
new_summary = await summarize_pair(llm_client, (entity.summary, community.summary))
new_name = await generate_summary_description(llm_client, new_summary)
community.summary = new_summary

View file

@ -542,7 +542,7 @@ async def resolve_extracted_edge(
'episode_content': episode.content,
'reference_time': episode.valid_at,
'fact': resolved_edge.fact,
}
}
edge_model = edge_type_candidates.get(fact_type) if edge_type_candidates else None
if edge_model is not None and len(edge_model.model_fields) != 0: