Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen15 committed Aug 23, 2024
1 parent 0dd33ab commit 42c27fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions core/prompts/dedupe_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def edge_list(context: dict[str, Any]) -> list[Message]:
Respond with a JSON object in the following format:
{{
"unique_facts": [
{{
"uuid": "unique identifier of the fact",
"fact": "fact of a unique edge"
}}
{{
"uuid": "unique identifier of the fact",
"fact": "fact of a unique edge"
}}
]
}}
""",
Expand Down
10 changes: 8 additions & 2 deletions core/utils/bulk_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def node_name_match(nodes: list[EntityNode]) -> tuple[list[EntityNode], dict[str
async def compress_nodes(
llm_client: LLMClient, nodes: list[EntityNode], uuid_map: dict[str, str]
) -> tuple[list[EntityNode], dict[str, str]]:
anchor = nodes[0] if len(nodes) > 0 else None
if len(nodes) == 0:
return nodes, uuid_map

anchor = nodes[0]
nodes.sort(key=lambda node: dot(anchor.name_embedding or [], node.name_embedding or []))

node_chunks = [nodes[i: i + CHUNK_SIZE] for i in range(0, len(nodes), CHUNK_SIZE)]
Expand All @@ -160,7 +163,10 @@ async def compress_nodes(


async def compress_edges(llm_client: LLMClient, edges: list[EntityEdge]) -> list[EntityEdge]:
anchor = edges[0] if len(edges) > 0 else None
if len(edges) == 0:
return edges

anchor = edges[0]
edges.sort(key=lambda embedding: dot(anchor.fact_embedding or [], embedding.fact_embedding or []))

edge_chunks = [edges[i: i + CHUNK_SIZE] for i in range(0, len(edges), CHUNK_SIZE)]
Expand Down

0 comments on commit 42c27fc

Please # to comment.