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

Function sanitize_input

mcts_math/tools/python_tool.py:77–92  ·  view source on GitHub ↗

Sanitize input to the python REPL. Remove whitespace, backtick & python (if llm mistakes python console as terminal) Args: query: The query to sanitize Returns: str: The sanitized query

(query: str)

Source from the content-addressed store, hash-verified

75
76
77def sanitize_input(query: str) -> str:
78 """Sanitize input to the python REPL.
79 Remove whitespace, backtick & python (if llm mistakes python console as terminal)
80
81 Args:
82 query: The query to sanitize
83
84 Returns:
85 str: The sanitized query
86 """
87
88 # Removes `, whitespace & python from start
89 query = re.sub(r"^(\s|`)*(?i:python)?\s*", "", query)
90 # Removes whitespace & ` from end
91 query = re.sub(r"(\s|`)*$", "", query)
92 return query
93
94
95class PythonInputs(BaseModel):

Callers 1

_base_runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected