Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
commit
Vasek Mlejnsky1979bb6ed1c6
diff --git a/api-service/codegen/tools/playground/playground.py b/api-service/codegen/tools/playground/playground.pyindex 8eb75868e..49035cc43 100644--- a/api-service/codegen/tools/playground/playground.py+++ b/api-service/codegen/tools/playground/playground.py@@ -168,13 +168,11 @@ class NodeJSPlayground(Playground):def run_javascript_code(self, code: str):print(f"Running javascript code: {code}")self.write_file(self.default_javascript_code_file, code)- res = self.run_command(+ return self.run_command(f"node {self.default_javascript_code_file}",rootdir=self.rootdir,env_vars=self.env_vars,)- print(res)- return resdef run_typescript_code(self, code: str, typecheck: bool = False):self.write_file(self.default_typescript_code_file, code)@@ -200,7 +198,6 @@ class NodeJSPlayground(Playground):request_cmd: str,port: float,):-print("CALLING", code)self.write_file(self.default_javascript_code_file, code)result = self.run_server_with_request(diff --git a/api-service/codegen/tools/playground/tools/process.py b/api-service/codegen/tools/playground/tools/process.pyindex 80ea8a305..003aa1751 100644--- a/api-service/codegen/tools/playground/tools/process.py+++ b/api-service/codegen/tools/playground/tools/process.py@@ -15,7 +15,7 @@ def encode_command_output(response: ProcessResponse, only_errors: bool = False)if only_errors:return result-+ print(errors)out_lines = [out.line for out in response.stdout]output = "\n".join(out_lines)diff --git a/api-service/could-not-parse-llm-output.txt b/api-service/could-not-parse-llm-output.txtnew file mode 100644index 000000000..72bdb7895--- /dev/null+++ b/api-service/could-not-parse-llm-output.txt@@ -0,0 +1,51 @@+Thought: We need to check if the incoming request is a POST request and retrieve the email from the request payload. We can use the `req.method` property to check if the request is a POST request and `req.body` to retrieve the email from the request payload. We can use a regular expression to check if the email is valid.++Action:+```+{+ "action": "RunJavaScriptCode",+ "action_input": "import express from 'express';\nconst app = express();\n\n// All incoming requests have payload in the JSON format.\napp.use(express.json());\n\nfunction handlepostRequest(req, res) {\n if (req.method !== 'POST') {\n res.status(400).send('Bad Request: Only POST requests are allowed.');\n } else {\n const email = req.body.email;\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;\n if (emailRegex.test(email)) {\n res.send('Ok');\n } else {\n res.status(400).send('Bad Request: Invalid email.');\n }\n }\n}\n\napp.post('/', handlepostRequest);\n\n// Start the server\napp.listen(3000, () => console.log('Listening on port 3000'));"+}+```++Traceback (most recent call last):+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/agents/chat/base.py", line 51, in _extract_tool_and_input+ response = json.loads(action.strip())+ File "/usr/local/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/__init__.py", line 346, in loads+ return _default_decoder.decode(s)+ File "/usr/local/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 337, in decode+ obj, end = self.raw_decode(s, idx=_w(s, 0).end())+ File "/usr/local/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 353, in raw_decode+ obj, end = self.scan_once(s, idx)+json.decoder.JSONDecodeError: Invalid \escape: line 3 column 416 (char 450)++During handling of the above exception, another exception occurred:++Traceback (most recent call last):+ File "/Users/vasekmlejnsky/Developer/ai-api/api-service/test.py", line 133, in <module>+ ae.run(+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/chains/base.py", line 216, in run+ return self(kwargs)[self.output_keys[0]]+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/chains/base.py", line 116, in __call__+ raise e+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/chains/base.py", line 113, in __call__+ outputs = self._call(inputs)+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/agents/agent.py", line 499, in _call+ next_step_output = self._take_next_step(+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/agents/agent.py", line 409, in _take_next_step+ output = self.agent.plan(intermediate_steps, **inputs)+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/agents/agent.py", line 105, in plan+ action = self._get_next_action(full_inputs)+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/agents/agent.py", line 67, in _get_next_action+ parsed_output = self._extract_tool_and_input(full_output)+ File "/Users/vasekmlejnsky/Library/Caches/pypoetry/virtualenvs/codegen-FZjZZaFx-py3.10/lib/python3.10/site-packages/langchain/agents/chat/base.py", line 55, in _extract_tool_and_input+ raise ValueError(f"Could not parse LLM output: {text}")+ValueError: Could not parse LLM output: Thought: We need to check if the incoming request is a POST request and retrieve the email from the request payload. We can use the `req.method` property to check if the request is a POST request and `req.body` to retrieve the email from the request payload. We can use a regular expression to check if the email is valid.++Action:+```+{+ "action": "RunJavaScriptCode",+ "action_input": "import express from 'express';\nconst app = express();\n\n// All incoming requests have payload in the JSON format.\napp.use(express.json());\n\nfunction handlepostRequest(req, res) {\n if (req.method !== 'POST') {\n res.status(400).send('Bad Request: Only POST requests are allowed.');\n } else {\n const email = req.body.email;\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;\n if (emailRegex.test(email)) {\n res.send('Ok');\n } else {\n res.status(400).send('Bad Request: Invalid email.');\n }\n }\n}\n\napp.post('/', handlepostRequest);\n\n// Start the server\napp.listen(3000, () => console.log('Listening on port 3000'));"+}+```\ No newline at end of filediff --git a/api-service/test.py b/api-service/test.pyindex 722b7bb44..f30affffd 100644--- a/api-service/test.py+++ b/api-service/test.py@@ -30,10 +30,13 @@ FORMAT_INSTRUCTIONS = """"""##########-PREFIX = """You are a senior JavaScript/Nodejs developer. You are building an Express server that handles your REST API and you are required to complete the code function `handle{method}Request` based on the provided instructions from your boss. You have access to the following tools:-You are starting with the following code snippet.+PREFIX = """You are an AI JavaScript/Nodejs assistant.+- Follow the user's requirements carefully & to the letter.+- Minimize any other prose.+- You are building an Express server that handles your REST API and you are required to complete the code based on the provided instructions.+- You are starting with the following code snippet:```-const express = require('express');+import express from 'express';const app = express();// All incoming requests have payload in the JSON format.@@ -42,7 +45,7 @@ app.use(express.json());// The function we need to implement that must handle the {method} requests.// We can make the function async if needed.function handle{method}Request(req, res) {{- // TODO: Implement the function based on the instructions from your boss+ // TODO: Complete the function based on the instructions}}app.{method}('/', handle{method}Request);@@ -50,13 +53,13 @@ app.{method}('/', handle{method}Request);// Start the serverapp.listen(3000, () => console.log('Listening on port 3000'));```--Please follow the template by including the above snippet with escaped new lines in your answers.+- ALWAYS INCLUDE THE ABOVE CODE SNIPPET IN YOUR ANSWERS AND MAKE SURE IT'S JSON ESCAPED.+- You have access to the following tools:"""FORMAT_INSTRUCTIONS = """"The way you use the tools is by specifying a json blob.Specifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).-The only values that should be in the "action" field are: {tool_names}+THE ONLY VALUES THAT SHOULD BE INT HE "action" FIELD ARE: {tool_names}. NO OTHER VALUES ARE ALLOWED.The $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:```{{{{@@ -67,7 +70,7 @@ The $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multALWAYS use the following format and don't add additional empty new lines:-Instruction: the input instruction from your boss you must implement+Instructions: the input instructions you must implementThought: you should always think about what to doAction:```@@ -76,7 +79,7 @@ $JSON_BLOBObservation: the result of the action... (this Thought/Action/Observation can repeat N times)Thought: I now know the final answer-Final Answer: the final answer to the original input question"""+Final Answer: the final code that satisfies all the input instructions. THE FINAL ANSWER IT MUST BE JUST THE CODE."""SUFFIX = """Begin! Reminder to NEVER use tools you don't have access to and ALWAYS use the exact characters `Final Answer` when responding."""