codeflash/README.md

85 lines
4.5 KiB
Markdown
Raw Normal View History

2025-03-08 02:15:39 +00:00
![Codeflash-banner](https://i.postimg.cc/GmPRC52t/Codeflash-banner.png)
<p align="center">
<a href="https://github.com/codeflash-ai/codeflash">
<img src="https://img.shields.io/github/commit-activity/m/codeflash-ai/codeflash" alt="GitHub commit activity">
</a>
2025-08-17 23:32:42 +00:00
<a href="https://pypi.org/project/codeflash/"><img src="https://static.pepy.tech/badge/codeflash" alt="PyPI Downloads"></a>
2025-03-08 02:15:39 +00:00
<a href="https://pypi.org/project/codeflash/">
<img src="https://img.shields.io/pypi/v/codeflash?label=PyPI%20version" alt="PyPI Downloads">
</a>
</p>
2024-08-12 22:42:00 +00:00
2025-05-03 08:46:35 +00:00
[Codeflash](https://www.codeflash.ai) is a general purpose optimizer for Python that helps you improve the performance of your Python code while maintaining its correctness.
2025-03-08 03:22:52 +00:00
It uses advanced LLMs to generate multiple optimization ideas for your code, tests them to be correct and benchmarks them for performance. It then creates merge-ready pull requests containing the best optimization found, which you can review and merge.
2024-08-12 22:42:00 +00:00
2025-03-08 02:15:39 +00:00
How to use Codeflash -
- Optimize an entire existing codebase by running `codeflash --all`
- Automate optimizing all __future__ code you will write by installing Codeflash as a GitHub action.
2025-07-03 23:57:30 +00:00
- Optimize a Python workflow `python myscript.py` end-to-end by running `codeflash optimize myscript.py`
2024-08-13 08:36:44 +00:00
Codeflash is used by top engineering teams at **Pydantic** [(PRs Merged)](https://github.com/pydantic/pydantic/pulls?q=is%3Apr+author%3Amisrasaurabh1+is%3Amerged), **Roboflow** [(PRs Merged 1](https://github.com/roboflow/inference/issues?q=state%3Aclosed%20is%3Apr%20author%3Amisrasaurabh1%20is%3Amerged), [PRs Merged 2)](https://github.com/roboflow/inference/issues?q=state%3Amerged%20is%3Apr%20author%3Acodeflash-ai%5Bbot%5D), **Unstructured** [(PRs Merged 1](https://github.com/Unstructured-IO/unstructured/pulls?q=is%3Apr+Explanation+and+details+in%3Abody+is%3Amerged), [PRs Merged 2)](https://github.com/Unstructured-IO/unstructured-ingest/pulls?q=is%3Apr+Explanation+and+details+in%3Abody+is%3Amerged), **Langflow** [(PRs Merged)](https://github.com/langflow-ai/langflow/issues?q=state%3Aclosed%20is%3Apr%20author%3Amisrasaurabh1) and many others to ship performant, expert level code.
2025-03-08 02:15:39 +00:00
2025-07-03 23:57:30 +00:00
Codeflash is great at optimizing AI Agents, Computer Vision algorithms, PyTorch code, numerical code, backend code or anything else you might write with Python.
2024-08-12 22:42:00 +00:00
## Installation
To install Codeflash, run:
```
pip install codeflash
```
2025-03-08 02:15:39 +00:00
Add codeflash as a development time dependency if you are using package managers like uv or poetry.
2024-08-12 22:42:00 +00:00
## Quick Start
2025-03-08 02:15:39 +00:00
1. To configure Codeflash for a project, at the root directory of your project where the pyproject.toml file is located, run:
2024-08-12 22:42:00 +00:00
```
2025-03-08 02:15:39 +00:00
codeflash init
2024-08-12 22:42:00 +00:00
```
2025-03-08 02:15:39 +00:00
- It will ask you a few questions about your project like the location of your code and tests
- Ask you to generate an [API Key](https://app.codeflash.ai/app/apikeys) to access Codeflash's LLMs
- Install a [GitHub app](https://github.com/apps/codeflash-ai/installations/select_target) to open Pull Requests on GitHub.
- Ask if you want to setup a GitHub actions which will optimize all your future code.
- The codeflash config is then saved in the pyproject.toml file.
2024-08-12 22:42:00 +00:00
2025-03-08 02:15:39 +00:00
2. Optimize your entire codebase:
2024-08-12 22:42:00 +00:00
```
codeflash --all
```
2025-03-08 02:15:39 +00:00
This can take a while to run for a large codebase, but it will keep opening PRs as it finds optimizations.
2025-07-03 23:57:30 +00:00
3. Optimize a script:
```
codeflash optimize myscript.py
```
2025-03-08 02:15:39 +00:00
## Documentation
For detailed installation and usage instructions, visit our documentation at [docs.codeflash.ai](https://docs.codeflash.ai)
## Demo
2024-08-12 22:42:00 +00:00
2025-03-08 03:22:52 +00:00
- Optimizing the performance of new code for a Pull Request through GitHub Actions. This lets you ship code quickly while ensuring it remains performant.
2024-08-12 22:42:00 +00:00
2025-03-08 02:15:39 +00:00
https://github.com/user-attachments/assets/38f44f4e-be1c-4f84-8db9-63d5ee3e61e5
2024-08-12 22:42:00 +00:00
2025-08-06 18:32:18 +00:00
- Optiming a workflow end to end automatically with `codeflash optimize`
https://github.com/user-attachments/assets/355ba295-eb5a-453a-8968-7fb35c70d16c
2025-03-08 02:15:39 +00:00
## Support
2024-08-12 22:42:00 +00:00
2025-03-08 02:15:39 +00:00
Join our community for support and discussions. If you have any questions, feel free to reach out to us using one of the following methods:
2024-08-12 22:42:00 +00:00
2025-06-07 19:53:43 +00:00
- [Free live Installation Support](https://calendly.com/codeflash-saurabh/codeflash-setup)
2025-03-08 02:15:39 +00:00
- [Join our Discord](https://www.codeflash.ai/discord)
- [Follow us on Twitter](https://x.com/codeflashAI)
- [Follow us on Linkedin](https://www.linkedin.com/in/saurabh-misra/)
2024-08-12 22:42:00 +00:00
## License
Codeflash is licensed under the BSL-1.1 License. See the [LICENSE](https://github.com/codeflash-ai/codeflash/blob/main/codeflash/LICENSE) file for details.