MCPcopy Create free account
hub / github.com/MARIO-Math-Reasoning/Super_MARIO / truncate_string

Function truncate_string

mcts_math/tools/python_tool.py:21–34  ·  view source on GitHub ↗
(text, max_length=500, is_evalf=True)

Source from the content-addressed store, hash-verified

19TIMEOUT_MESSAGE = f"Execution of the code snippet has timed out for exceeding {TIMEOUT_SECONDS} seconds."
20
21def truncate_string(text, max_length=500, is_evalf=True):
22 # print(text, file=sys.stderr)
23 # print(type(text), file=sys.stderr)
24 if is_evalf and isinstance(text, str):
25 try:
26 text_sympy = float(text)
27 refine_text = str(round(text_sympy, 4)) + "\n"
28 text = text if len(text) < len(refine_text) else refine_text
29 except:
30 pass
31
32 if len(str(text)) > max_length:
33 return str(text)[:max_length//2] + "..." + str(text)[-max_length//2:]
34 return text
35
36def extract_content(text):
37 pattern = r'print\((.*?)\)'

Callers 1

_sub_runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected