Skip to content

hanelliotphan/codeslator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codeslator - Translate Codes from One Programming Language to Another

Author: Han-Elliot Phan
Email: hanelliotphan@gmail.com

Last update: March 1, 2025

Brief Description

This project is to input a file of code and translate it into another language that is optimized and executable.

Architecture

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:

Instructions of Use

First, determine the model you would like to use with the following options:

  • gpt-4o: OpenAI's GPT-4o
  • claude-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.txt

Finally, 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-4o will 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

Dedication

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.

References

About

[2025] Codeslator - Translate code from one language to another language using Python and various LLMs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors