MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / __write_script_file

Function __write_script_file

functions/function_calling/code_executor.py:18–25  ·  view source on GitHub ↗
(_code: str)

Source from the content-addressed store, hash-verified

16 from pathlib import Path
17
18 def __write_script_file(_code: str):
19 _workspace = Path(os.getenv('TEMP_CODE_DIR', 'temp')).resolve()
20 _workspace.mkdir(exist_ok=True)
21 filename = f"{uuid.uuid4()}.py"
22 code_path = _workspace / filename
23 code_content = _code if _code.endswith("\n") else _code + "\n"
24 code_path.write_text(code_content, encoding="utf-8")
25 return code_path
26
27 def __default_interpreter() -> str:
28 return sys.executable or "python3"

Callers 1

execute_codeFunction · 0.85

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected