https://github.com/aliireza/cai

A Python program that automatically changes an input C/C++ code, ensuring compilability, correctness, and performance.

https://github.com/aliireza/cai

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
Last synced: 10 months ago · JSON representation

Repository

A Python program that automatically changes an input C/C++ code, ensuring compilability, correctness, and performance.

Basic Info
  • Host: GitHub
  • Owner: aliireza
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 53.7 KB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 4
  • Releases: 0
Created about 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme License

README.md

CodeAI (CAI): Code Optimization & Enhancement with AI Python Application

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

Networked Systems Researcher | Doctoral Student

GitHub Events

Total
  • Watch event: 3
Last Year
  • Watch event: 3

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 35
  • Total Committers: 1
  • Avg Commits per committer: 35.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Alireza Farshin f****n@k****e 35
Committer Domains (Top 20 + Academic)
kth.se: 1

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)
Top Labels
Issue Labels
enhancement (2) bug (1) documentation (1)
Pull Request Labels