A Windows file management agent powered by Google Gemini AI and LangGraph. This intelligent agent helps you manage your files through natural language commands, using vector search to efficiently locate files and folders on your system.
FileManagerAgent is a personal project that combines the power of large language models with file system operations. It indexes your files into a vector database and allows you to interact with your file system through natural language conversations. The agent can:
- 🔍 Search for files and folders using semantic search
- 📁 Create, copy, move, and delete files and folders
- 🔐 Compute file hashes
- 📊 Count and list files in directories
- 🪟 Open folders in Windows Explorer
- ✅ Ask for confirmation before destructive operations
- Intelligent File Search: Uses vector embeddings to find files based on content and context
- Safe Operations: Always asks for confirmation before performing destructive actions
- Recursive Indexing: Automatically indexes folder structures for quick access
- Natural Language Interface: Interact with your file system using conversational commands
- Windows Integration: Direct integration with Windows Explorer
- Python 3.10 or higher
- UV package manager
- Google API Key (for Gemini AI)
- Windows OS (for Explorer integration)
-
Clone the repository
git clone https://github.com/chamesh2019/FileManagerAgent.git cd FileManagerAgent -
Install UV package manager (if not already installed)
# On Windows powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
-
Install dependencies using UV
uv sync
-
Set up environment variables
Create a
.envfile in the root directory:cp .env.example .env
Edit
.envand add your Google API key:GOOGLE_API_KEY=your_google_api_key_here
The project requires the following environment variable:
GOOGLE_API_KEY: Your Google API key for accessing Gemini AI services- Get your API key from Google AI Studio
Before using the agent, you need to index your file system. Edit src/db.py and uncomment the indexing section at the bottom:
if __name__ == "__main__":
# Option 1: Build separate documents per folder
build_index("C:\\Your\\Path", max_folders=10)
# Option 2: Build one big document with everything
build_single_document_index("C:\\Your\\Path")Then run:
uv run python src/db.pyNote: You can customize which folders to ignore by modifying the ignore_folders parameter in get_all_folders() function in src/db.py.
Run the main script to start the interactive file management agent:
uv run python main.pyOnce the agent is running, you can interact with it using natural language:
User: Find all my Python files in the Documents folder
User: Create a new folder called "Backups" in D:\
User: Move all .log files from C:\Temp to D:\Backups
User: Delete all temporary files in the Downloads folder
User: Show me files that contain "report" in their name
User: Open the folder where my tax documents are stored
The project supports two indexing strategies:
-
Multiple Documents (
build_index): Creates separate vector documents for each folder- Better for large file systems
- More granular search results
-
Single Document (
build_single_document_index): Creates one large document with all file information- Faster initial queries
- Better for smaller file systems
You can also index additional paths by using:
build_single_document_index(
root_path="D:/",
additional_paths=["C:/Users/username/Downloads"]
)FileManagerAgent/
├── src/
│ ├── file_manager_agent.py # Main agent logic and LangGraph setup
│ ├── db.py # Vector database and indexing functions
│ └── tools.py # File operation tools
├── main.py # Entry point for the application
├── pyproject.toml # Project dependencies and metadata
├── .env # Environment variables (not in repo)
├── .env.example # Example environment configuration
└── README.md # This file
The agent has access to the following tools:
search_with_context(context, k): Search for files/folders using semantic searchcopy_to_dest(src, dest): Copy files or folders to a destinationmove_to_dest(src, dest): Move files or folders to a destinationdelete_file(paths): Delete specified files or folderscreate_folder(folder_path): Create a new directoryget_file_count(): Get total number of indexed filesget_files_in_folder(folder_path): List all files in a folder (recursive)get_file_hash(path): Compute SHA256 hash of a fileopen_explorer(path): Open a folder in Windows Explorer
The agent implements several safety measures:
- Confirmation Required: Asks for explicit confirmation before any destructive operation
- Dry Run: Performs a search preview before moving or deleting files
- Clear Communication: Presents a plan before executing operations
- Error Handling: Gracefully handles errors and reports them to the user
This is a personal project, but contributions are welcome! If you'd like to contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code follows the existing style and includes appropriate documentation.
This project is licensed under the MIT License - see the LICENSE file for details.
Issue: "Module not found" errors
- Solution: Ensure you've run
uv syncto install all dependencies
Issue: "GOOGLE_API_KEY not found"
- Solution: Make sure you've created a
.envfile with your Google API key
Issue: No search results
- Solution: You need to index your files first by running
python src/db.py
Issue: Agent is slow
- Solution: Consider using the single document indexing method for smaller file systems
- Built with LangChain and LangGraph
- Powered by Google Gemini AI
- Uses ChromaDB for vector storage
This tool performs actual file system operations. Always:
- Back up important files before using
- Review the agent's plan before confirming operations
- Test with non-critical files first
- Be cautious with delete operations
The author is not responsible for any data loss or system issues that may occur from using this tool.