autodocgenerator 0.9.0.0__tar.gz → 0.9.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autodocgenerator-0.9.0.2/PKG-INFO +981 -0
- autodocgenerator-0.9.0.2/README.md +901 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/engine/config/config.py +30 -23
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/manage.py +1 -4
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/preprocessor/spliter.py +11 -9
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/pyproject.toml +1 -1
- autodocgenerator-0.9.0.0/PKG-INFO +0 -699
- autodocgenerator-0.9.0.0/README.md +0 -619
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/__init__.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/auto_runner/config_reader.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/auto_runner/run_file.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/config/config.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/engine/__init__.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/engine/exceptions.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/engine/models/gpt_model.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/engine/models/model.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/factory/__init__.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/factory/base_factory.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/factory/modules/general_modules.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/factory/modules/intro.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/postprocessor/custom_intro.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/postprocessor/sorting.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/preprocessor/code_mix.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/preprocessor/compressor.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/preprocessor/settings.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/ui/__init__.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/ui/logging.py +0 -0
- {autodocgenerator-0.9.0.0 → autodocgenerator-0.9.0.2}/autodocgenerator/ui/progress_base.py +0 -0
|
@@ -0,0 +1,981 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autodocgenerator
|
|
3
|
+
Version: 0.9.0.2
|
|
4
|
+
Summary: This Project helps you to create docs for your projects
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: dima-on
|
|
7
|
+
Author-email: sinica911@gmail.com
|
|
8
|
+
Requires-Python: >=3.11,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Dist: CacheControl (==0.14.4)
|
|
16
|
+
Requires-Dist: Pygments (==2.19.2)
|
|
17
|
+
Requires-Dist: RapidFuzz (==3.14.3)
|
|
18
|
+
Requires-Dist: annotated-types (==0.7.0)
|
|
19
|
+
Requires-Dist: anyio (==4.12.1)
|
|
20
|
+
Requires-Dist: certifi (==2026.1.4)
|
|
21
|
+
Requires-Dist: charset-normalizer (==3.4.4)
|
|
22
|
+
Requires-Dist: cleo (==2.1.0)
|
|
23
|
+
Requires-Dist: colorama (==0.4.6)
|
|
24
|
+
Requires-Dist: crashtest (==0.4.1)
|
|
25
|
+
Requires-Dist: distlib (==0.4.0)
|
|
26
|
+
Requires-Dist: distro (==1.9.0)
|
|
27
|
+
Requires-Dist: dulwich (==0.25.2)
|
|
28
|
+
Requires-Dist: fastjsonschema (==2.21.2)
|
|
29
|
+
Requires-Dist: filelock (==3.20.3)
|
|
30
|
+
Requires-Dist: findpython (==0.7.1)
|
|
31
|
+
Requires-Dist: google-auth (==2.47.0)
|
|
32
|
+
Requires-Dist: google-genai (==1.56.0)
|
|
33
|
+
Requires-Dist: groq (==1.0.0)
|
|
34
|
+
Requires-Dist: h11 (==0.16.0)
|
|
35
|
+
Requires-Dist: httpcore (==1.0.9)
|
|
36
|
+
Requires-Dist: httpx (==0.28.1)
|
|
37
|
+
Requires-Dist: idna (==3.11)
|
|
38
|
+
Requires-Dist: installer (==0.7.0)
|
|
39
|
+
Requires-Dist: jaraco.classes (==3.4.0)
|
|
40
|
+
Requires-Dist: jaraco.context (==6.1.0)
|
|
41
|
+
Requires-Dist: jaraco.functools (==4.4.0)
|
|
42
|
+
Requires-Dist: jiter (==0.12.0)
|
|
43
|
+
Requires-Dist: keyring (==25.7.0)
|
|
44
|
+
Requires-Dist: markdown-it-py (==4.0.0)
|
|
45
|
+
Requires-Dist: mdurl (==0.1.2)
|
|
46
|
+
Requires-Dist: more-itertools (==10.8.0)
|
|
47
|
+
Requires-Dist: msgpack (==1.1.2)
|
|
48
|
+
Requires-Dist: openai (==2.14.0)
|
|
49
|
+
Requires-Dist: packaging (==25.0)
|
|
50
|
+
Requires-Dist: pbs-installer (==2026.1.14)
|
|
51
|
+
Requires-Dist: pkginfo (==1.12.1.2)
|
|
52
|
+
Requires-Dist: platformdirs (==4.5.1)
|
|
53
|
+
Requires-Dist: pyasn1 (==0.6.1)
|
|
54
|
+
Requires-Dist: pyasn1_modules (==0.4.2)
|
|
55
|
+
Requires-Dist: pydantic (==2.12.5)
|
|
56
|
+
Requires-Dist: pydantic_core (==2.41.5)
|
|
57
|
+
Requires-Dist: pyproject_hooks (==1.2.0)
|
|
58
|
+
Requires-Dist: python-dotenv (==1.2.1)
|
|
59
|
+
Requires-Dist: pywin32-ctypes (==0.2.3)
|
|
60
|
+
Requires-Dist: pyyaml (==6.0.3)
|
|
61
|
+
Requires-Dist: requests (==2.32.5)
|
|
62
|
+
Requires-Dist: requests-toolbelt (==1.0.0)
|
|
63
|
+
Requires-Dist: rich (==14.2.0)
|
|
64
|
+
Requires-Dist: rich_progress (==0.4.0)
|
|
65
|
+
Requires-Dist: rsa (==4.9.1)
|
|
66
|
+
Requires-Dist: shellingham (==1.5.4)
|
|
67
|
+
Requires-Dist: sniffio (==1.3.1)
|
|
68
|
+
Requires-Dist: tenacity (==9.1.2)
|
|
69
|
+
Requires-Dist: tomlkit (==0.14.0)
|
|
70
|
+
Requires-Dist: tqdm (==4.67.1)
|
|
71
|
+
Requires-Dist: trove-classifiers (==2026.1.14.14)
|
|
72
|
+
Requires-Dist: typing-inspection (==0.4.2)
|
|
73
|
+
Requires-Dist: typing_extensions (==4.15.0)
|
|
74
|
+
Requires-Dist: urllib3 (==2.6.2)
|
|
75
|
+
Requires-Dist: virtualenv (==20.36.1)
|
|
76
|
+
Requires-Dist: websockets (==15.0.1)
|
|
77
|
+
Requires-Dist: zstandard (==0.25.0)
|
|
78
|
+
Description-Content-Type: text/markdown
|
|
79
|
+
|
|
80
|
+
## Executive Navigation Tree
|
|
81
|
+
- 📦 Installation & Setup
|
|
82
|
+
- [Install Workflow Powershell Unix](#install-workflow-powershell-unix)
|
|
83
|
+
- [Install Scripts Behaviour](#install‑scripts‑behaviour)
|
|
84
|
+
- 📄 Documentation Generation
|
|
85
|
+
- [Autodocfile Structure](#autodocfile-structure)
|
|
86
|
+
- [Doc Factory](#doc-factory)
|
|
87
|
+
- [Gen Doc Function](#gen-doc-function)
|
|
88
|
+
- [Write Docs By Parts](#write-docs-by-parts)
|
|
89
|
+
- [Async Write Docs By Parts](#async-write-docs-by-parts)
|
|
90
|
+
- [Gen Doc Parts](#gen-doc-parts)
|
|
91
|
+
- [Async Gen Doc Parts](#async-gen-doc-parts)
|
|
92
|
+
- [Generate Descriptions](#generate-descriptions)
|
|
93
|
+
- [Intro Links](#intro-links)
|
|
94
|
+
- [Intro Text](#intro-text)
|
|
95
|
+
- 🛠️ Module & Manager Architecture
|
|
96
|
+
- [Manager Class Usage](#manager-class-usage)
|
|
97
|
+
- [Manager Core](#manager-core)
|
|
98
|
+
- [Module Initializer](#module-initializer)
|
|
99
|
+
- [Base Module](#base-module)
|
|
100
|
+
- [Custom Module](#custom-module)
|
|
101
|
+
- [Custom Module NoCtx](#custom-module-noctx)
|
|
102
|
+
- [Custom Intro Processor](#custom-intro-processor)
|
|
103
|
+
- [Code Mix Class](#code-mix-class)
|
|
104
|
+
- [Logging Module Structure](#logging‑module‑structure)
|
|
105
|
+
- [Progress Module Structure](#progress‑module‑structure)
|
|
106
|
+
- 📊 Metadata & Configuration
|
|
107
|
+
- [Visible Interactions](#visible-interactions)
|
|
108
|
+
- [Logic Flow](#logic-flow)
|
|
109
|
+
- [Metadata Logic Flow](#metadata-logic-flow)
|
|
110
|
+
- [Metadata Functional Role](#metadata-functional-role)
|
|
111
|
+
- [Metadata Visible Interactions](#metadata-visible-interactions)
|
|
112
|
+
- [Metadata Data Contract](#metadata-data-contract)
|
|
113
|
+
- [Get Order](#get-order)
|
|
114
|
+
- [Data Contract](#data-contract)
|
|
115
|
+
- [Structure Settings](#structure-settings)
|
|
116
|
+
- [Project Settings](#project-settings)
|
|
117
|
+
- [Project Metadata Definition](#project-metadata-definition)
|
|
118
|
+
- [CONTENT_DESCRIPTION](#CONTENT_DESCRIPTION)
|
|
119
|
+
- [Read Config Function](#read-config-function)
|
|
120
|
+
- 🔧 Processing & Compression
|
|
121
|
+
- [Extract Links From Start](#extract-links-from-start)
|
|
122
|
+
- [Split Text By Anchors](#split-text-by-anchors)
|
|
123
|
+
- [Split Data](#split-data)
|
|
124
|
+
- [Split Data Loop Adjustments](#split-data-loop-adjustments)
|
|
125
|
+
- [Split Data Chunk Assembly](#split-data-chunk-assembly)
|
|
126
|
+
- [Compress](#compress)
|
|
127
|
+
- [Compress And Compare](#compress-and-compare)
|
|
128
|
+
- [Async Compress](#async-compress)
|
|
129
|
+
- [Async Compress And Compare](#async-compress-and-compare)
|
|
130
|
+
- [Compress To One](#compress-to-one)
|
|
131
|
+
- 🤖 AI Model Integration
|
|
132
|
+
- [Async GPT Model](#async-gpt-model)
|
|
133
|
+
- [GPT Model](#gpt-model)
|
|
134
|
+
- [Model Base](#model-base)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
<a name="install-workflow-powershell-unix"></a>
|
|
139
|
+
To set up the automated installation for both Windows PowerShell and Unix‑like shells, follow these steps in your GitHub Actions workflow:
|
|
140
|
+
|
|
141
|
+
### 1. PowerShell bootstrap (Windows agents)
|
|
142
|
+
Use **Invoke‑RestMethod** (`irm`) to download the PowerShell bootstrap script directly from the repository and execute it in the same pipeline:
|
|
143
|
+
|
|
144
|
+
```yaml
|
|
145
|
+
- name: Run PowerShell installer
|
|
146
|
+
if: runner.os == 'Windows'
|
|
147
|
+
shell: pwsh
|
|
148
|
+
run: |
|
|
149
|
+
irm raw.githubusercontent.com/Drag-GameStudio/ADG/main/installer.ps1 | iex
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
* `irm` fetches the script content.
|
|
153
|
+
* The pipeline pipes the content to `iex` (Invoke‑Expression) so the script runs immediately without writing a temporary file.
|
|
154
|
+
|
|
155
|
+
### 2. Shell bootstrap (Linux/macOS agents)
|
|
156
|
+
Use **curl** to fetch the Unix shell bootstrap script and pipe it to `bash`:
|
|
157
|
+
|
|
158
|
+
```yaml
|
|
159
|
+
- name: Run Unix installer
|
|
160
|
+
if: runner.os != 'Windows'
|
|
161
|
+
run: |
|
|
162
|
+
curl -sSL raw.githubusercontent.com/Drag-GameStudio/ADG/main/installer.sh | bash
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
* `-sSL` makes curl silent, follows redirects, and ensures TLS is used.
|
|
166
|
+
* The script is streamed directly into `bash` for execution.
|
|
167
|
+
|
|
168
|
+
### 3. Add required secret for the installer
|
|
169
|
+
The installer expects an API key to be provided via a secret environment variable. Define a secret named **GROCK_API_KEY** in the repository settings (Settings → Secrets → Actions) with the key you obtained from the Grock documentation.
|
|
170
|
+
|
|
171
|
+
```yaml
|
|
172
|
+
env:
|
|
173
|
+
GROCK_API_KEY: ${{ secrets.GROCK_API_KEY }}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 4. Complete workflow example
|
|
177
|
+
|
|
178
|
+
```yaml
|
|
179
|
+
name: Install ADG
|
|
180
|
+
|
|
181
|
+
on:
|
|
182
|
+
push:
|
|
183
|
+
branches: [ main ]
|
|
184
|
+
|
|
185
|
+
jobs:
|
|
186
|
+
install:
|
|
187
|
+
runs-on: ${{ matrix.os }}
|
|
188
|
+
strategy:
|
|
189
|
+
matrix:
|
|
190
|
+
os: [ windows-latest, ubuntu-latest, macos-latest ]
|
|
191
|
+
|
|
192
|
+
steps:
|
|
193
|
+
- uses: actions/checkout@v3
|
|
194
|
+
|
|
195
|
+
# Provide the API key to all steps
|
|
196
|
+
- name: Set API key
|
|
197
|
+
env:
|
|
198
|
+
GROCK_API_KEY: ${{ secrets.GROCK_API_KEY }}
|
|
199
|
+
|
|
200
|
+
# Windows PowerShell installer
|
|
201
|
+
- name: Run PowerShell installer
|
|
202
|
+
if: runner.os == 'Windows'
|
|
203
|
+
shell: pwsh
|
|
204
|
+
run: |
|
|
205
|
+
irm raw.githubusercontent.com/Drag-GameStudio/ADG/main/installer.ps1 | iex
|
|
206
|
+
|
|
207
|
+
# Linux/macOS shell installer
|
|
208
|
+
- name: Run Unix installer
|
|
209
|
+
if: runner.os != 'Windows'
|
|
210
|
+
run: |
|
|
211
|
+
curl -sSL raw.githubusercontent.com/Drag-GameStudio/ADG/main/installer.sh | bash
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Key points to remember**
|
|
215
|
+
|
|
216
|
+
* Use the appropriate command (`irm` + `iex` for PowerShell, `curl` + `bash` for Unix) to pull and execute the remote bootstrap script in one step.
|
|
217
|
+
* Protect the API key by storing it as a secret (`GROCK_API_KEY`) and referencing it via `${{ secrets.GROCK_API_KEY }}`.
|
|
218
|
+
* The workflow runs on all major runner OSes, selecting the correct installer automatically.
|
|
219
|
+
<a name="install‑scripts‑behaviour"></a>
|
|
220
|
+
## Installation Scripts (`install.ps1` / `install.sh`)
|
|
221
|
+
|
|
222
|
+
| Script | Action | Result |
|
|
223
|
+
|--------|--------|--------|
|
|
224
|
+
| `install.ps1` | Creates `.github/workflows` directory; writes a GitHub Actions workflow YAML (`autodoc.yml`); writes `autodocconfig.yml` containing current folder name and language `"en"` | PowerShell‑based setup for Windows |
|
|
225
|
+
| `install.sh` | Same as above using Bash; uses `mkdir -p`; writes the workflow YAML with escaped `${{…}}`; creates `autodocconfig.yml` with `project_name` derived from `pwd` | Cross‑platform (Linux/macOS) setup |
|
|
226
|
+
|
|
227
|
+
Both scripts end with a success message printed to the console.
|
|
228
|
+
<a name="autodocfile-structure"></a>
|
|
229
|
+
The autodoc configuration file is a YAML document with the following top‑level keys and sub‑options:
|
|
230
|
+
|
|
231
|
+
**project_name** – a string that defines the name of the project.
|
|
232
|
+
|
|
233
|
+
**language** – a string indicating the language for generated documentation (e.g., “en”).
|
|
234
|
+
|
|
235
|
+
**build_settings** – a map containing:
|
|
236
|
+
- **save_logs** – boolean, whether to keep generation logs.
|
|
237
|
+
- **log_level** – integer, level of detail for logging.
|
|
238
|
+
|
|
239
|
+
**structure_settings** – a map that controls documentation layout:
|
|
240
|
+
- **include_intro_links** – boolean, include introductory hyperlinks.
|
|
241
|
+
- **include_order** – boolean, preserve the order of sections.
|
|
242
|
+
- **max_doc_part_size** – integer, maximum size (in characters) for each documentation part.
|
|
243
|
+
|
|
244
|
+
**project_additional_info** – a map for extra project metadata, for example:
|
|
245
|
+
- **global idea** – a descriptive string about the project’s purpose.
|
|
246
|
+
|
|
247
|
+
**custom_descriptions** – a list of strings, each providing custom prompts or explanations that will be incorporated into the generated documentation.
|
|
248
|
+
|
|
249
|
+
When writing the file, use proper YAML indentation, include the keys above, and set values according to the desired behavior. No other options are shown in the provided context.
|
|
250
|
+
<a name="doc-factory"></a>
|
|
251
|
+
## `DocFactory` – Orchestrator of Module Pipeline
|
|
252
|
+
|
|
253
|
+
**Responsibility** – Executes a sequence of `BaseModule` instances, concatenates their outputs, logs progress, and updates a `BaseProgress` sub‑task.
|
|
254
|
+
|
|
255
|
+
**Logic Flow**
|
|
256
|
+
1. `__init__(*modules)` stores modules list and creates `BaseLogger`.
|
|
257
|
+
2. `generate_doc(info, model, progress)`
|
|
258
|
+
- Calls `progress.create_new_subtask` with module count.
|
|
259
|
+
- Iterates over `self.modules`:
|
|
260
|
+
• `module.generate(info, model)` → `module_result`.
|
|
261
|
+
• Appends `module_result` and two newlines to `output`.
|
|
262
|
+
• Logs module completion (`InfoLog`).
|
|
263
|
+
• Logs raw module output at level 2.
|
|
264
|
+
• Calls `progress.update_task()`.
|
|
265
|
+
- After loop, `progress.remove_subtask()`.
|
|
266
|
+
- Returns the aggregated `output`.
|
|
267
|
+
|
|
268
|
+
**Data Contract**
|
|
269
|
+
|
|
270
|
+
| Entity | Type | Role | Notes |
|
|
271
|
+
|--------|------|------|-------|
|
|
272
|
+
| `modules` | `list[BaseModule]` | Generation steps | Provided at construction |
|
|
273
|
+
| `logger` | `BaseLogger` | Central logger | Uses `InfoLog`/`ErrorLog` etc. |
|
|
274
|
+
| `info` | `dict` | Shared context for all modules | Passed unchanged |
|
|
275
|
+
| `model` | `Model` | LLM interface for modules | Same instance reused |
|
|
276
|
+
| `progress` | `BaseProgress` | Progress UI controller | Must support sub‑task API |
|
|
277
|
+
| Return | `str` | Full documentation string | Newlines separate parts |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
<a name="gen-doc-function"></a>
|
|
281
|
+
## `gen_doc` – Orchestrator of Documentation Generation
|
|
282
|
+
|
|
283
|
+
**Responsibility** – Creates the AI models, configures a `Manager`, drives the full generation cycle, and returns the final markdown document.
|
|
284
|
+
|
|
285
|
+
**Logic Flow**
|
|
286
|
+
1. Instantiate `GPTModel` (sync) and `AsyncGPTModel` (async) with `API_KEY`.
|
|
287
|
+
2. Initialise `Manager` with `project_path`, the `Config`, both models, and a `ConsoleGtiHubProgress` bar.
|
|
288
|
+
3. Sequential calls on `manager`:
|
|
289
|
+
- `generate_code_file()` – extracts source files.
|
|
290
|
+
- `generete_doc_parts(max_symbols=structure_settings.max_doc_part_size)` – splits docs.
|
|
291
|
+
- `factory_generate_doc(DocFactory(*custom_modules))` – applies custom modules.
|
|
292
|
+
- Conditional `order_doc()` if `include_order` is true.
|
|
293
|
+
- Conditional `factory_generate_doc(DocFactory(IntroLinks()))` if `include_intro_links` is true.
|
|
294
|
+
- `clear_cache()` – removes temporary artefacts.
|
|
295
|
+
4. Retrieve the assembled output via `manager.read_file_by_file_key("output_doc")`.
|
|
296
|
+
|
|
297
|
+
**Data Contract**
|
|
298
|
+
|
|
299
|
+
| Entity | Type | Role | Notes |
|
|
300
|
+
|--------|------|------|-------|
|
|
301
|
+
| `project_path` | `str` | Filesystem root of the target project | Passed unchanged to `Manager`. |
|
|
302
|
+
| `config` | `Config` | Global configuration (language, ignores, etc.) | Produced by `read_config`. |
|
|
303
|
+
| `custom_modules` | `list[CustomModule]` | Extension points for description generation | May be empty. |
|
|
304
|
+
| `structure_settings` | `StructureSettings` | Controls chunk size & optional sections | Influences `generete_doc_parts` and ordering. |
|
|
305
|
+
| Return value | `str` | Final assembled documentation | Read from manager’s internal cache. |
|
|
306
|
+
|
|
307
|
+
> **Warning** – The function assumes `API_KEY` is defined in `autodocgenerator.engine.config.config`; missing or invalid keys will raise at model construction time.
|
|
308
|
+
<a name="write-docs-by-parts"></a>
|
|
309
|
+
## write_docs_by_parts Interaction
|
|
310
|
+
|
|
311
|
+
| Entity | Type | Role | Notes |
|
|
312
|
+
|--------|------|------|-------|
|
|
313
|
+
| `part` | `str` | Code fragment to document | Supplied by caller |
|
|
314
|
+
| `model` | `Model` | LLM interface | Provides `get_answer_without_history` |
|
|
315
|
+
| `project_settings` | `ProjectSettings` | Holds `prompt` for global context | Inserted into system messages |
|
|
316
|
+
| `prev_info` | `str | None` | Prior generated doc snippet | May be included in prompt |
|
|
317
|
+
| `language` | `str` | Desired output language | Defaults `"en"` |
|
|
318
|
+
| Return | `str` | Generated documentation snippet | Stripped of surrounding markdown fences if present |
|
|
319
|
+
|
|
320
|
+
The function builds a prompt (system messages + optional previous info + user part), calls the model, trims leading/trailing ``````` fences, logs the result, and returns the cleaned answer.
|
|
321
|
+
<a name="async-write-docs-by-parts"></a>
|
|
322
|
+
## async_write_docs_by_parts Async Generation
|
|
323
|
+
|
|
324
|
+
Mirrors `write_docs_by_parts` but **awaits** `async_model.get_answer_without_history` within a semaphore‑protected block. It also accepts an optional `update_progress` callback invoked after the LLM call.
|
|
325
|
+
<a name="gen-doc-parts"></a>
|
|
326
|
+
## gen_doc_parts Orchestration
|
|
327
|
+
|
|
328
|
+
| Entity | Type | Role |
|
|
329
|
+
|--------|------|------|
|
|
330
|
+
| `full_code_mix` | `str` | Whole source to split |
|
|
331
|
+
| `max_symbols` | `int` | Size limit for chunks |
|
|
332
|
+
| `model` | `Model` | Synchronous LLM |
|
|
333
|
+
| `project_settings` | `ProjectSettings` | Global prompt |
|
|
334
|
+
| `language` | `str` | Output language |
|
|
335
|
+
| `progress_bar` | `BaseProgress` | Visual progress tracking |
|
|
336
|
+
| Return | `str` | Concatenated documentation |
|
|
337
|
+
|
|
338
|
+
Calls `split_data`, iterates over each chunk, invokes `write_docs_by_parts`, appends results, trims the tail to keep a 3000‑character context window, updates the progress bar, and finally returns the aggregated documentation.
|
|
339
|
+
<a name="async-gen-doc-parts"></a>
|
|
340
|
+
## async_gen_doc_parts Asynchronous Orchestration
|
|
341
|
+
|
|
342
|
+
Functions identically to `gen_doc_parts` but creates tasks that run `async_write_docs_by_parts` concurrently (semaphore limit = 4) and gathers their results. Progress updates are performed via the supplied `update_progress` lambda. The final concatenated documentation is returned.
|
|
343
|
+
<a name="generate-descriptions"></a>
|
|
344
|
+
## `generate_discribtions_for_code` – LLM‑Driven Doc Generation
|
|
345
|
+
|
|
346
|
+
**Role** – Sends each code snippet to a model with a strict “no‑hallucination” prompt, collects the responses.
|
|
347
|
+
|
|
348
|
+
| Entity | Type | Role | Notes |
|
|
349
|
+
|--------|------|------|------- |
|
|
350
|
+
| `data` | `list[str]` | Input | Code snippets. |
|
|
351
|
+
| `model` | `Model` | Input | Must support `get_answer_without_history`. |
|
|
352
|
+
| `project_settings` | `ProjectSettings` | — | Not used directly. |
|
|
353
|
+
| `progress_bar` | `BaseProgress` | Internal | Per‑snippet progress. |
|
|
354
|
+
| `describtions` | `list[str]` | Output | Model‑generated documentation strings. |
|
|
355
|
+
|
|
356
|
+
**Flow**
|
|
357
|
+
1. Create sub‑task sized to `len(data)`.
|
|
358
|
+
2. For each snippet, build a prompt that forces the model to produce a self‑contained description.
|
|
359
|
+
3. Call `model.get_answer_without_history`.
|
|
360
|
+
4. Append the answer to `describtions`.
|
|
361
|
+
5. Update progress, remove sub‑task, return the list.
|
|
362
|
+
<a name="manager-core"></a>
|
|
363
|
+
## `Manager` – Core Coordination Component
|
|
364
|
+
|
|
365
|
+
**Responsibility** – Orchestrates the end‑to‑end documentation pipeline: prepares cache, reads/writes intermediate files, drives code‑mix creation, part‑wise generation, factory‑based enrichment, and final ordering.
|
|
366
|
+
|
|
367
|
+
**Visible Interactions**
|
|
368
|
+
- Imports preprocessing utilities (`split_data`, `gen_doc_parts`, `CodeMix`), post‑processing helpers (`get_introdaction`, `get_all_html_links`, `get_links_intro`), model abstractions (`Model`, `AsyncModel`), and UI logging/progress classes.
|
|
369
|
+
- Persists files under `self.CACHE_FOLDER_NAME` using paths from `self.FILE_NAMES`.
|
|
370
|
+
- Delegates heavy work to external functions (`gen_doc_parts`, `DocFactory.generate_doc`, `split_text_by_anchors`, `get_order`).
|
|
371
|
+
|
|
372
|
+
**Logic Flow**
|
|
373
|
+
1. **`__init__(project_directory, config, sync_model=None, async_model=None, progress_bar=BaseProgress())`**
|
|
374
|
+
- Stores arguments, creates a logger with file target `logs`.
|
|
375
|
+
- Ensures cache directory exists (`.auto_doc_cache`).
|
|
376
|
+
|
|
377
|
+
2. **`read_file_by_file_key(file_key)`** → opens `self.get_file_path(file_key)` and returns its UTF‑8 content.
|
|
378
|
+
|
|
379
|
+
3. **`get_file_path(file_key)`** → builds `os.path.join(project_directory, CACHE_FOLDER_NAME, FILE_NAMES[file_key])`.
|
|
380
|
+
|
|
381
|
+
4. **`generate_code_file()`** →
|
|
382
|
+
- Instantiates `CodeMix` with `project_directory` and `config.ignore_files`.
|
|
383
|
+
- Calls `cm.build_repo_content` to write the code mix to `code_mix.txt`.
|
|
384
|
+
|
|
385
|
+
5. **`generete_doc_parts(max_symbols=5_000)`** →
|
|
386
|
+
- Reads full code mix, logs start, invokes `gen_doc_parts(full_code_mix, max_symbols, sync_model, config.get_project_settings(), config.language, progress_bar)`.
|
|
387
|
+
- Writes the returned markdown to `output_doc.md`.
|
|
388
|
+
|
|
389
|
+
6. **`factory_generate_doc(doc_factory)`** →
|
|
390
|
+
- Reads current doc and code mix, builds `info` dict (`language`, `full_data`, `code_mix`).
|
|
391
|
+
- Calls `doc_factory.generate_doc(info, sync_model, progress_bar)`.
|
|
392
|
+
- Prepends the new fragment to existing doc and writes back.
|
|
393
|
+
|
|
394
|
+
7. **`order_doc()`** →
|
|
395
|
+
- Splits current doc by anchors via `split_text_by_anchors`, orders sections with `get_order`, and rewrites the file.
|
|
396
|
+
|
|
397
|
+
8. **`clear_cache()`** → deletes `logs` file when `config.pbc.save_logs` is `False`.
|
|
398
|
+
|
|
399
|
+
**Data Contract**
|
|
400
|
+
|
|
401
|
+
| Method | Input(s) | Output | Side Effects |
|
|
402
|
+
|--------|----------|--------|--------------|
|
|
403
|
+
| `__init__` | `project_directory: str`, `config: Config`, optional models, `progress_bar` | `Manager` instance | Creates cache folder, sets up logger |
|
|
404
|
+
| `read_file_by_file_key` | `file_key: str` (key in `FILE_NAMES`) | `str` file content | None |
|
|
405
|
+
| `get_file_path` | `file_key: str` | `str` absolute path | None |
|
|
406
|
+
| `generate_code_file` | – | – | Writes `code_mix.txt` |
|
|
407
|
+
| `generete_doc_parts` | `max_symbols: int` | – | Writes `output_doc.md` |
|
|
408
|
+
| `factory_generate_doc` | `doc_factory: DocFactory` | – | Updates `output_doc.md` |
|
|
409
|
+
| `order_doc` | – | – | Rewrites `output_doc.md` |
|
|
410
|
+
| `clear_cache` | – | – | May delete `report.txt` |
|
|
411
|
+
|
|
412
|
+
> **Warning** – All file operations assume the referenced keys exist in `FILE_NAMES`; missing keys raise `KeyError`.
|
|
413
|
+
<a name="module-initializer"></a>
|
|
414
|
+
## Package Initializer – Logger Bootstrap
|
|
415
|
+
|
|
416
|
+
**Functional role**
|
|
417
|
+
The `autodocgenerator/__init__.py` module bootstraps the **AutoDocGenerator** package by:
|
|
418
|
+
|
|
419
|
+
1. Emitting a simple runtime banner (`print("ADG")`).
|
|
420
|
+
2. Importing the core logging classes from `autodocgenerator.ui.logging`.
|
|
421
|
+
3. Instantiating a global `logger` object (`BaseLogger`).
|
|
422
|
+
4. Attaching a concrete logging template (`BaseLoggerTemplate`) to the logger.
|
|
423
|
+
|
|
424
|
+
This makes a ready‑to‑use `logger` available to every submodule that imports `autodocgenerator`.
|
|
425
|
+
<a name="base-module"></a>
|
|
426
|
+
## `BaseModule` – Abstract Generation Unit
|
|
427
|
+
|
|
428
|
+
**Responsibility** – Serves as the contract for all documentation modules; subclasses must implement `generate(info: dict, model: Model)`.
|
|
429
|
+
|
|
430
|
+
**Logic Flow**
|
|
431
|
+
1. Inherits from `ABC`.
|
|
432
|
+
2. Defines abstract `generate`.
|
|
433
|
+
3. Provides a no‑op `__init__`.
|
|
434
|
+
|
|
435
|
+
**Data Contract**
|
|
436
|
+
|
|
437
|
+
| Entity | Type | Role | Notes |
|
|
438
|
+
|--------|------|------|-------|
|
|
439
|
+
| `info` | `dict` | Input data for generation | Expected keys are module‑specific |
|
|
440
|
+
| `model` | `Model` | LLM wrapper used by modules | Imported from `engine.models.model` |
|
|
441
|
+
| Return | `str` | Generated documentation fragment | Must be a string |
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
<a name="custom-module"></a>
|
|
445
|
+
## `CustomModule` – Context‑Aware Description Generator
|
|
446
|
+
|
|
447
|
+
**Responsibility** – Produces a custom description using the code mix (split to ≤ 5000 symbols) and language.
|
|
448
|
+
|
|
449
|
+
**Logic Flow**
|
|
450
|
+
1. Stores `discription` (sic) on init.
|
|
451
|
+
2. `generate(info, model)` →
|
|
452
|
+
- Calls `split_data(info.get("code_mix"), max_symbols=5000)`.
|
|
453
|
+
- Passes result, `model`, stored `discription`, and `info.get("language")` to `generete_custom_discription`.
|
|
454
|
+
- Returns the obtained string.
|
|
455
|
+
|
|
456
|
+
**Data Contract**
|
|
457
|
+
|
|
458
|
+
| Entity | Type | Role | Notes |
|
|
459
|
+
|--------|------|------|-------|
|
|
460
|
+
| `discription` | `str` | Template text for generation | Set via constructor |
|
|
461
|
+
| `info["code_mix"]` | `str` | Source code fragment | May be absent → `None` |
|
|
462
|
+
| `info["language"]` | `str` | Target language for output | Optional |
|
|
463
|
+
| Return | `str` | Generated custom description | From `generete_custom_discription` |
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
<a name="custom-module-noctx"></a>
|
|
467
|
+
## `CustomModuleWithOutContext` – Context‑Free Description Generator
|
|
468
|
+
|
|
469
|
+
**Responsibility** – Generates a description without processing any code context.
|
|
470
|
+
|
|
471
|
+
**Logic Flow**
|
|
472
|
+
1. Stores `discription` on init.
|
|
473
|
+
2. `generate(info, model)` → calls `generete_custom_discription_without(model, self.discription, info.get("language"))` and returns its result.
|
|
474
|
+
|
|
475
|
+
**Data Contract**
|
|
476
|
+
|
|
477
|
+
| Entity | Type | Role | Notes |
|
|
478
|
+
|--------|------|------|-------|
|
|
479
|
+
| `discription` | `str` | Fixed template | Constructor argument |
|
|
480
|
+
| `info["language"]` | `str` | Desired language | Optional |
|
|
481
|
+
| Return | `str` | Description string | From `generete_custom_discription_without` |
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
<a name="custom-intro-processor"></a>
|
|
485
|
+
## Custom Intro Processor Functions
|
|
486
|
+
|
|
487
|
+
**Responsibility** – Generates enriched introductory sections and HTML link lists for the documentation pipeline. It extracts anchors, prompts a *Model* to create link‑based intros, full introductions, and optional custom descriptions.
|
|
488
|
+
<a name="code-mix-class"></a>
|
|
489
|
+
## `CodeMix` – Repository Content Packager
|
|
490
|
+
|
|
491
|
+
**Responsibility** – Walks a directory tree, writes a textual representation of its structure and the raw content of each non‑ignored file to an output file.
|
|
492
|
+
|
|
493
|
+
| Entity | Type | Role | Notes |
|
|
494
|
+
|--------|------|------|-------|
|
|
495
|
+
| `root_dir` | `Path` | Input | Base directory (resolved). |
|
|
496
|
+
| `ignore_patterns` | `list[str]` | Input | Glob patterns for files/dirs to skip. |
|
|
497
|
+
| `logger` | `BaseLogger` | Internal | Logs actions at configurable levels. |
|
|
498
|
+
| `should_ignore(path)` | `bool` | Output | True if `path` matches any ignore pattern. |
|
|
499
|
+
| `build_repo_content(output_file)` | `None` | Side‑effect | Writes structure + file bodies to *output_file*. |
|
|
500
|
+
|
|
501
|
+
**Logic Flow**
|
|
502
|
+
1. `should_ignore` computes a relative path, then checks glob matches against the full path, basename, and any path component.
|
|
503
|
+
2. `build_repo_content` opens `output_file`.
|
|
504
|
+
3. First pass: writes “Repository Structure” with indentation proportional to depth, skipping ignored entries.
|
|
505
|
+
4. Writes a separator line.
|
|
506
|
+
5. Second pass: for each non‑ignored file, writes `<file path="…">` header, the file’s text (read with UTF‑8, errors ignored), and a blank line; errors are recorded in the output.
|
|
507
|
+
|
|
508
|
+
**Interaction** – Relies solely on the standard library (`os`, `pathlib`, `fnmatch`) and the internal `BaseLogger`. No external services are invoked.
|
|
509
|
+
<a name="logging‑module‑structure"></a>
|
|
510
|
+
## `logging.py` Classes and Flow
|
|
511
|
+
|
|
512
|
+
| Entity | Type | Role | Notes |
|
|
513
|
+
|--------|------|------|-------|
|
|
514
|
+
| `BaseLog` | class | Holds raw `message` and numeric `level`; provides default `format()` | `level` defaults 0 |
|
|
515
|
+
| `ErrorLog` / `WarningLog` / `InfoLog` | subclasses of `BaseLog` | Override `format()` to prepend timestamp & severity | Use `_log_prefix` property |
|
|
516
|
+
| `BaseLoggerTemplate` | class | Routes a `BaseLog` to an output; respects `log_level` filter | `global_log()` checks filter |
|
|
517
|
+
| `FileLoggerTemplate` | subclass of `BaseLoggerTemplate` | Writes formatted logs to a file path | Overrides `log()` |
|
|
518
|
+
| `BaseLogger` | singleton class | Central façade exposing `set_logger()` and `log()` | Stores a single `logger_template` instance |
|
|
519
|
+
|
|
520
|
+
**Logic flow**
|
|
521
|
+
1. A log object (e.g., `ErrorLog("msg")`) is instantiated → `_log_prefix` builds `"[YYYY‑MM‑DD HH:MM:SS]"`.
|
|
522
|
+
2. `BaseLogger().set_logger(logger_template)` injects a concrete template (`BaseLoggerTemplate` or `FileLoggerTemplate`).
|
|
523
|
+
3. `BaseLogger().log(log_obj)` forwards to `logger_template.global_log`.
|
|
524
|
+
4. `global_log` checks `self.log_level`; if `-1` or `log_level >= log.level`, it calls `log()` of the template, which either prints or appends to file.
|
|
525
|
+
<a name="progress‑module‑structure"></a>
|
|
526
|
+
## `progress_base.py` Classes and Flow
|
|
527
|
+
|
|
528
|
+
| Entity | Type | Role | Notes |
|
|
529
|
+
|--------|------|------|-------|
|
|
530
|
+
| `BaseProgress` | abstract class | Defines progress‑related API (`create_new_subtask`, `update_task`, `remove_subtask`) | Methods are placeholders |
|
|
531
|
+
| `LibProgress` | subclass of `BaseProgress` | Wraps **rich** `Progress`; tracks a base task and optional sub‑task | `update_task()` advances the appropriate task |
|
|
532
|
+
| `ConsoleTask` | helper class | Prints simple textual progress updates | `progress()` increments and prints percent |
|
|
533
|
+
| `ConsoleGtiHubProgress` | subclass of `BaseProgress` | Uses `ConsoleTask` for both general and sub‑tasks | `gen_task` created for overall progress |
|
|
534
|
+
|
|
535
|
+
**Logic flow**
|
|
536
|
+
1. `LibProgress.__init__` creates a rich base task (`total` defaults 4).
|
|
537
|
+
2. `create_new_subtask(name, total_len)` registers a sub‑task and stores its ID.
|
|
538
|
+
3. `update_task()` advances the sub‑task if present; otherwise advances the base task.
|
|
539
|
+
4. `remove_subtask()` clears the sub‑task reference.
|
|
540
|
+
5. `ConsoleGtiHubProgress` mirrors this behavior with `ConsoleTask` objects, printing textual percentages.
|
|
541
|
+
<a name="intro-links"></a>
|
|
542
|
+
## `IntroLinks` – HTML Link Intro Builder
|
|
543
|
+
|
|
544
|
+
**Responsibility** – Extracts HTML links from `full_data` and formats an introductory block using the model.
|
|
545
|
+
|
|
546
|
+
**Logic Flow**
|
|
547
|
+
1. `generate(info, model)` →
|
|
548
|
+
- `links = get_all_html_links(info.get("full_data"))`.
|
|
549
|
+
- `intro_links = get_links_intro(links, model, info.get("language"))`.
|
|
550
|
+
- Returns `intro_links`.
|
|
551
|
+
|
|
552
|
+
**Data Contract**
|
|
553
|
+
|
|
554
|
+
| Entity | Type | Role | Notes |
|
|
555
|
+
|--------|------|------|-------|
|
|
556
|
+
| `info["full_data"]` | `Any` | Raw data containing HTML links | Passed to `get_all_html_links` |
|
|
557
|
+
| `info["language"]` | `str` | Output language | Optional |
|
|
558
|
+
| Return | `str` | Intro text with links | From `get_links_intro` |
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
<a name="intro-text"></a>
|
|
562
|
+
## `IntroText` – General Introduction Generator
|
|
563
|
+
|
|
564
|
+
**Responsibility** – Generates a textual introduction from `global_data` via the model.
|
|
565
|
+
|
|
566
|
+
**Logic Flow**
|
|
567
|
+
1. `generate(info, model)` →
|
|
568
|
+
- `intro = get_introdaction(info.get("global_data"), model, info.get("language"))`.
|
|
569
|
+
- Returns `intro`.
|
|
570
|
+
|
|
571
|
+
**Data Contract**
|
|
572
|
+
|
|
573
|
+
| Entity | Type | Role | Notes |
|
|
574
|
+
|--------|------|------|-------|
|
|
575
|
+
| `info["global_data"]` | `Any` | Source content for intro | Consumed by `get_introdaction` |
|
|
576
|
+
| `info["language"]` | `str` | Desired language | Optional |
|
|
577
|
+
| Return | `str` | Introduction paragraph | From `get_introdaction` |
|
|
578
|
+
|
|
579
|
+
> **Warning** – All modules assume required keys exist in `info`; missing keys will cause `None` to be passed to downstream functions, which may raise errors if not handled.
|
|
580
|
+
<a name="visible-interactions"></a>
|
|
581
|
+
## External Interactions
|
|
582
|
+
|
|
583
|
+
- Imports **`GPTModel`**, **`Model`** (model abstractions).
|
|
584
|
+
- Uses UI logging classes **`BaseLogger`**, **`InfoLog`** for progress reporting.
|
|
585
|
+
- Relies on configuration constants **`BASE_INTRODACTION_CREATE_LINKS`**, **`BASE_INTRO_CREATE`**, **`BASE_CUSTOM_DISCRIPTIONS`**.
|
|
586
|
+
- No file I/O is performed here; all persistence is handled upstream/downstream.
|
|
587
|
+
<a name="logic-flow"></a>
|
|
588
|
+
## Execution Flow
|
|
589
|
+
|
|
590
|
+
1. **`get_all_html_links(data)`** – Scans *data* with regex `<a name=["']?(.*?)["']?</a>`; collects anchors longer than 5 chars, prefixes “#”. Logs start/completion.
|
|
591
|
+
2. **`get_links_intro(links, model, language)`** – Builds a system‑prompt using `BASE_INTRODACTION_CREATE_LINKS`, adds the *links* list, calls `model.get_answer_without_history`, returns the generated intro.
|
|
592
|
+
3. **`get_introdaction(global_data, model, language)`** – Similar prompt flow with `BASE_INTRO_CREATE`; returns plain introduction text.
|
|
593
|
+
4. **`generete_custom_discription(splited_data, model, custom_description, language)`** – Iterates over *splited_data*, constructs a detailed system prompt (technical analyst + `BASE_CUSTOM_DISCRIPTIONS`), stops when the model returns a substantive answer (absence of “!noinfo”/“No information found”). Returns the first valid result.
|
|
594
|
+
5. **`generete_custom_discription_without(model, custom_description, language)`** – Sends a single prompt that enforces a mandatory `
|
|
595
|
+
<a name="metadata-logic-flow"></a>
|
|
596
|
+
## Logic Flow
|
|
597
|
+
|
|
598
|
+
1. Build tool opens `pyproject.toml`.
|
|
599
|
+
2. Parses `[project]` section → extracts metadata fields.
|
|
600
|
+
3. Parses `[build-system]` → ensures `poetry-core` is available.
|
|
601
|
+
4. Emits a `ProjectMetadata` object; downstream steps use it to construct distribution files.
|
|
602
|
+
<a name="metadata-functional-role"></a>
|
|
603
|
+
## Functional Role
|
|
604
|
+
|
|
605
|
+
The fragment declares **static package metadata** and **dependency constraints** for the **Auto Doc Generator** project. It serves as the single source of truth for packaging, installation, and build‑time resolution of required libraries.
|
|
606
|
+
<a name="metadata-visible-interactions"></a>
|
|
607
|
+
## Visible Interactions
|
|
608
|
+
|
|
609
|
+
1. **Build backend** (`poetry.core.masonry.api`) reads the file to generate `pyproject‑metadata` and wheel/sdist artifacts.
|
|
610
|
+
2. **Dependency resolvers** (pip, poetry) consume the `dependencies` list to install required packages.
|
|
611
|
+
3. **IDE tooling** may display the metadata (name, version, authors) for user reference.
|
|
612
|
+
<a name="metadata-data-contract"></a>
|
|
613
|
+
## Data Contract
|
|
614
|
+
|
|
615
|
+
| Entity | Type | Role | Notes |
|
|
616
|
+
|--------|------|------|-------|
|
|
617
|
+
| Input file | **toml** | Source of configuration | Must be present at project root |
|
|
618
|
+
| Output artifact | **wheel / sdist** | Packaged distribution | Contains metadata derived from this fragment |
|
|
619
|
+
| Side effects | **none at runtime** | Build‑time only | No code execution, only static analysis |
|
|
620
|
+
|
|
621
|
+
This documentation isolates the `pyproject.toml` fragment, adhering strictly to the provided content without external inference.
|
|
622
|
+
<a name="get-order"></a>
|
|
623
|
+
## `get_order` – Semantic Title Sorting
|
|
624
|
+
|
|
625
|
+
**Responsibility** – Sends the list of anchor titles to a *Model* for semantic ordering, then assembles the ordered markdown.
|
|
626
|
+
|
|
627
|
+
| Entity | Type | Role | Notes |
|
|
628
|
+
|--------|------|------|-------|
|
|
629
|
+
| `model` | `Model` | Input | Must implement `get_answer_without_history`. |
|
|
630
|
+
| `chanks` | `dict[str, str]` | Input | Anchor → content mapping from `split_text_by_anchors`. |
|
|
631
|
+
| `result` | `str` | Internal | Raw comma‑separated answer from model. |
|
|
632
|
+
| `new_result` | `list[str]` | Internal | Stripped title list. |
|
|
633
|
+
| `order_output` | `str` | Output | Concatenated content in the model’s order. |
|
|
634
|
+
|
|
635
|
+
**Logic Flow**
|
|
636
|
+
1. Log start and inputs.
|
|
637
|
+
2. Build `prompt` requesting a **comma‑separated** list of titles (anchors kept).
|
|
638
|
+
3. Call `model.get_answer_without_history(prompt)`.
|
|
639
|
+
- *If the model lacks this method, an `AttributeError` is raised.*
|
|
640
|
+
4. Split and strip the answer → `new_result`.
|
|
641
|
+
5. Iterate `new_result`, append `chanks[el]` to `order_output` with a trailing newline, logging each addition.
|
|
642
|
+
6. Return the assembled string.
|
|
643
|
+
<a name="data-contract"></a>
|
|
644
|
+
## Data Contract
|
|
645
|
+
|
|
646
|
+
| Function | Input(s) | Output | Side Effects |
|
|
647
|
+
|----------|----------|--------|--------------|
|
|
648
|
+
| `get_all_html_links` | `data: str` | `list[str]` of “#anchor” links | Logs extraction |
|
|
649
|
+
| `get_links_intro` | `links: list[str]`, `model: Model`, `language: str` | `str` intro with links | Logs generation |
|
|
650
|
+
| `get_introdaction` | `global_data: str`, `model: Model`, `language: str` | `str` full intro | None |
|
|
651
|
+
| `generete_custom_discription` | `splited_data: str`, `model: Model`, `custom_description: str`, `language: str` | `str` description (or empty) | Logs each attempt |
|
|
652
|
+
| `generete_custom_discription_without` | `model: Model`, `custom_description: str`, `language: str` | `str` description with mandatory tag | None |
|
|
653
|
+
|
|
654
|
+
> **⚠️ Warning** – All prompts assume the provided *Model* implements `get_answer_without_history`. If the model is absent or mis‑configured, the functions will raise an `AttributeError`.
|
|
655
|
+
<a name="structure-settings"></a>
|
|
656
|
+
## `StructureSettings` – Runtime Documentation Layout Settings
|
|
657
|
+
|
|
658
|
+
| Entity | Type | Role | Notes |
|
|
659
|
+
|--------|------|------|-------|
|
|
660
|
+
| `include_intro_links` | `bool` | Toggle insertion of intro‑links section | Defaults `True` |
|
|
661
|
+
| `include_order` | `bool` | Toggle automatic ordering of generated parts | Defaults `True` |
|
|
662
|
+
| `max_doc_part_size` | `int` | Maximum symbols per documentation chunk | Default `5 000` |
|
|
663
|
+
| `load_settings` | method | Populates attributes from a dict | **Assumption** – keys match attribute names exactly |
|
|
664
|
+
|
|
665
|
+
> **Assumption** – No validation is performed; unknown keys become new attributes.
|
|
666
|
+
<a name="project-settings"></a>
|
|
667
|
+
## `ProjectSettings` – Project‑Specific Prompt Builder
|
|
668
|
+
|
|
669
|
+
**Role** – Holds a project name and arbitrary key/value pairs, exposing a `prompt` property that concatenates the base settings prompt with those values.
|
|
670
|
+
|
|
671
|
+
| Entity | Type | Role | Notes |
|
|
672
|
+
|--------|------|------|------- |
|
|
673
|
+
| `project_name` | `str` | Input | Identifier for the project. |
|
|
674
|
+
| `info` | `dict` | Internal | Arbitrary metadata added via `add_info`. |
|
|
675
|
+
| `add_info(key, value)` | `method` | Mutator | Stores `key: value` in `info`. |
|
|
676
|
+
| `prompt` | `property` | Output | `BASE_SETTINGS_PR` + project name + all `info` entries. |
|
|
677
|
+
|
|
678
|
+
**Flow**
|
|
679
|
+
1. `add_info` inserts a key/value pair.
|
|
680
|
+
2. `prompt` starts with `BASE_SETTINGS_PROMPT`, appends “Project Name: …”, then each stored pair as `key: value`.
|
|
681
|
+
|
|
682
|
+
> **Note:** All components rely solely on the standard library and the internal `engine` and `ui` packages; no external services are invoked beyond the supplied `Model` implementations.
|
|
683
|
+
<a name="project-metadata-definition"></a>
|
|
684
|
+
## `pyproject.toml` Project Metadata
|
|
685
|
+
|
|
686
|
+
| Entity | Type | Role | Notes |
|
|
687
|
+
|--------|------|------|-------|
|
|
688
|
+
| `name` | string | Package identifier | `"autodocgenerator"` |
|
|
689
|
+
| `version` | string | Semantic version | `"0.9.0.1"` |
|
|
690
|
+
| `description` | string | One‑line summary | Helps create docs for projects |
|
|
691
|
+
| `authors` | list of tables | Author contact info | `{name, email}` |
|
|
692
|
+
| `license` | table | SPDX‑compatible licensing | `text = "MIT"` |
|
|
693
|
+
| `readme` | string | Path to long description | `"README.md"` |
|
|
694
|
+
| `requires-python` | string | Python version constraint | `">=3.11,<4.0"` |
|
|
695
|
+
| `dependencies` | list of strings | Runtime requirements | 44 packages listed |
|
|
696
|
+
| `build-system.requires` | list of strings | Build‑time requirements | `["poetry-core>=2.0.0"]` |
|
|
697
|
+
| `build-system.build-backend` | string | Build backend entry point | `"poetry.core.masonry.api"` |
|
|
698
|
+
|
|
699
|
+
> **Assumption:** The file is processed by **PEP 621**‑compatible tools (e.g., *poetry*). No other runtime logic is present.
|
|
700
|
+
<a name="CONTENT_DESCRIPTION"></a>` tag and strict lexical rules; returns the model’s raw answer.
|
|
701
|
+
<a name="read-config-function"></a>
|
|
702
|
+
## `read_config` – YAML Configuration Loader
|
|
703
|
+
|
|
704
|
+
**Responsibility** – Parses a YAML string, builds a **`Config`** object, instantiates custom description modules, and prepares a **`StructureSettings`** instance for the generation pipeline.
|
|
705
|
+
|
|
706
|
+
**Logic Flow**
|
|
707
|
+
1. `yaml.safe_load` → `data` dict.
|
|
708
|
+
2. Extract `ignore_files`, `language`, `project_name`, `project_additional_info`, `build_settings`, `custom_descriptions`, `structure_settings`.
|
|
709
|
+
3. Initialise `Config()` → `pcs = ProjectBuildConfig()`; `pcs.load_settings(build_settings)`.
|
|
710
|
+
4. Chain setters: `set_language`, `set_project_name`, `set_pcs`.
|
|
711
|
+
5. Append each ignore pattern via `config.add_ignore_file`.
|
|
712
|
+
6. Populate additional info with `config.add_project_additional_info`.
|
|
713
|
+
7. Build `custom_modules` list: entries starting with **`%`** become `CustomModuleWithOutContext(custom_desc[1:])`; otherwise `CustomModule(custom_desc)`.
|
|
714
|
+
8. Load structure settings into a fresh `StructureSettings` object.
|
|
715
|
+
|
|
716
|
+
**Data Contract**
|
|
717
|
+
|
|
718
|
+
| Entity | Type | Role | Notes |
|
|
719
|
+
|--------|------|------|-------|
|
|
720
|
+
| `file_data` | `str` | Raw YAML content | Must be UTF‑8 valid |
|
|
721
|
+
| `config` | `Config` | Central project configuration | Populated via setters |
|
|
722
|
+
| `custom_modules` | `list[CustomModule]` | User‑supplied description hooks | Context‑aware vs. context‑less |
|
|
723
|
+
| `structure_settings_object` | `StructureSettings` | Controls doc chunking & ordering | Loaded from `structure_settings` dict |
|
|
724
|
+
| Return value | `tuple[Config, list[CustomModule], StructureSettings]` | Combined runtime configuration | Order fixed as shown |
|
|
725
|
+
<a name="extract-links-from-start"></a>
|
|
726
|
+
## `extract_links_from_start` – Anchor Extraction
|
|
727
|
+
|
|
728
|
+
**Responsibility** – Scans a list of markdown *chunks* and returns a list of anchor links (`#anchor`) whose name length > 5.
|
|
729
|
+
|
|
730
|
+
| Entity | Type | Role | Notes |
|
|
731
|
+
|--------|------|------|-------|
|
|
732
|
+
| `chunks` | `list[str]` | Input | Raw markdown sections. |
|
|
733
|
+
| `links` | `list[str]` | Output | Collected `#`‑prefixed anchors. |
|
|
734
|
+
|
|
735
|
+
> **Assumption** – Each chunk may start with an HTML `<a name="…"></a>` tag.
|
|
736
|
+
<a name="split-text-by-anchors"></a>
|
|
737
|
+
## `split_text_by_anchors` – Chunk Partitioning
|
|
738
|
+
|
|
739
|
+
**Responsibility** – Splits a markdown *text* at anchor tags, validates a 1:1 mapping, and builds a dict `{anchor: chunk}`.
|
|
740
|
+
|
|
741
|
+
| Entity | Type | Role | Notes |
|
|
742
|
+
|--------|------|------|-------|
|
|
743
|
+
| `text` | `str` | Input | Full markdown document. |
|
|
744
|
+
| `result_chanks` | `list[str]` | Internal | Trimmed, non‑empty pieces. |
|
|
745
|
+
| `all_links` | `list[str]` | Internal | Output of `extract_links_from_start`. |
|
|
746
|
+
| `result` | `dict[str, str]` | Output | Mapping anchor → chunk; `None` if lengths differ. |
|
|
747
|
+
|
|
748
|
+
**Logic Flow**
|
|
749
|
+
1. Regex `(?=<a name=…)` creates split points.
|
|
750
|
+
2. Whitespace‑trim each piece.
|
|
751
|
+
3. Call `extract_links_from_start` → `all_links`.
|
|
752
|
+
4. If `len(all_links) != len(result_chanks)` → `return None`.
|
|
753
|
+
5. Populate `result` by index.
|
|
754
|
+
<a name="split-data"></a>
|
|
755
|
+
## `split_data` – Input Chunking for Symbol‑Limited Processing
|
|
756
|
+
|
|
757
|
+
**Role** – Divides a raw documentation string into smaller fragments that do not exceed a given symbol count, preparing the text for downstream model calls that have size limits.
|
|
758
|
+
|
|
759
|
+
| Entity | Type | Role | Notes |
|
|
760
|
+
|--------|------|------|-------|
|
|
761
|
+
| `data` | `str` | Input | Complete documentation text to be partitioned. |
|
|
762
|
+
| `max_symbols` | `int` | Input | Maximum number of characters allowed per output fragment. |
|
|
763
|
+
| `split_objects` | `list[str]` | Internal | Accumulates the generated fragments; initially empty. |
|
|
764
|
+
| `splited_by_files` | `list[str]` | Internal | Result of `data.split(...)`; the delimiter is not visible in the fragment. |
|
|
765
|
+
| `BASE_PART_COMPLITE_TEXT` | `str` (import) | External | Constant from the engine config; purpose not evident in the shown code. |
|
|
766
|
+
| `ProjectSettings`, `BaseProgress`, `BaseLogger`, … | *imports* | External | Imported but not referenced in the visible fragment. |
|
|
767
|
+
|
|
768
|
+
> **Note:** The delimiter used in `data.split(...)` and any subsequent processing steps are omitted from the provided snippet; therefore, the full transformation logic cannot be described.
|
|
769
|
+
|
|
770
|
+
**Flow**
|
|
771
|
+
1. **Initialize** `split_objects` as an empty list.
|
|
772
|
+
2. **Split** the input string `data` using an unspecified delimiter (`data.split("…")`) and store the resulting list in `splited_by_files`.
|
|
773
|
+
3. *(Further processing – e.g., chunk size enforcement, aggregation into `split_objects` – is not present in the supplied fragment and therefore not documented.)*
|
|
774
|
+
|
|
775
|
+
**Visible Interactions**
|
|
776
|
+
- Relies solely on Python's built‑in `str.split` method; no external APIs or custom classes are invoked within the visible portion.
|
|
777
|
+
- Imports from the engine and UI layers are present but unused in the excerpt, indicating that additional functionality may be added later in the function.
|
|
778
|
+
|
|
779
|
+
> **Critical Assumption:** Without the remainder of the function, the exact mechanism for respecting `max_symbols` and how the fragments are returned remains undefined.
|
|
780
|
+
|
|
781
|
+
---
|
|
782
|
+
|
|
783
|
+
*End of `split_data` documentation.*
|
|
784
|
+
<a name="split-data-loop-adjustments"></a>
|
|
785
|
+
## split_data Loop Adjustments
|
|
786
|
+
|
|
787
|
+
| Entity | Type | Role | Notes |
|
|
788
|
+
|--------|------|------|-------|
|
|
789
|
+
| `splited_by_files` | `list[str]` | Source fragments after initial split | Populated before this fragment |
|
|
790
|
+
| `max_symbols` | `int` | Size threshold | Used with multipliers `1.5` and `1.25` |
|
|
791
|
+
| `have_to_change` | `bool` | Loop‑control flag | Starts `False`, set `True` when a slice is re‑partitioned |
|
|
792
|
+
| `i`, `el` | `int`, `str` | Iterator values | `enumerate(splited_by_files)` |
|
|
793
|
+
|
|
794
|
+
**Logic flow**
|
|
795
|
+
1. Enter an indefinite `while` loop.
|
|
796
|
+
2. Iterate over `splited_by_files`.
|
|
797
|
+
3. If a segment length exceeds `max_symbols * 1.5`, insert a new slice at `i+1` containing the right half (`el[i][int(max_symbols/2):]`) and truncate the original to the left half (`el[i][:int(max_symbols/2)]`).
|
|
798
|
+
4. Set `have_to_change` = `True`.
|
|
799
|
+
5. After the `for` loop, break when no segment required further splitting.
|
|
800
|
+
|
|
801
|
+
> **Assumption:** `el[i]` indexing is safe because `el` is a string; the code relies on Python slicing semantics.
|
|
802
|
+
<a name="split-data-chunk-assembly"></a>
|
|
803
|
+
## split_data Chunk Assembly
|
|
804
|
+
|
|
805
|
+
| Entity | Type | Role | Notes |
|
|
806
|
+
|--------|------|------|-------|
|
|
807
|
+
| `split_objects` | `list[str]` | Accumulator for final parts | Initialized earlier as `[]` |
|
|
808
|
+
| `curr_index` | `int` | Current output bucket index | Starts `0` |
|
|
809
|
+
| `el` (loop variable) | `str` | Current piece from `splited_by_files` | Processed sequentially |
|
|
810
|
+
|
|
811
|
+
**Logic flow**
|
|
812
|
+
1. Ensure `split_objects` has an entry for `curr_index`; append empty string if missing.
|
|
813
|
+
2. If adding `el` would make the current bucket exceed `max_symbols * 1.25`, increment `curr_index`, start a new bucket with `el`, and continue.
|
|
814
|
+
3. Otherwise, append `"\n"+el` to the existing bucket.
|
|
815
|
+
|
|
816
|
+
The loop yields `split_objects`, a list of strings each respecting the size heuristic.
|
|
817
|
+
<a name="compress"></a>
|
|
818
|
+
## `compress` – Text Chunk Compression
|
|
819
|
+
|
|
820
|
+
**Role** – Sends a single text fragment to a language model with a project‑specific system prompt and a base compression prompt, then returns the model’s raw answer.
|
|
821
|
+
|
|
822
|
+
| Entity | Type | Role | Notes |
|
|
823
|
+
|--------|------|------|------- |
|
|
824
|
+
| `data` | `str` | Input | Text to compress. |
|
|
825
|
+
| `project_settings` | `ProjectSettings` | Input | Provides the system prompt via its `prompt` property. |
|
|
826
|
+
| `model` | `Model` | Input | Must implement `get_answer_without_history`. |
|
|
827
|
+
| `compress_power` | `int` | Input | Determines the compression strength. |
|
|
828
|
+
| `prompt` | `list[dict]` | Internal | System and user messages built for the model. |
|
|
829
|
+
| `answer` | `str` | Output | Raw response from `model.get_answer_without_history`. |
|
|
830
|
+
|
|
831
|
+
**Flow**
|
|
832
|
+
1. Assemble `prompt` with three messages: project settings, base‑compression text (`get_BASE_COMPRESS_TEXT(10000, compress_power)`), and the target `data`.
|
|
833
|
+
2. Call `model.get_answer_without_history(prompt=prompt)`.
|
|
834
|
+
3. Return the obtained answer.
|
|
835
|
+
<a name="compress-and-compare"></a>
|
|
836
|
+
## `compress_and_compare` – Batch Compression & Comparison
|
|
837
|
+
|
|
838
|
+
**Role** – Groups input strings into bundles of size `compress_power`, compresses each via `compress`, and returns a list where each element contains the concatenated compressed results of a bundle.
|
|
839
|
+
|
|
840
|
+
| Entity | Type | Role | Notes |
|
|
841
|
+
|--------|------|------|------- |
|
|
842
|
+
| `data` | `list[str]` | Input | Source strings to compress. |
|
|
843
|
+
| `model` | `Model` | Input | Used by `compress`. |
|
|
844
|
+
| `project_settings` | `ProjectSettings` | Input | Passed to `compress`. |
|
|
845
|
+
| `compress_power` | `int` | Input | Bundle size (default 4). |
|
|
846
|
+
| `progress_bar` | `BaseProgress` | Internal | Updates progress per item. |
|
|
847
|
+
| `compress_and_compare_data` | `list[str]` | Output | List sized ⌈len(data)/compress_power⌉. |
|
|
848
|
+
|
|
849
|
+
**Flow**
|
|
850
|
+
1. Allocate a result list sized for the number of bundles.
|
|
851
|
+
2. Create a sub‑task for progress.
|
|
852
|
+
3. Iterate over `data`; compute `curr_index = i // compress_power`.
|
|
853
|
+
4. Append `compress(el, …)` plus newline to the corresponding slot.
|
|
854
|
+
5. Update progress after each element.
|
|
855
|
+
6. Remove the sub‑task and return the list.
|
|
856
|
+
<a name="async-compress"></a>
|
|
857
|
+
## `async_compress` – Async Single‑Item Compression
|
|
858
|
+
|
|
859
|
+
**Role** – Async counterpart of `compress`; respects a semaphore to limit concurrent model calls and reports progress.
|
|
860
|
+
|
|
861
|
+
| Entity | Type | Role | Notes |
|
|
862
|
+
|--------|------|------|------- |
|
|
863
|
+
| `data` | `str` | Input | Text to compress. |
|
|
864
|
+
| `project_settings` | `ProjectSettings` | Input | Provides system prompt. |
|
|
865
|
+
| `model` | `AsyncModel` | Input | Async `get_answer_without_history`. |
|
|
866
|
+
| `compress_power` | `int` | Input | Compression strength. |
|
|
867
|
+
| `semaphore` | `asyncio.Semaphore` | Input | Limits parallel calls. |
|
|
868
|
+
| `progress_bar` | `BaseProgress` | Input | Updates after each call. |
|
|
869
|
+
| `answer` | `str` | Output | Model’s response. |
|
|
870
|
+
|
|
871
|
+
**Flow**
|
|
872
|
+
1. Acquire `semaphore`.
|
|
873
|
+
2. Build the same three‑message `prompt` as `compress`.
|
|
874
|
+
3. Await `model.get_answer_without_history(prompt=prompt)`.
|
|
875
|
+
4. Increment progress, release semaphore, return answer.
|
|
876
|
+
<a name="async-compress-and-compare"></a>
|
|
877
|
+
## `async_compress_and_compare` – Parallel Batch Compression
|
|
878
|
+
|
|
879
|
+
**Role** – Dispatches `async_compress` for each element, runs up to four concurrent tasks, and merges results into bundles of size `compress_power`.
|
|
880
|
+
|
|
881
|
+
| Entity | Type | Role | Notes |
|
|
882
|
+
|--------|------|------|------- |
|
|
883
|
+
| `data` | `list[str]` | Input | Items to compress. |
|
|
884
|
+
| `model` | `AsyncModel` | Input | Async model. |
|
|
885
|
+
| `project_settings` | `ProjectSettings` | Input | System prompt source. |
|
|
886
|
+
| `compress_power` | `int` | Input | Bundle size (default 4). |
|
|
887
|
+
| `progress_bar` | `BaseProgress` | Internal | Tracks overall progress. |
|
|
888
|
+
| `compressed_elements` | `list[str]` | Internal | Individual async results. |
|
|
889
|
+
| `final_data` | `list[str]` | Output | Concatenated bundles. |
|
|
890
|
+
|
|
891
|
+
**Flow**
|
|
892
|
+
1. Create a semaphore of 4 permits.
|
|
893
|
+
6. Queue a task for each element via `async_compress`.
|
|
894
|
+
2. Await `asyncio.gather(*tasks)`.
|
|
895
|
+
3. Slice the flat list into chunks of `compress_power` and join with newlines.
|
|
896
|
+
<a name="compress-to-one"></a>
|
|
897
|
+
## `compress_to_one` – Recursive Full‑Project Compression
|
|
898
|
+
|
|
899
|
+
**Role** – Repeatedly compresses a list until a single string remains; optionally uses async processing.
|
|
900
|
+
|
|
901
|
+
| Entity | Type | Role | Notes |
|
|
902
|
+
|--------|------|------|------- |
|
|
903
|
+
| `data` | `list[str]` | Input | Initial fragments. |
|
|
904
|
+
| `model` | `Model` | Input | Model for sync or async calls. |
|
|
905
|
+
| `project_settings` | `ProjectSettings` | Input | Prompt source. |
|
|
906
|
+
| `compress_power` | `int` | Input | Max items per iteration. |
|
|
907
|
+
| `use_async` | `bool` | Input | Selects async path. |
|
|
908
|
+
| `progress_bar` | `BaseProgress` | Internal | Progress for each iteration. |
|
|
909
|
+
| `count_of_iter` | `int` | Internal | Iteration counter. |
|
|
910
|
+
| `data` (final) | `str` | Output | Final compressed document. |
|
|
911
|
+
|
|
912
|
+
**Flow**
|
|
913
|
+
Loop while `len(data) > 1`:
|
|
914
|
+
• Adjust `compress_power` to 2 when list is smaller than `compress_power+1`.
|
|
915
|
+
• Call either `async_compress_and_compare` (via `asyncio.run`) or `compress_and_compare`.
|
|
916
|
+
• Increment iteration counter.
|
|
917
|
+
Return the sole remaining element.
|
|
918
|
+
<a name="async-gpt-model"></a>
|
|
919
|
+
## `AsyncGPTModel` – Asynchronous LLM Wrapper
|
|
920
|
+
|
|
921
|
+
**Responsibility** – Implements `AsyncModel` for Groq’s async client, handling model rotation, history management, and logging.
|
|
922
|
+
|
|
923
|
+
**Logic Flow**
|
|
924
|
+
1. `__init__` → calls `ParentModel.__init__` → shuffles `MODELS_NAME` into `regen_models_name`.
|
|
925
|
+
2. Instantiates `AsyncGroq` client with `api_key`.
|
|
926
|
+
3. `generate_answer` logs start, selects `messages` from `self.history.history` (or a single `prompt`).
|
|
927
|
+
4. Loops until a model succeeds:
|
|
928
|
+
- Picks `model_name` from `regen_models_name[self.current_model_index]`.
|
|
929
|
+
- Calls `await self.client.chat.completions.create(messages=messages, model=model_name)`.
|
|
930
|
+
- On exception logs a warning and advances `current_model_index` (wrap‑around).
|
|
931
|
+
5. On success extracts `chat_completion.choices[0].message.content`, logs result, returns it.
|
|
932
|
+
|
|
933
|
+
**Data Contract**
|
|
934
|
+
|
|
935
|
+
| Entity | Type | Role | Notes |
|
|
936
|
+
|--------|------|------|-------|
|
|
937
|
+
| `api_key` | `str` | Authentication token | Defaults to `API_KEY` from config |
|
|
938
|
+
| `history` | `History` | Message buffer for context | Provided to `ParentModel` |
|
|
939
|
+
| `use_random` | `bool` | Enables random model order | Shuffles `MODELS_NAME` |
|
|
940
|
+
| `messages` | `list[dict]` | Payload sent to Groq | Derived from `history` or `prompt` |
|
|
941
|
+
| `model_name` | `str` | Current LLM identifier | Rotated on failure |
|
|
942
|
+
| `chat_completion` | `AsyncGroq` response | Raw API result | Must contain `choices[0].message.content` |
|
|
943
|
+
| Return | `str` | Generated answer | Logged at level 2 |
|
|
944
|
+
|
|
945
|
+
> **Warning** – If `regen_models_name` becomes empty, `ModelExhaustedException` is raised; ensure at least one model is configured.
|
|
946
|
+
|
|
947
|
+
---
|
|
948
|
+
<a name="gpt-model"></a>
|
|
949
|
+
## `GPTModel` – Synchronous LLM Wrapper
|
|
950
|
+
|
|
951
|
+
**Responsibility** – Mirrors `AsyncGPTModel` for the synchronous Groq client, providing the same rotation and logging logic.
|
|
952
|
+
|
|
953
|
+
**Logic Flow**
|
|
954
|
+
1. `__init__` → inherits `ParentModel` setup, creates `Groq` client.
|
|
955
|
+
2. `generate_answer` follows the identical loop as the async version, using `self.client.chat.completions.create`.
|
|
956
|
+
3. Logs success and returns the extracted content.
|
|
957
|
+
|
|
958
|
+
**Data Contract** – Same as `AsyncGPTModel` with the only difference being a **synchronous** `client` (`Groq`).
|
|
959
|
+
|
|
960
|
+
---
|
|
961
|
+
<a name="model-base"></a>
|
|
962
|
+
## `Model` / `AsyncModel` – Shared Foundations
|
|
963
|
+
|
|
964
|
+
**Responsibility** – Provide history handling (`get_answer`, `get_answer_without_history`) and expose `generate_answer` placeholders overridden by subclasses.
|
|
965
|
+
|
|
966
|
+
**Visible Interactions**
|
|
967
|
+
- Both subclasses call `self.history.add_to_history` to record *user* and *assistant* turns.
|
|
968
|
+
- They rely on `BASE_SYSTEM_TEXT`, `API_KEY`, and `MODELS_NAME` imported from `autodocgenerator.engine.config.config`.
|
|
969
|
+
|
|
970
|
+
**Data Contract**
|
|
971
|
+
|
|
972
|
+
| Entity | Type | Role | Notes |
|
|
973
|
+
|--------|------|------|-------|
|
|
974
|
+
| `history` | `History` | Stores system, user, and assistant messages | Initialized with `BASE_SYSTEM_TEXT` |
|
|
975
|
+
| `api_key` | `str` | API credential | Default from config |
|
|
976
|
+
| `regen_models_name` | `list[str]` | Rotated list of model identifiers | Shuffled when `use_random=True` |
|
|
977
|
+
| `current_model_index` | `int` | Pointer to the next model to try | Reset on each call cycle |
|
|
978
|
+
| Return of `get_answer` | `str` | Answer from underlying `generate_answer` | Also updates history |
|
|
979
|
+
|
|
980
|
+
> **Note** – Base implementations of `generate_answer` return the literal string `"answer"`; real behavior is supplied by `GPTModel` and `AsyncGPTModel`.
|
|
981
|
+
|