This repository extends the agent-zero project by adding a FastAPI interface that allows the usage of the agent via API, enabling its integration with other platforms.
The API provides a simple interface for sending tasks to the agent and receiving processed results. This integration makes it easier to interact with the agent remotely and allows for the agent's functionality to be accessed from various external systems.
-
Clone the repository:
git clone https://github.com/frdel/agent-zero.git cd agent-zero -
Update the repository with the new API files:
- Add
main_api.pyto the root directory. - Update the
requirements.txtto include the necessary dependencies for FastAPI and Uvicorn:fastapi==0.95.1 uvicorn==0.22.0
- Add
-
Install the dependencies: Make sure you have Python 3.8+ installed. Then, create a virtual environment and install the dependencies:
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt -
Run the FastAPI application: Start the FastAPI application using Uvicorn:
uvicorn main_api:app --host 0.0.0.0 --port 8000
This endpoint is used to execute a task using the configured Agent.
-
Request:
task(string): The task to be executed by the Agent.
-
Response:
status(string): The status of the task execution, typically "success".data(dict): The data containing the response from the Agent.
-
Example:
curl -X POST "http://localhost:8000/api/execute" -H "Content-Type: application/json" -d '{"task": "Your task here"}'
Response:
{ "status": "success", "data": { "response": "Task executed" } }
The AgentConfig class allows for various configurations, which are now accessible through the API:
- rate_limit_requests: Number of maximum requests per time window.
- rate_limit_input_tokens: Maximum input tokens allowed (set to 0 to disable).
- rate_limit_output_tokens: Maximum output tokens allowed (set to 0 to disable).
- rate_limit_seconds: Time window for rate limiting (in seconds).
- max_tool_response_length: Maximum length of tool responses.
- code_exec_docker_enabled: Enable or disable Docker for code execution.
- code_exec_ssh_enabled: Enable or disable SSH for code execution.
- Floating Output via API: The API will be enhanced in the future to support floating output, allowing for continuous streaming of responses from the agent as they are being processed.
To run tests, use the following command:
pytestThis project is licensed under the MIT License - see the LICENSE file for details.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
If you have any questions, feel free to open an issue or reach out directly.