https://github.com/aliireza/cai
A Python program that automatically changes an input C/C++ code, ensuring compilability, correctness, and performance.
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 1 committers (100.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.4%) to scientific vocabulary
Repository
A Python program that automatically changes an input C/C++ code, ensuring compilability, correctness, and performance.
Basic Info
Statistics
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 4
- Releases: 0
Metadata Files
README.md
CodeAI (CAI): Code Optimization & Enhancement with AI 
CodeAI (CAI) is a Python program designed to optimize and enhance your C/C++ code. It leverages Large Language Models (LLMs) to automate code transformations, ensuring that the output code maintains its compilability, correctness, and performance. It can interact with Google BARD, OpenAI's GPT, and Microsoft Bing APIs.
BARD API is not currently supported in Sweden.
Key Features:
Automated Code Optimization: CAI utilizes AI to refactor and optimize your existing code, potentially leading to more efficient and performant output.
Compilability Assurance: The transformed code is ensured to be compilable.
Correctness Verification: CAI verifies the functional equivalence of the original and transformed codes.
Performance Measurement: The application benchmarks and compares the performance of the original and transformed code, ensuring that the changes have improved performance.
How to Use:
You can use the application by running the following command:
bash
cai-run -i <input_file> -o <output_file> -t <task> -l <language> -a <AI API> -c -comp <compiler>
Where:
<input_file>is the path to the original code.<output_file>is the path where the transformed code will be saved.<task>is the task you want the AI to perform on the code.<language>can be either C or C++.<AI API>is the name of the AI API to use; it can be BARD, GPT, or BING.<compiler>is the compiler to use for checking the compilability of the code, it can be gcc or g++. For example:
bash
cai-run -i examples/2sum.cpp -o test.cpp -t "Improve the performance of the code and use the same main function as the original code" -l C++ -a BARD -c -comp gcc
Alternatively, you can also run python cai.py.
Note that you need to export _BARD_API_KEY and OPENAI_API_KEY variables in your operating system in order to use Bard and OpenAI's GPT. You can run the following command or add it to .bashrc or .zshrc:
bash
export _BARD_API_KEY="bard_api_key"
export OPENAI_API_KEY="openai_api_key"
To use Bing, you should save the cookies in the bing_cookies_1.json. Check Get API Key section for more information.
Get API Key
Check the following links for different LLMs: - bardapi: https://github.com/dsdanielpark/Bard-API/blob/main/assets/bard_api.gif - openai: https://platform.openai.com/account/api-keys - EdgeGPT: https://github.com/acheong08/EdgeGPT#chatbot
Testing
You can test different classes by running the test units in the `tests/ folder, similar to the following command:
bash
python -m unittest test_ai_interface.py
TODO: Currently, they are not working properly.
How to Build
You can build a python package using the following command:
bash
python setup.py sdist bdist_wheel
or
bash
pip install .
License
CodeAI is released under the GPL 3.0 License.
Owner
- Name: Alireza Farshin
- Login: aliireza
- Kind: user
- Location: Stockholm, Sweden
- Company: KTH
- Website: https://www.kth.se/profile/farshin/
- Twitter: alirezafarshin
- Repositories: 5
- Profile: https://github.com/aliireza
Networked Systems Researcher | Doctoral Student
GitHub Events
Total
- Watch event: 3
Last Year
- Watch event: 3
Committers
Last synced: 12 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Alireza Farshin | f****n@k****e | 35 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 4
- Total pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: 2 minutes
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- aliireza (4)
Pull Request Authors
- aliireza (2)