Code2LLM is a tool for preparing codebases for analysis by language models (LLMs). It extracts code from a specified directory, chunks it into manageable sizes, and formats it for LLM input. This tool provides both a command-line interface (CLI) and a web interface to interact with the extracted code.
- Code Extraction: Extracts and formats code from a directory.
- Chunking: Splits code into chunks of a specified size to fit LLM input constraints.
- Web Interface: View, copy, and interact with extracted code chunks.
- CLI Support: Initialize and run the extraction process from the command line.
- Customizable Exclusions: Define patterns to exclude files and directories from processing.
You can install Code2LLM using pipx
:
pipx install git+https://github.com/adhilroshan/code2llm.git
pipx
is a tool for installing and running Python applications in isolated environments. It ensures that Code2LLM and its dependencies don't interfere with other Python projects on your system.
-
Initialize Exclusion Patterns:
Initialize default exclusion patterns and add additional patterns if needed:
code2llm init --additional-excludes '*.tmp' 'test_dir/'
-
Start Extraction and Web Server:
Run the extraction process and start the Flask web server:
code2llm --directory /path/to/your/code --max-chars 3000 --port 2277
--directory
: Base directory to scan.--max-chars
: Maximum number of characters per chunk (default is 3000).--port
: Port number for the Flask app (default is 2277).
After starting the web server, access the web interface at:
http://localhost:2277
Here you can view and interact with the extracted code chunks.
We welcome contributions to improve Code2LLM. Please follow the guidelines below:
- Report Issues: If you encounter any bugs or issues, please open an issue on the GitHub Issues page.
- Feature Requests: If you have suggestions for new features, feel free to open a feature request.
- Feedback: For general feedback or questions, you can reach out via email or open a discussion in the GitHub Discussions section.
-
Fork the Repository: Fork the repository on GitHub and clone it to your local machine.
-
Create a Branch: Create a new branch for your changes:
git checkout -b feature-branch
-
Make Changes: Implement your changes or fixes.
-
Write Tests: Ensure your changes are covered by tests.
-
Commit Changes: Commit your changes with a descriptive message:
git add . git commit -m "Describe your changes"
-
Push to GitHub: Push your changes to your forked repository:
git push origin feature-branch
-
Create a Pull Request: Open a pull request from your forked repository to the main repository, describing your changes and why they should be merged.
-
Review Process: Participate in the review process and make any necessary adjustments based on feedback.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, please contact Adhil Roshan.
Check out our blog post for more insights and detailed information about Code2LLM!