https://github.com/giulianodigiuseppe/agentforfilecommands
A Python server that enables an LLM-based agent to perform operations on files and folders through a REST API.
https://github.com/giulianodigiuseppe/agentforfilecommands
agents langchain langgraph langgraph-python poetry python rag
Last synced: about 1 month ago
JSON representation
A Python server that enables an LLM-based agent to perform operations on files and folders through a REST API.
- Host: GitHub
- URL: https://github.com/giulianodigiuseppe/agentforfilecommands
- Owner: GiulianoDiGiuseppe
- License: gpl-3.0
- Created: 2024-10-28T17:27:59.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-03T16:51:19.000Z (7 months ago)
- Last Synced: 2025-04-08T01:42:27.728Z (about 1 month ago)
- Topics: agents, langchain, langgraph, langgraph-python, poetry, python, rag
- Language: Python
- Homepage:
- Size: 167 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AgentForFileCommands
LLM File System Agent: A Python server that enables an LLM-based agent to perform operations on files and folders through a REST API.
## Guide to Clone and Activate a Project with Poetry
* **Open Terminal or Command Prompt**:
* **Clone the Repository**:Run the following command, replacing `` with the actual URL of the repository:
```bash
git clone
cd
```
* **Install Dependencies**:Install all dependencies listed in `pyproject.toml`:
```bash
poetry install
```
* **Activate the Virtual Environment**:Activate the Poetry virtual environment:
```bash
poetry shell
```
## Run Code
To start the backend, use the following command:
```bash
poetry run python -m uvicorn src.app:app --reload
```Once the server is running, you can make POST requests to the following endpoint: **[http://0.0.0.0:8000/agent](http://0.0.0.0:8000/agents)** .
### Request Body
The body of the request should be formatted as follows:
```
{
"msg" : "I want to find all files in directory with txt extension. Then for those of these files which contain at least 1 word log, change their extension to .log"
}
```The result will be provided in the response from the last agent.
## Workflow
The system consists of a supervisor agent and four executor agents. The supervisor agent's code can be found in `src/agents/supervisor_agent.py`. Each executor agent has its own set of functions located in `src/tools`.
### Process Overview
1. The supervisor agent receives the initial message.
2. Based on the message, it decides which executor agent should handle the request or sends a "FINISH" message to conclude the workflow.
3. The supervisor monitors the responses from the executor agents and determines whether to continue or halt the process.This design ensures clear control over the execution flow and allows for effective management of the agents.
# Conclusions
* **Performance Comparison** : The **gpt4o-mini** often created infinite loops and failed to terminate, while **gpt4o** demonstrated significantly higher accuracy.
* **Improvement Suggestion** : Consider developing an additional agent to refine and clarify the outputs from the executor agents.
* **Prompt Optimization** : Further optimization of the supervisor agent's prompts could enhance its decision-making capabilities.
* **Agent Organization** : Initially, I tested integrating all tools into a single executor agent. However, I opted to separate the tools into multiple executor agents for better modularity and management.
* **Security Measures** : The current design lacks safeguards against potentially malicious requests and does not incorporate oversight before executing certain actions. Implementing such measures would significantly improve system integrity.
* **Functionality Improvements** : The functions developed are quite basic and present opportunities for optimization:
* **Enhanced File Search** : Implement recursive searching using functions like `os.walk` to traverse deeper file structures rather than limiting the search to the top level with `os.listdir`.
* **Path Optimization** : Improve the concatenation of file paths for efficiency and readability.## Future Work
1. **Self-Reflection** : Adopt **ReAct** to specify how the supervisor divides tasks step-by-step and communicate what is missing after each action of the executors, improving transparency in the workflow for Explainable AI. [Langchain create react agent](https://python.langchain.com/v0.1/docs/modules/agents/agent_types/react/)
2. **User Interaction** : Request permission for operations and utilize **Chain of Hindsight (CoH)** for improvements.
3. **Memory Evolution** : Update the operational context and apply **Algorithm Distillation (AD)** to learn from past stories.