OpenHands
OpenHands copied to clipboard
First pass at a control loop
This is very rough, but it works for simple examples.
See README.md for usage, and TODO.md for what's next.
Sample usage:
mkdir -p `pwd`/workspace
docker build -t control-loop .
docker run \
-e OPENAI_API_KEY=$OPENAI_API_KEY \
-v `pwd`/workspace:/workspace control-loop python /app/main.py /workspace \
"write a bash script that prints 'hello world'"
Wow @rbren , this is great!
Could you elaborate a little bit on how you're expecting this to interface with the frontend?
For instance, the user enters a chat request into the frontend, end then what happens?
Thanks!
Here's what I think the user flow should be:
- User loads a repo, or starts the app in the dir they want to work in
- We start a docker container with that directory mounted
- User types in a prompt into the chat window
- Control loop kicks off
- At each turn of the control loop:
- We send a message back to the web client (e.g. via websocket, or the client polls the backend)
- For edit/read actions, put a chat message that says "editing $FILE..." or "reading $FILE...", and show the file being read/edited in the file pane
- for browse actions, put a chat message that says "browsing $URL..." and show the page in the browser pane
- for think actions, put the thought into the chat directly
- for
run
actions, put a chat message that says "running $COMMAND", and show the command being run - for finish actions, put a friendly "Done" message
At any point, as the agent is working, the user should be able to type in a message to give it a hint or redirect it. That message will be added to short-term memory
nice work. i'm gonna impl a multi-llm interface for langchain
I've added a couple simple test cases in ./agent/regression/cases
, so you can see how it performs for some basic tasks.
FWIW--I fully expect (and hope!) for this code to get deleted and replaced with something better. But getting this merged would at least give the frontend and backend folks something to code against.
@rbren Thank you for your contribution! I will review the code, please give me some time.