Skip to content

Commit 4cc34f1

Browse files
committed
Added mkdocs and minor fixes.
1 parent d97e547 commit 4cc34f1

File tree

13 files changed

+237
-22
lines changed

13 files changed

+237
-22
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Deploy MkDocs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Checkout the repository
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
# Set up Python
18+
- name: Setup Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
23+
# Install dependencies
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install mkdocs mkdocs-material mkdocstrings-python
28+
29+
# Build the MkDocs site
30+
- name: Build and Publish MkDocs site
31+
run: mkdocs gh-deploy

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
ReadmeReady welcomes contributions from the community.
44

5-
# Questions and Reporting Issues
5+
# Asking Questions and Reporting Issues
66

77
Have a question? Have you identified a reproducible problem in ReadmeReady? Have a feature request? We want to hear about it!
88

9-
Submit a bug report or feature request on [GitHub Issues](https://github.com/souradipp76/ReadMeReady/issues).
9+
Ask a question, submit a bug report or feature request on [GitHub Issues](https://github.com/souradipp76/ReadMeReady/issues).
1010

1111
# How to develop on this project
1212

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Auto-generate code documentation in Markdown format in seconds.
1010
Automated documentation of programming source code is a challenging task with significant practical and scientific implications for the developer community. ReadmeReady is a large language model (LLM)-based application that developers can use as a support tool to generate basic documentation for any publicly available or custom repository. Over the last decade, several research have been done on generating documentation for source code using neural network architectures. With the recent advancements in LLM technology, some open-source applications have been developed to address this problem. However, these applications typically rely on the OpenAI APIs, which incur substantial financial costs, particularly for large repositories. Moreover, none of these open-source applications offer a fine-tuned model or features to enable users to fine-tune custom LLMs. Additionally, finding suitable data for fine-tuning is often challenging. Our application addresses these issues.
1111

1212
## Installation
13+
14+
ReadmeReady is available only on Linux/Windows.
15+
16+
### Dependencies
17+
18+
Please follow the installation guide [here](https://pypi.org/project/python-magic/) to install `python-magic`.
19+
1320
### Install it from PyPI
1421

1522
The simplest way to install ReadmeReady and its dependencies is from PyPI with pip, Python's preferred package installer.

docs/index.md

Lines changed: 119 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,123 @@
1-
# Welcome to ReadMeReady
1+
# ReadmeReady
22

3-
## Commands
3+
Auto-generate code documentation in Markdown format in seconds.
44

5-
* `readme_ready` - Start generating README documentation.
5+
## What is ReadmeReady?
66

7-
## Project layout
7+
Automated documentation of programming source code is a challenging task with significant practical and scientific implications for the developer community. ReadmeReady is a large language model (LLM)-based application that developers can use as a support tool to generate basic documentation for any publicly available or custom repository. Over the last decade, several research have been done on generating documentation for source code using neural network architectures. With the recent advancements in LLM technology, some open-source applications have been developed to address this problem. However, these applications typically rely on the OpenAI APIs, which incur substantial financial costs, particularly for large repositories. Moreover, none of these open-source applications offer a fine-tuned model or features to enable users to fine-tune custom LLMs. Additionally, finding suitable data for fine-tuning is often challenging. Our application addresses these issues.
88

9-
mkdocs.yml # The configuration file.
10-
docs/
11-
index.md # The documentation homepage.
9+
## Installation
10+
11+
ReadmeReady is available only on Linux/Windows.
12+
13+
### Dependencies
14+
15+
Please follow the installation guide [here](https://pypi.org/project/python-magic/) to install `python-magic`.
16+
17+
### Install it from PyPI
18+
19+
The simplest way to install ReadmeReady and its dependencies is from PyPI with pip, Python's preferred package installer.
20+
21+
```bash
22+
pip install readme_ready
23+
```
24+
25+
In order to upgrade ReadmeReady to the latest version, use pip as follows.
26+
27+
```bash
28+
$ pip install -U readme_ready
29+
```
30+
31+
### Install it from source
32+
33+
You can also install ReadmeReady from source as follows.
34+
35+
```bash
36+
$ git clone https://github.com/souradipp76/ReadMeReady.git
37+
$ cd ReadMeReady
38+
$ make install
39+
```
40+
41+
To create a virtual environment before installing ReadmeReady, you can use the command:
42+
```bash
43+
$ make virtualenv
44+
$ source .venv/bin/activate
45+
```
46+
47+
## Usage
48+
49+
### Initialize
50+
```bash
51+
$ export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
52+
$ export HF_TOKEN=<YOUR_HUGGINGFACE_TOKEN>
53+
```
54+
55+
Set `OPENAI_API_KEY=dummy` to use only open-source models.
56+
57+
### Command-Line
58+
59+
```bash
60+
$ python -m readme_ready
61+
#or
62+
$ readme_ready
63+
```
64+
65+
### In Code
66+
67+
```py
68+
from readme_ready.query import query
69+
from readme_ready.index import index
70+
from readme_ready.types import (
71+
AutodocReadmeConfig,
72+
AutodocRepoConfig,
73+
AutodocUserConfig,
74+
LLMModels,
75+
)
76+
77+
model = LLMModels.LLAMA2_7B_CHAT_GPTQ # Choose model from supported models
78+
79+
repo_config = AutodocRepoConfig (
80+
name = "<NAME>", # Replace <NAME>
81+
root = "<PROJECT_ROOT>", # Replace <PROJECT_ROOT>
82+
repository_url = "<PROJECT_URL>", # Replace <PROJECT_URL>
83+
output = "<OUTPUT_DIR>", # Replace <OUTPUT_DIR>
84+
llms = [model],
85+
peft_model_path = "<PEFT_MODEL_NAME_OR_PATH>", # Replace <PEFT_MODEL_NAME_OR_PATH>
86+
ignore = [
87+
".*",
88+
"*package-lock.json",
89+
"*package.json",
90+
"node_modules",
91+
"*dist*",
92+
"*build*",
93+
"*test*",
94+
"*.svg",
95+
"*.md",
96+
"*.mdx",
97+
"*.toml"
98+
],
99+
file_prompt = "",
100+
folder_prompt = "",
101+
chat_prompt = "",
102+
content_type = "docs",
103+
target_audience = "smart developer",
104+
link_hosted = True,
105+
priority = None,
106+
max_concurrent_calls = 50,
107+
add_questions = False,
108+
device = "auto", # Select device "cpu" or "auto"
109+
)
110+
111+
user_config = AutodocUserConfig(
112+
llms = [model]
113+
)
114+
115+
readme_config = AutodocReadmeConfig(
116+
headings = "Description,Requirements,Installation,Usage,Contributing,License"
117+
)
118+
119+
index.index(repo_config)
120+
query.generate_readme(repo_config, user_config, readme_config)
121+
```
122+
123+
Run the sample script in the `examples/example.py` to see a typical code usage.

docs/reference.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# API Reference
2+
3+
::: readme_ready.index.index
4+
handler: python
5+
options:
6+
members:
7+
- index
8+
show_root_heading: true
9+
show_source: false
10+
11+
::: readme_ready.index.create_vector_store
12+
handler: python
13+
options:
14+
members:
15+
- create_vector_store
16+
show_root_heading: true
17+
show_source: false
18+
19+
::: readme_ready.index.process_repository
20+
handler: python
21+
options:
22+
members:
23+
- process_repository
24+
show_root_heading: true
25+
show_source: false
26+
27+
::: readme_ready.query.query
28+
handler: python
29+
options:
30+
members:
31+
- query
32+
- generate_readme
33+
show_root_heading: true
34+
show_source: false
35+
36+
::: readme_ready.query.create_chat_chain
37+
handler: python
38+
options:
39+
members:
40+
- make_qa_chain
41+
- make_readme_chain
42+
show_root_heading: true
43+
show_source: false

mkdocs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
site_name: ReadMeReady
1+
site_name: ReadmeReady
22
theme: readthedocs
3+
plugins:
4+
- search
5+
- mkdocstrings

readme_ready/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def url_validator(x):
7474
LLMModels.CODELLAMA_13B_INSTRUCT_HF.value,
7575
LLMModels.GOOGLE_GEMMA_2B_INSTRUCT.value,
7676
LLMModels.GOOGLE_GEMMA_7B_INSTRUCT.value,
77+
LLMModels.GOOGLE_CODEGEMMA_2B.value,
78+
LLMModels.GOOGLE_CODEGEMMA_7B_INSTRUCT.value,
7779
],
7880
default=LLMModels.TINYLLAMA_1p1B_CHAT_GGUF.value,
7981
).ask()
@@ -113,6 +115,10 @@ def url_validator(x):
113115
model = LLMModels.GOOGLE_GEMMA_2B_INSTRUCT
114116
case LLMModels.GOOGLE_GEMMA_7B_INSTRUCT.value:
115117
model = LLMModels.GOOGLE_GEMMA_7B_INSTRUCT
118+
case LLMModels.GOOGLE_CODEGEMMA_2B.value:
119+
model = LLMModels.GOOGLE_CODEGEMMA_2B
120+
case LLMModels.GOOGLE_CODEGEMMA_7B_INSTRUCT.value:
121+
model = LLMModels.GOOGLE_CODEGEMMA_7B_INSTRUCT
116122
case _:
117123
model = LLMModels.LLAMA2_7B_CHAT_HF
118124
print("Initialization Complete.\n")

readme_ready/query/query.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ def generate_readme(
128128
)
129129
try:
130130
response = chain.invoke({"input": question})
131-
print("\n\nMarkdown:\n")
132-
print(markdown(response["answer"]))
131+
# print("\n\nMarkdown:\n")
132+
# print(markdown(response["answer"]))
133133
file.write(markdown(response["answer"]))
134134
except RuntimeError as error:
135135
print(f"Something went wrong: {error}")
136136
traceback.print_exc()
137+
138+
print(f"README generated at {readme_path}")

readme_ready/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class LLMModels(str, Enum):
1515
GPT4 = "gpt-4"
1616
GPT432k = "gpt-4-32k"
1717
TINYLLAMA_1p1B_CHAT_GGUF = "TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF"
18+
GOOGLE_GEMMA_2B_INSTRUCT_GGUF = "bartowski/gemma-2-2b-it-GGUF"
1819
LLAMA2_7B_CHAT_GPTQ = "TheBloke/Llama-2-7B-Chat-GPTQ"
1920
LLAMA2_13B_CHAT_GPTQ = "TheBloke/Llama-2-13B-Chat-GPTQ"
2021
CODELLAMA_7B_INSTRUCT_GPTQ = "TheBloke/CodeLlama-7B-Instruct-GPTQ"
@@ -25,9 +26,8 @@ class LLMModels(str, Enum):
2526
CODELLAMA_13B_INSTRUCT_HF = "meta-llama/CodeLlama-13b-Instruct-hf"
2627
GOOGLE_GEMMA_2B_INSTRUCT = "google/gemma-2b-it"
2728
GOOGLE_GEMMA_7B_INSTRUCT = "google/gemma-7b-it"
28-
GOOGLE_CODEGEMMA_2B_INSTRUCT = "google/codegemma-2b-it"
29+
GOOGLE_CODEGEMMA_2B = "google/codegemma-2b"
2930
GOOGLE_CODEGEMMA_7B_INSTRUCT = "google/codegemma-7b-it"
30-
GOOGLE_GEMMA_2B_INSTRUCT_GGUF = "bartowski/gemma-2-2b-it-GGUF"
3131

3232

3333
class Priority(str, Enum):

readme_ready/utils/llm_utils.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def get_gemma_chat_model(model_name: str, streaming=False, model_kwargs=None):
2222
gguf_file = model_kwargs["gguf_file"]
2323
_ = hf_hub_download(model_name, gguf_file)
2424
tokenizer = get_tokenizer(model_name, gguf_file)
25-
if (
26-
sys.platform == "linux" or sys.platform == "linux2"
27-
) and "gptq" not in model_name.lower():
25+
if sys.platform != "darwin" and "gptq" not in model_name.lower():
2826
from transformers import BitsAndBytesConfig
2927

3028
bnb_config = BitsAndBytesConfig(
@@ -57,6 +55,10 @@ def get_gemma_chat_model(model_name: str, streaming=False, model_kwargs=None):
5755
PEFT_MODEL = model_kwargs["peft_model_path"]
5856
model = PeftModel.from_pretrained(model, PEFT_MODEL)
5957

58+
print(
59+
f"Memory footprint: {model.get_memory_footprint() / 1024 **3:.2f} GB."
60+
)
61+
6062
return HuggingFacePipeline(
6163
pipeline=pipeline(
6264
"text-generation",
@@ -78,9 +80,7 @@ def get_llama_chat_model(model_name: str, streaming=False, model_kwargs=None):
7880
_ = hf_hub_download(model_name, gguf_file)
7981
tokenizer = get_tokenizer(model_name, gguf_file)
8082
tokenizer.pad_token = tokenizer.eos_token
81-
if (
82-
sys.platform == "linux" or sys.platform == "linux2"
83-
) and "gptq" not in model_name.lower():
83+
if sys.platform != "darwin" and "gptq" not in model_name.lower():
8484
from transformers import BitsAndBytesConfig
8585

8686
bnb_config = BitsAndBytesConfig(
@@ -112,6 +112,10 @@ def get_llama_chat_model(model_name: str, streaming=False, model_kwargs=None):
112112
PEFT_MODEL = model_kwargs["peft_model"]
113113
model = PeftModel.from_pretrained(model, PEFT_MODEL)
114114

115+
print(
116+
f"Memory footprint: {model.get_memory_footprint() / 1024 **3:.2f} GB."
117+
)
118+
115119
return HuggingFacePipeline(
116120
pipeline=pipeline(
117121
"text-generation",

0 commit comments

Comments
 (0)