COBOL Enhancer is a Python-based tool designed to optimize COBOL code. Using the power of AI, it refactors COBOL code to be more efficient and error-free while maintaining the original functionality and structure of the code.
- Python 3.9+
- Poetry for dependency management
- Direnv for environment variable management
- Clone the repository from GitHub:
git clone https://github.com/thibaudbrg/cobol_enhancer.git
- Navigate to the cloned repository directory:
cd cobol_enhancer
- Install dependencies using Poetry:
poetry install
- Create a
.env
file by copying the.env.example
template:cp .env.example .env
- Fill in your Langchain and OpenAI API keys in the
.env
file. - Load the environment variables:
eval "$(direnv hook bash)" direnv allow
- Start the Langchain server:
langchain serve
- Run the tests for the
cobol_enhancer
workflow:poetry add pytest --group dev poetry run python -m pytest packages/ubp-cobol/tests/test_chain.py::test_workflow -s
- To display a side-by-side comparison of the old and new COBOL code:
poetry run python -m pytest packages/ubp-cobol/tests/test_chain.py::test_print_workflow -s
The cobol_enhancer
application is designed to iteratively improve a directory of COBOL code files using an AI-based language model (LLM). The process flow is as follows:
-
Input: The program takes a directory containing COBOL code files as its input.
-
Enhancement: Each COBOL file is passed through the LLM, which refactors the code to improve efficiency, readability, and adherence to modern coding practices while preserving the original functionality and structure.
-
Human Review: After an enhancement is suggested by the LLM, a human reviewer is prompted to either accept the changes or provide specific feedback for further refinement.
-
Iterative Generation: Based on the human reviewer's feedback, the LLM re-attempts to enhance the code. This loop continues until the reviewer is satisfied with the enhancements.
-
Completion: Once the code is approved by the human reviewer, it is deemed finalized, and the program proceeds to the next COBOL file in the directory.
Below is a visual representation of the workflow within cobol_enhancer
:
Distributed under the MIT License. See LICENSE
for more information.