AI Readme Generator reads a Github repository and suggest a README.md file based on that code using Langchain and OpenAI's GPT4.
Main functionalities of this project are listed below:
- The script clones a given repo from its url or local path, and fetches file content and metadata.
- The content and metadata fetched are then passed to GPT-4 model to generate the README suggestion.
- It can filter out files based on their extensions.
- The script can also work in debug mode. In debug mode, the script provides more detailed output logs.
Please note, in order to use this script, you will need the OPENAI_API_KEY
.
To use the script from command line, please use the following template and fill in the relevant details:
pipenv run python -m ai_readme_generator.main -h
usage: main.py [-h] [-u REPO_URL] [-b BRANCH] [-e FILE_EXT_FILTER] [-m {gpt-3.5-turbo,gpt-3.5-turbo-16k,gpt-4,gpt-4-32k}]
[-t TEMPERATURE] [-D DEBUG]
AI README Generator
options:
-h, --help show this help message and exit
-u REPO_URL, --repo_url REPO_URL
Git repository URL or local path
-b BRANCH, --branch BRANCH
Repository branch name. Default: main
-e FILE_EXT_FILTER, --file_ext_filter FILE_EXT_FILTER
Filter the files based on their extensions. For instance: 'py,md', 'js,jsx' or 'php'
-m {gpt-3.5-turbo,gpt-3.5-turbo-16k,gpt-4,gpt-4-32k}, --model {gpt-3.5-turbo,gpt-3.5-turbo-16k,gpt-4,gpt-4-32k}
GPT model. Default: gpt-3.5-turbo-16k
-t TEMPERATURE, --temperature TEMPERATURE
Temperature for the GPT model. Default: 0.7
-D DEBUG, --debug DEBUG
Show debug information
-
REPO_URL
: repository URL for which you want to generate README. It is a mandatory parameter. This can be also a local path, so repo won't be cloned in the/tmp
directory. -
BRANCH
: It is the branch of the repo from which you want to generate README. This is an optional parameter, themain
branch will be used by default if no branch is specified. -
FILE_EXT_FILTER
: It is to filter the files based on their extensions. For instance:py,md
,js,jsx
orphp
. This is an optional parameter, all files will be used if no filter is given.
For instance,
pipenv run python -m ai_readme_generator.main -u https://github.com/bard/ai-assistant -b main -e py,md
Following Python libraries are required:
- git (Repo)
- langchain.document_loaders (GitLoader)
- openai
- os, sys
- dotenv (load_dotenv)
- pprint
- Clone the repo:
git clone https://github.com/tomkat-cr/ai_readme_generator
- Change the directory:
cd ai_readme_generator
- Start the virtual environment:
python3 -m venv venv
source venv/bin/activate
- Install requirements:
pip install -r requirements.txt
- Create the .env file:
cp .env-example .env
vi .env
- Configure parameters:
OPENAI_API_KEY=sk-XXXXXX
DEBUG=0
- Run it (it'll ask for git repo URL/local path and branch):
pipenv run python -m ai_readme_generator.main
- or run it with repo URL/path and branch
pipenv run python -m ai_readme_generator.main -u https://github.com/tomkat-cr/ai_readme_generator -b main
Please be aware that script will not attempt to delete or modify any files or directories outside of its designated working area.
Enjoy exploring the project!
Feel free to submit pull requests create issues or spread the word.
Technologies used in the project:
- python3
- openai
- langchain
- gitpython
- pipenv
- make
This project is licensed under the GNU 2.0