Author: Han-Elliot Phan
Email: hanelliotphan@gmail.com
Last update: March 1, 2025
This project is to input a file of code and translate it into another language that is optimized and executable.
This project uses the OpenAI's GPT-4o and the Anthropic's Claude 3.5 Sonnet models to ensure the executability of the translated code while still guaranteeing the optimization of the code.
For more information about the model, please read the following documentation:
First, determine the model you would like to use with the following options:
gpt-4o: OpenAI's GPT-4oclaude-3: Anthropic's Claude 3.5 Sonnet
Second, acquire the API keys for the supported models above and export the keys as below:
$ export OPENAI_API_KEY=<you OpenAI API key>
$ export ANTHROPIC_API_KEY=<you Anthropic API key>Next, install required packages via pip command
$ pip install -r requirements.txtFinally, run the main.py script to execute the software
$ python ./codeslator/src/main.py -f <your code filepath> -fl <your code language> -tl <language to translate your code to> -m <your desired model>where
-f / --file(required): The filepath of the code to translate.-fl / --from_language(required): The language to translate the code from (please see the supported languages below).-tl / --to_language(required): The language to translate the code to.-m / --model(optional): The model to use for the code translation. By default,gpt-4owill be used.
You will find the result code file under the ./files folder.
Supported Languages:
- C
- C++
- C#
- Dart
- Elixir
- Erlang
- Go/Golang
- Java
- JavaScript
- Kotlin
- PHP
- Python2/Python3
- Racket
- Ruby
- Rust
- Scala
- Swift
- TypeScript
I dedicate this hard-work commitment to myself, my mother, my best friend Ha-Phuong and those that have imprinted in my heart. I hope that I have made you all truly proud of me.