AutoPackAI / beebot

An Autonomous AI Agent that works
MIT License
403 stars 71 forks source link

Add API via e2b SDK #3

Closed ValentaTomas closed 1 year ago

ValentaTomas commented 1 year ago

This PR adds an API to the beebot by using the e2b agent protocol SDK that implements the Agent Communication Protocol.


Here is a short preview how to use the API that I also added to the README

To start the server run:

python beebot/initiator/api.py

and then you can call the API using the following commands:

To create a task run:

curl --request POST \
  --url http://localhost:8000/agent/tasks \
  --header 'Content-Type: application/json' \
  --data '{
    "input": "Write '\''hello world'\'' to hi.txt"
}'

You will get a response like this:

{"input":"Write 'hello world' to hi.txt","task_id":"e6d768bb-4c50-4007-9853-aeffb46c77be","artifacts":[]}

Then to execute one step of the task copy the task_id you got from the previous request and run:

curl --request POST \
  --url http://localhost:8000/agent/tasks/<task-id>/steps

To get response like this:

{"output":{"plan":{"plan_text":"Plan:\n1. Check if the file \"hi.txt\" exists.\n2. If the file exists, check if the content of the file is \"hello world\".\n3. If the content is not \"hello world\", rewrite the file with the correct content.\n4. If the file does not exist, create a new file named \"hi.txt\" with the content \"hello world\".\n\nThe first action to be taken is to check if the file \"hi.txt\" exists."},"decision":{"tool_name":"get_more_tools","tool_args":{"desired_functionality":"check_file_existence"}},"observation":{"response":"Exception: 'functions'","error_reason":"","success":true},"model_object":{"__data__":{"plan":{"plan_text":"Plan:\n1. Check if the file \"hi.txt\" exists.\n2. If the file exists, check if the content of the file is \"hello world\".\n3. If the content is not \"hello world\", rewrite the file with the correct content.\n4. If the file does not exist, create a new file named \"hi.txt\" with the content \"hello world\".\n\nThe first action to be taken is to check if the file \"hi.txt\" exists."},"decision":{"tool_name":"get_more_tools","tool_args":{"desired_functionality":"check_file_existence"}},"observation":{"response":"Exception: 'functions'","error_reason":"","success":true},"id":1},"_dirty":[],"__rel__":{}}},"artifacts":[],"is_last":false,"input":null,"task_id":"94b36d67-7e3d-4031-80ac-cb0ac1c3c242","step_id":"8ff8ba39-2c3e-4246-8086-fbd2a897240b"}
ValentaTomas commented 1 year ago

I also added beautifulsoup4 and psutil missing dependencies.

erik-megarad commented 1 year ago

Oh hell yeah, thank you!

erik-megarad commented 1 year ago

Merged in https://github.com/AutoPackAI/beebot/commit/0139cb16fc8577d9d8672d5873eca96ab1426a23