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

Function truncate_text

query_graph.py:45–50  ·  view source on GitHub ↗
(text, max_tokens=4096)

Source from the content-addressed store, hash-verified

43
44tokenizer = tiktoken.get_encoding("cl100k_base")
45def truncate_text(text, max_tokens=4096):
46 tokens = tokenizer.encode(text)
47 if len(tokens) > max_tokens:
48 tokens = tokens[:max_tokens]
49 truncated_text = tokenizer.decode(tokens)
50 return truncated_text
51
52def get_reasoning_chain(global_config,entities_set):
53 maybe_edges=list(combinations(entities_set,2))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected