mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* Replace OpenDevin with OpenHands * Update CONTRIBUTING.md * Update README.md * Update README.md * update poetry lock; move opendevin folder to openhands * fix env var * revert image references in docs * revert permissions * revert permissions --------- Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
232 lines
6.3 KiB
Django/Jinja
232 lines
6.3 KiB
Django/Jinja
{% set DEFAULT_EXAMPLE %}
|
|
--- START OF EXAMPLE ---
|
|
|
|
USER: Create a list of numbers from 1 to 10, and display them in a web page at port 5000.
|
|
|
|
ASSISTANT:
|
|
Sure! Let me create a Python file `app.py`:
|
|
<execute_ipython>
|
|
create_file('app.py')
|
|
</execute_ipython>
|
|
|
|
USER:
|
|
OBSERVATION:
|
|
[File: /workspace/app.py (1 lines total)]
|
|
(this is the beginning of the file)
|
|
1|
|
|
(this is the end of the file)
|
|
[File app.py created.]
|
|
|
|
ASSISTANT:
|
|
Now I will write the Python code for starting a web server and save it to the file `app.py`:
|
|
<execute_ipython>
|
|
EDITED_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)"""
|
|
|
|
insert_content_at_line(
|
|
'app.py',
|
|
1,
|
|
EDITED_CODE,
|
|
)
|
|
</execute_ipython>
|
|
|
|
USER:
|
|
OBSERVATION:
|
|
(this is the beginning of the file)
|
|
1|from flask import Flask
|
|
2|app = Flask(__name__)
|
|
3|
|
|
4|@app.route('/')
|
|
5|def index():
|
|
6| numbers = list(range(1, 11))
|
|
7| return str(numbers)
|
|
8|
|
|
9|if __name__ == '__main__':
|
|
10| app.run(port=5000)
|
|
(this is the end of the file)
|
|
[File updated (edited at line 1). Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.]
|
|
|
|
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:
|
|
<execute_bash>
|
|
python3 app.py > server.log 2>&1 &
|
|
</execute_bash>
|
|
|
|
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:
|
|
<execute_bash>
|
|
cat server.log
|
|
</execute_bash>
|
|
|
|
USER:
|
|
OBSERVATION:
|
|
Traceback (most recent call last):
|
|
File "/workspace/app.py", line 2, in <module>
|
|
from flask import Flask
|
|
ModuleNotFoundError: No module named 'flask'
|
|
|
|
ASSISTANT:
|
|
It seems that Flask is not installed. Let me install Flask for you:
|
|
<execute_bash>
|
|
pip install flask
|
|
</execute_bash>
|
|
|
|
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/openhands/.local/lib/python3.10/site-packages (from flask) (3.1.3)
|
|
Requirement already satisfied: MarkupSafe>=2.0 in /home/openhands/.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:
|
|
<execute_bash>
|
|
python3 app.py > server.log 2>&1 &
|
|
</execute_bash>
|
|
|
|
USER:
|
|
OBSERVATION:
|
|
[1] 124
|
|
|
|
ASSISTANT:
|
|
Let me check the server log again:
|
|
<execute_bash>
|
|
cat server.log
|
|
</execute_bash>
|
|
|
|
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 browse the newly started server's homepage and show me the content.
|
|
|
|
ASSISTANT:
|
|
Sure! Let me browse the server's homepage at http://127.0.0.1:5000:
|
|
<execute_browse>
|
|
Get the content on "http://127.0.0.1:5000"
|
|
</execute_browse>
|
|
|
|
USER:
|
|
OBSERVATION:
|
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
|
|
ASSISTANT:
|
|
The content of the server's homepage is "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]". 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:
|
|
<execute_bash>
|
|
kill 124
|
|
</execute_bash>
|
|
|
|
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.
|
|
<execute_ipython>
|
|
open_file('app.py')
|
|
</execute_ipython>
|
|
|
|
USER:
|
|
[File: /workspace/app.py (10 lines total)]
|
|
(this is the beginning of the file)
|
|
1|from flask import Flask
|
|
2|app = Flask(__name__)
|
|
3|
|
|
4|@app.route('/')
|
|
5|def index():
|
|
6| numbers = list(range(1, 11))
|
|
7| return str(numbers)
|
|
8|
|
|
9|if __name__ == '__main__':
|
|
10| app.run(port=5000)
|
|
(this is the end of the file)
|
|
|
|
ASSISTANT:
|
|
I should edit the file to display the numbers in a table format. I should include correct indentation. Let me update the file:
|
|
<execute_ipython>
|
|
edit_file_by_replace(
|
|
'app.py',
|
|
to_replace=" return str(numbers)",
|
|
new_content=" return '<table>' + ''.join([f'<tr><td>{i}</td></tr>' for i in numbers]) + '</table>'",
|
|
)
|
|
</execute_ipython>
|
|
|
|
USER:
|
|
Observation:
|
|
[File: /workspace/app.py (10 lines total after edit)]
|
|
(this is the beginning of the file)
|
|
1|from flask import Flask
|
|
2|app = Flask(__name__)
|
|
3|
|
|
4|@app.route('/')
|
|
5|def index():
|
|
6| numbers = list(range(1, 11))
|
|
7| return '<table>' + ''.join([f'<tr><td>{i}</td></tr>' for i in numbers]) + '</table>'
|
|
8|
|
|
9|if __name__ == '__main__':
|
|
10| app.run(port=5000)
|
|
(this is the end of the file)
|
|
[File updated (edited at line 7). Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.]
|
|
|
|
ASSISTANT:
|
|
Running the updated file:
|
|
<execute_bash>
|
|
python3 app.py > server.log 2>&1 &
|
|
</execute_bash>
|
|
|
|
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. Let me know if you have any further requests!
|
|
<finish></finish>
|
|
|
|
--- END OF EXAMPLE ---
|
|
{% endset %}
|
|
Here is an example of how you can interact with the environment for task solving:
|
|
{{ DEFAULT_EXAMPLE }}
|
|
{% if micro_agent %}
|
|
--- BEGIN OF GUIDELINE ---
|
|
The following information may assist you in completing your task:
|
|
|
|
{{ micro_agent }}
|
|
--- END OF GUIDELINE ---
|
|
{% endif %}
|
|
|
|
NOW, LET'S START!
|