Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Switch to pure code execution tool
Tomas Valenta8df0ebf28011
diff --git a/api-service/codegen/tools/playground/tools/code.py b/api-service/codegen/tools/playground/tools/code.pyindex f56edd5b6..20a1aceed 100644--- a/api-service/codegen/tools/playground/tools/code.py+++ b/api-service/codegen/tools/playground/tools/code.py@@ -51,8 +51,13 @@ def create_code_tools(playground: NodeJSPlayground, mock: MockRequestFactory):mock_request_cmd = mock.terminal_command()port = 3000- request_output, server_output = playground.run_typescript_server_code_with_request(- code=code, request_cmd=mock_request_cmd, port=port,+ (+ request_output,+ server_output,+ ) = playground.run_typescript_server_code_with_request(+ code=code,+ request_cmd=mock_request_cmd,+ port=port,)request_result = encode_command_output(request_output)@@ -60,7 +65,6 @@ def create_code_tools(playground: NodeJSPlayground, mock: MockRequestFactory):return f"Request result:\n{request_result}\nCode execution result:\n{server_result}"-# yield run_typescript_code@tool("CheckTypeScriptCodeTypes")@@ -76,37 +80,37 @@ def create_code_tools(playground: NodeJSPlayground, mock: MockRequestFactory):# yield check_typescript_code_types# This tool is just for executing JavaScript without doing the request to server- # @tool("RunJavaScriptCode")- # def run_javascript_code(code: str) -> str:- # """- # Run JavaScript code and return errors and output.- # Input should be a valid JavaScript code.- # """- # output = playground.run_javascript_code(extract_code(code))- # result = encode_command_output(output)- # return result if len(result) > 0 else "Code execution finished without error"-- # yield run_javascript_code-@tool("RunJavaScriptCode")def run_javascript_code(code: str) -> str:"""- Execute JavaScript code and make a request to see if server correctly handles needed requests.- The input should be a valid JavaScript code.- The server should run on http://localhost:3000.- The returned result is a the request's output followed by the server code output and errors.+ Run JavaScript code and return errors and output.+ Input should be a valid JavaScript code."""+ output = playground.run_javascript_code(extract_code(code))+ result = encode_command_output(output)+ return result if len(result) > 0 else "Code execution finished without error"- mock_request_cmd = mock.terminal_command()+ yield run_javascript_code- port = 3000- request_output, server_output = playground.run_javascript_server_code_with_request(- code=code, request_cmd=mock_request_cmd, port=port,- )+ # @tool("RunJavaScriptCode")+ # def run_javascript_code(code: str) -> str:+ # """+ # Execute JavaScript code and make a request to see if server correctly handles needed requests.+ # The input should be a valid JavaScript code.+ # The server should run on http://localhost:3000.+ # The returned result is a the request's output followed by the server code output and errors.+ # """- request_result = encode_command_output(request_output)- server_result = encode_command_output(server_output)+ # mock_request_cmd = mock.terminal_command()- return f"Request result:\n{request_result}\nCode execution result:\n{server_result}"+ # port = 3000+ # request_output, server_output = playground.run_javascript_server_code_with_request(+ # code=code, request_cmd=mock_request_cmd, port=port,+ # )- yield run_javascript_code+ # request_result = encode_command_output(request_output)+ # server_result = encode_command_output(server_output)++ # return f"Request result:\n{request_result}\nCode execution result:\n{server_result}"++ # yield run_javascript_code