MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / summarize_entity

Function summarize_entity

GraphExtraction/deal_triple.py:14–20  ·  view source on GitHub ↗
(entity_name, description, summary_prompt, threshold, tokenizer)

Source from the content-addressed store, hash-verified

12import tiktoken
13threshold=50
14def summarize_entity(entity_name, description, summary_prompt, threshold, tokenizer):
15 tokens = len(tokenizer.encode(description))
16 if tokens > threshold:
17 exact_prompt = summary_prompt.format(entity_name=entity_name, description=description)
18 response = use_llm(exact_prompt)
19 return entity_name, response
20 return entity_name, description # 不需要摘要则返回原始 description
21
22
23def truncate_data():

Callers

nothing calls this directly

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected