Function
summarize_entity
(entity_name, description, summary_prompt, threshold, tokenizer)
Source from the content-addressed store, hash-verified
| 12 | import tiktoken |
| 13 | threshold=50 |
| 14 | def 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 | |
| 23 | def truncate_data(): |
Callers
nothing calls this directly
Tested by
no test coverage detected