Skip to main content

No project description provided

Project description

Description

CodeMage is a tool that translates a source file written in one programming language into another language. The translation will be done by Large Language Model AI(such as ChatGPT)

Release 1.0.0

Features

1. Supported Languages: Javascript, Python, C++, Java
2. Default target Language is Python
3. Supported LLM model: openrouter, groq
4. Default LLM model is openrouter(sao10k/l3-euryale-70b)

Getting Started with PyPI

1. Download the package using PyPI

pip install code-mage

2. Create your API_KEY at openrouter Or Groq

It's free with sign-up. You can easily sign-up with your google account

3.a Set-up the API_KEY using Variable (option 1)

export API_KEY=YOUR-API-KEY

3.b Set-up with .toml file (option 2)

With this option, you can also set other tool options.

  • Start by creating a .codemage-config.toml in your home directory.
mkdir ~/.codemage-config.toml
  • Add the following information to the file:
model="groq" # if you wish to use OPEN ROUTER you can just delete this line
GROQ_API_KEY="<YOUR-GROQ-API-KEY>"
OPENROUTER_API_KEY="<YOUR-OPEN-ROUTER-API-KEY>"
language="java" # you can use any of the supported languages
stream=false # if you wish to get the output streamed, set it `true`
token_usage=false # if you wish to get token_usage info, set it `true`
output="result" # type any name for the output file without the extension

4. Run the tool

codemage <file-you-want-to-convert>
# For example,
codemage test.js

Getting Started by cloning the github repo

1. Install Python : https://www.python.org/downloads/


2. Install Poetry

curl -sSL https://install.python-poetry.org | python3 -

OR if you have pipx installed on your local machine, you can use the following commend

How to download pipx

pipx install poetry

3. Clone the repository

git clone https://github.com/gitdevjin/code-mage.git
cd code_mage

4. Install Poetry Package

poetry install

5. Create your API_KEY at openrouter Or Groq

It's free with sign-up. You can easily sign-up with your google account


6. Create .env file in the root directory and save the following:

OPENROUTER_API_KEY=your_open_router_api_key
GROQ_API_KEY=your_groq_api_key

Now you are ready to use the tool!


Usage

poetry run codemage <source_file>

Examples

You can try the tool with the included example files as followings:

poetry run codemage ./example/test.js -l python

You can also use the tool with multiple files:

poetry run codemage ./example/test.js ./example/sample.js -l java

You can select model with -m, --model <model_name> option:

poetry run codemage ./example/test.js -m groq -o result -t

You can stream out the result onto stdout with -s, --stream flag:

poetry run codemage ./example/test.js -s

Using TOML files

If you wish, you can specify all of your options in a TOML formatted configuration.

  • Start by creating a .codemage-config.toml in your home directory.
mkdir ~/.codemage-config.toml
  • Add the following information to the file:
model="groq" # if you wish to use OPEN ROUTER you can just delete this line
GROQ_API_KEY="<YOUR-GROQ-API-KEY>"
OPENROUTER_API_KEY="<YOUR-OPEN-ROUTER-API-KEY>"
language="java" # you can use any of the supported languages
stream=false/true
token_usage=false/true
output="result" # type any name for the output file without the extension
  • Run the command
poetry run codemage ./example/test.js

Options

-h, --help : display help message and exit

-l, --language : choose your target language (currently python, java, c++, and javascript are supported)

-o, --output : enter your output file name without extension

-m, --model : select LLM API model (currently openrouter, and groq are supported)

-v, --version : Show program's version number and exit

-t, --token-usage : Get information about token usage for the prompt and response

-s, --stream : Stream out the output into stdout

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_mage-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

code_mage-1.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file code_mage-1.0.0.tar.gz.

File metadata

  • Download URL: code_mage-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Darwin/23.6.0

File hashes

Hashes for code_mage-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8e7cef04217c0424fd721c16635bf4d3cc40796f368c05e3e8a58ae8b2fdc62f
MD5 685b06230be0dcd2504bcc19501c8767
BLAKE2b-256 01b67a2afcfb3bc3355ce81fea95892fc1c3228dd4047c775c2e10f88d52f64f

See more details on using hashes here.

File details

Details for the file code_mage-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: code_mage-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Darwin/23.6.0

File hashes

Hashes for code_mage-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 591f2a35ff69ff76c3e5938876cf300b4d438df483157dfcfdc0b8e83293e1ae
MD5 26baf86e4d877d67e20a0b8b50670493
BLAKE2b-256 c1db322b0c8f7bf644d86982bae846d2c9bb649d8b565a8c66ca07decb214906

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page