From c1a9120a5e54457585a69d78cbc048f2234e4a39 Mon Sep 17 00:00:00 2001 From: Engel Nyst Date: Wed, 15 May 2024 10:17:37 +0200 Subject: [PATCH] restore the integration tests --- .../CodeActAgent/test_edits/prompt_002.log | 11 +- .../CodeActAgent/test_edits/prompt_003.log | 35 ++- .../CodeActAgent/test_edits/prompt_004.log | 285 ------------------ .../CodeActAgent/test_edits/response_001.log | 4 +- .../CodeActAgent/test_edits/response_002.log | 9 +- .../CodeActAgent/test_edits/response_003.log | 5 +- .../CodeActAgent/test_edits/response_004.log | 4 - .../CodeActAgent/test_ipython/prompt_002.log | 14 +- .../test_ipython/response_001.log | 8 +- .../test_ipython/response_002.log | 2 +- 10 files changed, 50 insertions(+), 327 deletions(-) delete mode 100644 tests/integration/mock/CodeActAgent/test_edits/prompt_004.log delete mode 100644 tests/integration/mock/CodeActAgent/test_edits/response_004.log diff --git a/tests/integration/mock/CodeActAgent/test_edits/prompt_002.log b/tests/integration/mock/CodeActAgent/test_edits/prompt_002.log index 4ef9c0d63f9..912b44ca85c 100644 --- a/tests/integration/mock/CodeActAgent/test_edits/prompt_002.log +++ b/tests/integration/mock/CodeActAgent/test_edits/prompt_002.log @@ -228,7 +228,8 @@ ENVIRONMENT REMINDER: You have 98 turns left to complete the task. ---------- -Let's start by opening the file `bad.txt` to identify and fix the typos. Let me open the file for you: +Certainly! I will start by opening the file `bad.txt` to see the content and then proceed to fix the typos. + open bad.txt @@ -236,10 +237,10 @@ open bad.txt ---------- OBSERVATION: -[File: /workspace/bad.txt (4 lines total)] -1:This is a stupid typoo. -2:Really? -3:No mor typos! +[File: /workspace/bad.txt (4 lines total)] +1:This is a stupid typoo. +2:Really? +3:No mor typos! 4:Enjoy! [Command -1 finished with exit code 0]] diff --git a/tests/integration/mock/CodeActAgent/test_edits/prompt_003.log b/tests/integration/mock/CodeActAgent/test_edits/prompt_003.log index 9ce4f8cc73a..c0581fd3105 100644 --- a/tests/integration/mock/CodeActAgent/test_edits/prompt_003.log +++ b/tests/integration/mock/CodeActAgent/test_edits/prompt_003.log @@ -228,7 +228,8 @@ ENVIRONMENT REMINDER: You have 98 turns left to complete the task. ---------- -Let's start by opening the file `bad.txt` to identify and fix the typos. Let me open the file for you: +Certainly! I will start by opening the file `bad.txt` to see the content and then proceed to fix the typos. + open bad.txt @@ -236,10 +237,10 @@ open bad.txt ---------- OBSERVATION: -[File: /workspace/bad.txt (4 lines total)] -1:This is a stupid typoo. -2:Really? -3:No mor typos! +[File: /workspace/bad.txt (4 lines total)] +1:This is a stupid typoo. +2:Really? +3:No mor typos! 4:Enjoy! [Command -1 finished with exit code 0]] @@ -247,11 +248,13 @@ ENVIRONMENT REMINDER: You have 97 turns left to complete the task. ---------- -I will now correct the typos in the file `bad.txt`. Let me edit the file to fix the typos: +I will now edit the file to correct the typos. + -edit 1:3 +edit 1:1 This is a stupid typo. -Really? +end_of_edit +edit 3:3 No more typos! end_of_edit @@ -259,11 +262,17 @@ end_of_edit ---------- OBSERVATION: -> > > > [File: /workspace/bad.txt (4 lines total)] -1:This is a stupid typo. -2:Really? -3:No more typos! -4:Enjoy! +> > [File: /workspace/bad.txt (4 lines total)] +1:This is a stupid typo. +2:Really? +3:No mor typos! +4:Enjoy! +File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary. +> > [File: /workspace/bad.txt (4 lines total)] +1:This is a stupid typo. +2:Really? +3:No more typos! +4:Enjoy! File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary. [Command -1 finished with exit code 0]] diff --git a/tests/integration/mock/CodeActAgent/test_edits/prompt_004.log b/tests/integration/mock/CodeActAgent/test_edits/prompt_004.log deleted file mode 100644 index c685cff5019..00000000000 --- a/tests/integration/mock/CodeActAgent/test_edits/prompt_004.log +++ /dev/null @@ -1,285 +0,0 @@ - - ----------- - -A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. -The assistant can interact with an interactive Python (Jupyter Notebook) environment and receive the corresponding output when needed. The code should be enclosed using "" tag, for example: - -print("Hello World!") - -The assistant can execute bash commands on behalf of the user by wrapping them with and . -For example, you can list the files in the current directory by ls . -The assistant should attempt fewer things at a time instead of putting too much commands OR code in one "execute" block. -The assistant can install Python packages through bash by pip install [package needed] and should always import packages and define variables before starting to use them. -The assistant should stop and provide an answer when they have already obtained the answer from the execution result. -If the assistant encounters an import error in IPython for a newly installed package, they should try to restart the kernel and import the package again. IPython kernel can be re-started by: - -import IPython -IPython.Application.instance().kernel.do_shutdown(True) # Restart the kernel - -To do any activities on GitHub, you should use the token in the $GITHUB_TOKEN environment variable. -For instance, to push a local branch `my_branch` to the github repo `owner/repo`, you can use the following four commands: - git push https://$GITHUB_TOKEN@github.com/owner/repo.git my_branch -If you require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it for you. - - -Apart from the standard bash commands, you can also use the following special commands in environment: -open [] - opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line -goto - moves the window to show -scroll_down - moves the window down {WINDOW} lines -scroll_up - moves the window down {WINDOW} lines -create - creates and opens a new file with the given name -search_dir [] - searches for search_term in all files in dir. If dir is not provided, searches in the current directory -search_file [] - searches for search_term in file. If file is not provided, searches in the current open file -find_file [] - finds all files with the given name in dir. If dir is not provided, searches in the current directory -edit : - -end_of_edit - replaces lines through (inclusive) with the given text in the open file. The replacement text is terminated by a line with only end_of_edit on it. All of the will be entered, so make sure your indentation is formatted properly. Python files will be checked for syntax errors after the edit. If the system detects a syntax error, the edit will not be executed. Simply try to edit the file again, but make sure to read the error message and modify the edit command you issue accordingly. Issuing the same command a second time will just lead to the same error message again. Remember, the file must be open before editing. -Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run. - -The assistant's response should be concise. -You should include or in every one of your responses, unless you are finished with the task or need more input or action from the user in order to proceed. -IMPORTANT: Whenever possible, execute the code for the user using or instead of providing it. - - ----------- - -Here is an example of how you can interact with the environment for task solving: - ---- START OF EXAMPLE --- - -USER: Can you create a list of numbers from 1 to 10, and create a web page to display them at port 5000? - -ASSISTANT: -Sure! Let me write the Python code for starting a web server and save it to a file `app.py`: - -CODE=''' -from flask import Flask -app = Flask(__name__) - -@app.route('/') -def index(): - numbers = list(range(1, 11)) - return str(numbers) - -if __name__ == '__main__': - app.run(port=5000) -''' -with open('app.py', 'w') as f: - f.write(CODE) - - -USER: -Observation: -[Code executed successfully with no output] - -ASSISTANT: -I have created a Python file `app.py` that will display a list of numbers from 1 to 10 when you run it. Let me run the Python file for you: - -python3 app.py > server.log 2>&1 & - - -USER: -Observation: -[1] 121[1]+ Exit 1 python3 app.py > server.log 2>&1 - -ASSISTANT: Looks like the server is running with PID 121 then crashed. Let me check the server log: - -cat server.log - - -USER: -Observation: -Traceback (most recent call last): - File "/workspace/app.py", line 2, in - from flask import Flask -ModuleNotFoundError: No module named 'flask' - -ASSISTANT: -It seems that Flask is not installed. Let me install Flask for you: - -pip install flask - - -USER: -Observation: -Defaulting to user installation because normal site-packages is not writeable -Collecting flask - Using cached flask-3.0.3-py3-none-any.whl (101 kB) -Collecting blinker>=1.6.2 - Using cached blinker-1.7.0-py3-none-any.whl (13 kB) -Collecting Werkzeug>=3.0.0 - Using cached werkzeug-3.0.2-py3-none-any.whl (226 kB) -Collecting click>=8.1.3 - Using cached click-8.1.7-py3-none-any.whl (97 kB) -Collecting itsdangerous>=2.1.2 - Using cached itsdangerous-2.2.0-py3-none-any.whl (16 kB) -Requirement already satisfied: Jinja2>=3.1.2 in /home/opendevin/.local/lib/python3.10/site-packages (from flask) (3.1.3) -Requirement already satisfied: MarkupSafe>=2.0 in /home/opendevin/.local/lib/python3.10/site-packages (from Jinja2>=3.1.2->flask) (2.1.5) -Installing collected packages: Werkzeug, itsdangerous, click, blinker, flask -Successfully installed Werkzeug-3.0.2 blinker-1.7.0 click-8.1.7 flask-3.0.3 itsdangerous-2.2.0 - -ASSISTANT: -Now that Flask is installed, let me run the Python file again: - -python3 app.py > server.log 2>&1 & - - -USER: -Observation: -[1] 124 - -ASSISTANT: -Let me check the server log again: - -cat server.log - - -USER: -Observation: -* Serving Flask app 'app' - * Debug mode: off -WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. - * Running on http://127.0.0.1:5000 -Press CTRL+C to quit - -ASSISTANT: -The server is running on port 5000 with PID 124. You can access the list of numbers by visiting http://127.0.0.1:5000. If you have any further questions, feel free to ask! - -USER: Now kill the server, make it display the numbers in a table format. - -ASSISTANT: -Sure! Let me stop the server first: - -kill 124 - - -USER: -Observation: -[1]+ Terminated python3 app.py > server.log 2>&1 - -ASSISTANT: -The server has been stopped. Let me open the Python file and modify it. - -open app.py - - -USER: -[File: /workspace/app.py (11 lines total)] -1: -2:from flask import Flask -3:app = Flask(__name__) -4: -5:@app.route('/') -6:def index(): -7: numbers = list(range(1, 11)) -8: return str(numbers) -9: -10:if __name__ == '__main__': -11: app.run(port=5000) - -ASSISTANT: -I should edit the file to display the numbers in a table format. I should include correct indentation. Let me update the file: - -edit 8:8 - return '' + ''.join([f'' for i in numbers]) + '
{i}
' -end_of_edit -
- -USER: -Observation: -[File: /workspace/app.py (11 lines total)] -1: -2:from flask import Flask -3:app = Flask(__name__) -4: -5:@app.route('/') -6:def index(): -7: numbers = list(range(1, 11)) -8: return '' + ''.join([f'' for i in numbers]) + '
{i}
' -9: -10:if __name__ == '__main__': -11: app.run(port=5000) -File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary. - -ASSISTANT: -The file has been updated. Let me run the Python file again with the new changes: - -python3 app.py > server.log 2>&1 & - - -USER: -Observation: -[1] 126 - -ASSISTANT: -The server is running on port 5000 with PID 126. You can access the list of numbers in a table format by visiting http://127.0.0.1:5000. Free free to let me know if you have any further requests! - ---- END OF EXAMPLE --- - - -NOW, LET'S START! - ----------- - -Fix typos in bad.txt. Do not ask me for confirmation at any point. - -ENVIRONMENT REMINDER: You have 98 turns left to complete the task. - ----------- - -Let's start by opening the file `bad.txt` to identify and fix the typos. Let me open the file for you: - -open bad.txt - - ----------- - -OBSERVATION: -[File: /workspace/bad.txt (4 lines total)] -1:This is a stupid typoo. -2:Really? -3:No mor typos! -4:Enjoy! -[Command -1 finished with exit code 0]] - -ENVIRONMENT REMINDER: You have 97 turns left to complete the task. - ----------- - -I will now correct the typos in the file `bad.txt`. Let me edit the file to fix the typos: - -edit 1:3 -This is a stupid typo. -Really? -No more typos! -end_of_edit - - ----------- - -OBSERVATION: -> > > > [File: /workspace/bad.txt (4 lines total)] -1:This is a stupid typo. -2:Really? -3:No more typos! -4:Enjoy! -File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary. -[Command -1 finished with exit code 0]] - -ENVIRONMENT REMINDER: You have 96 turns left to complete the task. - ----------- - -The typos in the file `bad.txt` have been corrected. Let me save the changes and close the file: - -save bad.txt - - ----------- - -OBSERVATION: --bash: save: command not found -[Command -1 finished with exit code 127]] - -ENVIRONMENT REMINDER: You have 95 turns left to complete the task. diff --git a/tests/integration/mock/CodeActAgent/test_edits/response_001.log b/tests/integration/mock/CodeActAgent/test_edits/response_001.log index 8666e181e3d..9a251342e9b 100644 --- a/tests/integration/mock/CodeActAgent/test_edits/response_001.log +++ b/tests/integration/mock/CodeActAgent/test_edits/response_001.log @@ -1,4 +1,4 @@ -Let's start by opening the file `bad.txt` to identify and fix the typos. Let me open the file for you: +Certainly! I will start by opening the file `bad.txt` to see the content and then proceed to fix the typos. + open bad.txt - diff --git a/tests/integration/mock/CodeActAgent/test_edits/response_002.log b/tests/integration/mock/CodeActAgent/test_edits/response_002.log index 1f3705fe820..8016c2db859 100644 --- a/tests/integration/mock/CodeActAgent/test_edits/response_002.log +++ b/tests/integration/mock/CodeActAgent/test_edits/response_002.log @@ -1,8 +1,9 @@ -I will now correct the typos in the file `bad.txt`. Let me edit the file to fix the typos: +I will now edit the file to correct the typos. + -edit 1:3 +edit 1:1 This is a stupid typo. -Really? +end_of_edit +edit 3:3 No more typos! end_of_edit - diff --git a/tests/integration/mock/CodeActAgent/test_edits/response_003.log b/tests/integration/mock/CodeActAgent/test_edits/response_003.log index de2fe850abe..b515529ad1f 100644 --- a/tests/integration/mock/CodeActAgent/test_edits/response_003.log +++ b/tests/integration/mock/CodeActAgent/test_edits/response_003.log @@ -1,4 +1 @@ -The typos in the file `bad.txt` have been corrected. Let me save the changes and close the file: - -save bad.txt - +The typos in `bad.txt` have been fixed. The task is complete. If you need further assistance, feel free to ask! diff --git a/tests/integration/mock/CodeActAgent/test_edits/response_004.log b/tests/integration/mock/CodeActAgent/test_edits/response_004.log deleted file mode 100644 index fdb17e2c25c..00000000000 --- a/tests/integration/mock/CodeActAgent/test_edits/response_004.log +++ /dev/null @@ -1,4 +0,0 @@ -Apologies for the confusion. Let me save the changes to the file `bad.txt` for you: - -exit - diff --git a/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log b/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log index a2dc1960334..1e2108e22f6 100644 --- a/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log +++ b/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log @@ -228,15 +228,17 @@ ENVIRONMENT REMINDER: You have 98 turns left to complete the task. ---------- -Sure! Let me write 'hello world' to a text file named 'test.txt' in the '/workspace' directory without asking for confirmation: - -echo "hello world" > /workspace/test.txt - +Certainly! I will write the text 'hello world' to the file `/workspace/test.txt` using Jupyter IPython. + + +# Write 'hello world' to the specified text file +with open('/workspace/test.txt', 'w') as file: + file.write('hello world') + ---------- OBSERVATION: - -[Command -1 finished with exit code 0]] +[Code executed successfully with no output] ENVIRONMENT REMINDER: You have 97 turns left to complete the task. diff --git a/tests/integration/mock/CodeActAgent/test_ipython/response_001.log b/tests/integration/mock/CodeActAgent/test_ipython/response_001.log index 38c5b92c854..7525ffbf6d1 100644 --- a/tests/integration/mock/CodeActAgent/test_ipython/response_001.log +++ b/tests/integration/mock/CodeActAgent/test_ipython/response_001.log @@ -1,4 +1,6 @@ -Sure! Let me write 'hello world' to a text file named 'test.txt' in the '/workspace' directory without asking for confirmation: - -echo "hello world" > /workspace/test.txt +Certainly! I will write the text 'hello world' to the file `/workspace/test.txt` using Jupyter IPython. + +# Write 'hello world' to the specified text file +with open('/workspace/test.txt', 'w') as file: + file.write('hello world') diff --git a/tests/integration/mock/CodeActAgent/test_ipython/response_002.log b/tests/integration/mock/CodeActAgent/test_ipython/response_002.log index 30165356e1a..f0a4ebd49ad 100644 --- a/tests/integration/mock/CodeActAgent/test_ipython/response_002.log +++ b/tests/integration/mock/CodeActAgent/test_ipython/response_002.log @@ -1 +1 @@ -The text file 'test.txt' containing 'hello world' has been successfully created in the '/workspace' directory. Is there anything else you would like assistance with? +The text 'hello world' has been successfully written to `/workspace/test.txt`. If you need any further assistance, feel free to ask!