0xpayne /gpt-migrate

Easily migrate your codebase from one framework or language to another.

★ 6,966⑂ 499👁 52⑃ 16● 43▤ 0
PythonCreated 2023-06-25gpt-migrate.com
6,966
stars
+0+-1+-10
499
forks
52
watchers
16
prs
43
issues
0
releases
–
discussions

README

◐   GPT-Migrate   ◑

Easily migrate your codebase from one framework or language to another.










If you've ever faced the pain of migrating a codebase to a new framework or language, this project is for you.

https://user-images.githubusercontent.com/25165841/250232917-bcc99ce8-99b7-4e3d-a653-f89e163ed825.mp4

Migration is a costly, tedious, and non-trivial problem. Do not trust the current version blindly and please use responsibly. Please also be aware that costs can add up quickly as GPT-Migrate is designed to write (and potentially re-write) the entirety of a codebase.

However, with the collective brilliance of the OSS community and the current state of LLMs, it is also a very tractable problem.

 ⚡️ Usage

1. Install Docker and ensure that it's running. It's also recommended that you use at least GPT-4, preferably GPT-4-32k.

 📦 Installation using Poetry

1. Install Poetry by following the instructions on the official Poetry website.

2. Once Poetry is installed, navigate to the project directory and install the project dependencies using the following command:

bash
poetry install


This will create a virtual environment and install all the necessary dependencies in that environment.

2. Set your OpenRouter API key (default) and/or your OpenAI API key (to use the OpenAI API directly...in this case, set --model to gpt-4-32k or your desired model) and install the python requirements:

export OPENROUTER_API_KEY=
export OPENAI_API_KEY=
pip install -r requirements.txt

3. Run the main script with the target language you want to migrate to:

python main.py --targetlang nodejs

4. (Optional) If you'd like GPT-Migrate to validate the unit tests it creates against your app before it tests the migrated app with them, please have your existing app exposed and use the --sourceport flag. For executing this against the benchmark, open a separate terminal, navigate to the benchmarks/language-pair/source directory, and run python app.py after installing the requirements. It will expose on port 5000. Use this with the --sourceport flag.

By default, this script will execute the flask-nodejs benchmark. You can specify the language, source directory, and many other things using the options guide below.

 💡 Options

You can customize the behavior of GPT-Migrate by passing the following options to the main.py script:

- --model: The Large Language Model to be used. Default is "gpt-4-32k".

- --temperature: Temperature setting for the AI model. Default is 0.

- --sourcedir: Source directory containing the code to be migrated. Default is "../benchmarks/flask-nodejs/source".

- --sourcelang: Source language or framework of the code to be migrated. No default value.

- --sourceentry: Entrypoint filename relative to the source directory. For instance, this could be an app.py or main.py file for Python. Default is "app.py".

- --targetdir: Directory where the migrated code will live. Default is "../benchmarks/flask-nodejs/target".

- --targetlang: Ta

Snapshot: 2026-11-04T14:00:00Z · Data license Apache-2.0 · JSON