MCPcopy Create free account
hub / github.com/HKUDS/AutoAgent / encode_string_by_tiktoken

Function encode_string_by_tiktoken

autoagent/memory/utils.py:4–9  ·  view source on GitHub ↗
(content: str, model_name: str = "gpt-4o")

Source from the content-addressed store, hash-verified

2ENCODER = None
3
4def encode_string_by_tiktoken(content: str, model_name: str = "gpt-4o"):
5 global ENCODER
6 if ENCODER is None:
7 ENCODER = tiktoken.encoding_for_model(model_name)
8 tokens = ENCODER.encode(content)
9 return tokens
10
11
12def decode_tokens_by_tiktoken(tokens: list[int], model_name: str = "gpt-4o"):

Callers 1

chunking_by_token_sizeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected