MCPcopy
hub / github.com/huggingface/smolagents / truncate_content

Function truncate_content

src/smolagents/utils.py:257–265  ·  view source on GitHub ↗
(content: str, max_length: int = MAX_LENGTH_TRUNCATE_CONTENT)

Source from the content-addressed store, hash-verified

255
256
257def truncate_content(content: str, max_length: int = MAX_LENGTH_TRUNCATE_CONTENT) -> str:
258 if len(content) <= max_length:
259 return content
260 else:
261 return (
262 content[: max_length // 2]
263 + f"\n..._This content has been truncated to stay below {max_length} characters_...\n"
264 + content[-max_length // 2 :]
265 )
266
267
268class ImportFinder(ast.NodeVisitor):

Callers 3

__call__Method · 0.85
_step_streamMethod · 0.85
_execute_codeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…