This script generates Python functions based on user requirements using GPT-4 and automatically generates unit tests to validate the generated functions.
Ensure you have the following installed:
- Python 3.8+
- OpenAI Python SDK
Install required Python packages:
pip install openai requests
Clone the repository and navigate to the directory:
git clone [email protected]:robert-at-pretension-io/code_gen.git
cd your_repo
python -m venv venv
- Windows:
.\venv\Scripts\activate
- macOS and Linux:
source venv/bin/activate
pip install openai requests
You need to have an OpenAI API key set in the python script. Obtain an API key from OpenAI and replace the placeholder in the script with your key.
python script_generator.py
To run the script with a direct string input for requirements, use the following command:
python script_generator.py --requirements "Your high-level user requirements here."
To run the script with a file containing the requirements, create a text file with the requirements and use the following command:
python script_generator.py --file path/to/your/file_containing_requirements.txt