MCPcopy
hub / github.com/algorithmicsuperintelligence/optillm / prepare_execution_globals

Function prepare_execution_globals

optillm/z3_solver.py:18–62  ·  view source on GitHub ↗

Prepare globals dictionary for Z3/SymPy code execution. WARNING: This is NOT a security sandbox. The name "execution_globals" reflects that this simply provides the execution environment for solver code, not a security boundary. The code is executed via exec() with access to z3, sy

()

Source from the content-addressed store, hash-verified

16 pass
17
18def prepare_execution_globals():
19 """
20 Prepare globals dictionary for Z3/SymPy code execution.
21
22 WARNING: This is NOT a security sandbox. The name "execution_globals" reflects
23 that this simply provides the execution environment for solver code, not a
24 security boundary. The code is executed via exec() with access to z3, sympy,
25 and math libraries. Only execute trusted code.
26 """
27 execution_globals = {
28 'print': print,
29 '__builtins__': {
30 'True': True,
31 'False': False,
32 'None': None,
33 'abs': abs,
34 'float': float,
35 'int': int,
36 'len': len,
37 'max': max,
38 'min': min,
39 'round': round,
40 'sum': sum,
41 'complex': complex,
42 }
43 }
44
45 # Add common math functions
46 execution_globals.update({
47 'log': math.log,
48 'log2': math.log2,
49 'sqrt': math.sqrt,
50 'exp': math.exp,
51 'sin': math.sin,
52 'cos': math.cos,
53 'tan': math.tan,
54 'pi': math.pi,
55 'e': math.e,
56 })
57
58 # Add complex number support
59 execution_globals['I'] = complex(0, 1)
60 execution_globals['Complex'] = complex
61
62 return execution_globals
63
64def execute_code_in_process(code: str):
65 import z3

Callers 1

execute_code_in_processFunction · 0.85

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected