MCPcopy Create free account
hub / github.com/NanGePlus/LightRAGTest / encode_string_by_tiktoken

Function encode_string_by_tiktoken

LightRAG/lightrag/utils.py:137–142  ·  view source on GitHub ↗
(content: str, model_name: str = "gpt-4o")

Source from the content-addressed store, hash-verified

135
136
137def encode_string_by_tiktoken(content: str, model_name: str = "gpt-4o"):
138 global ENCODER
139 if ENCODER is None:
140 ENCODER = tiktoken.encoding_for_model(model_name)
141 tokens = ENCODER.encode(content)
142 return tokens
143
144
145def decode_tokens_by_tiktoken(tokens: list[int], model_name: str = "gpt-4o"):

Callers 3

chunking_by_token_sizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected