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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ๐ง Intelligent Documentation Generator Agent
|
| 2 |
+
|
| 3 |
+
Built with **GLM-4.6 on Fireworks AI** and **Gradio**
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## ๐ Overview
|
| 8 |
+
|
| 9 |
+
The **Intelligent Documentation Generator Agent** automatically generates structured, multi-layer documentation and provides a chat interface to explore Python codebases.
|
| 10 |
+
This version is powered by **GLM-4.6** via the **Fireworks AI Inference API** and implemented in **Gradio**, offering a lightweight, interactive browser-based UI.
|
| 11 |
+
|
| 12 |
+
**Capabilities:**
|
| 13 |
+
|
| 14 |
+
* Analyze Python files from uploads, pasted code, or GitHub links
|
| 15 |
+
* Generate consistent, well-structured documentation (overview, API breakdown, usage examples)
|
| 16 |
+
* Chat directly with your code to understand logic, dependencies, and optimization opportunities
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## โ๏ธ Architecture
|
| 21 |
+
|
| 22 |
+
```
|
| 23 |
+
User (Upload / Paste / GitHub)
|
| 24 |
+
โ
|
| 25 |
+
โผ
|
| 26 |
+
Gradio UI (Tabs)
|
| 27 |
+
โโโโโโโโโโโโโโโโโโโโโโโ
|
| 28 |
+
โ Documentation Tab โโโโบ Fireworks GLM-4.6 โ Markdown Docs
|
| 29 |
+
โ Chat Tab โโโโบ Fireworks GLM-4.6 โ Q&A Responses
|
| 30 |
+
โโโโโโโโโโโโโโโโโโโโโโโ
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## ๐งฉ Core Features
|
| 36 |
+
|
| 37 |
+
### ๐ Documentation Generator
|
| 38 |
+
|
| 39 |
+
* Input via:
|
| 40 |
+
|
| 41 |
+
* Pasted Python code
|
| 42 |
+
* Uploaded `.py` file
|
| 43 |
+
* GitHub file link (supports automatic conversion to raw URL)
|
| 44 |
+
* Produces:
|
| 45 |
+
|
| 46 |
+
* Overview and purpose
|
| 47 |
+
* Key functions/classes with signatures
|
| 48 |
+
* Dependencies and relationships
|
| 49 |
+
* Example usage and improvement suggestions
|
| 50 |
+
* Outputs documentation in Markdown
|
| 51 |
+
|
| 52 |
+
### ๐ฌ Code Chatbot
|
| 53 |
+
|
| 54 |
+
* Conversational Q&A with the analyzed code
|
| 55 |
+
* References exact functions and dependencies
|
| 56 |
+
* Maintains interactive chat history using Gradioโs `Chatbot` component
|
| 57 |
+
* Uses the same GLM-4.6 model context for accurate answers
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## ๐งฑ Tech Stack
|
| 62 |
+
|
| 63 |
+
| Layer | Technology |
|
| 64 |
+
| ----------------- | ----------------------------------------------- |
|
| 65 |
+
| **Model** | [GLM-4.6](https://fireworks.ai) on Fireworks AI |
|
| 66 |
+
| **UI Framework** | [Gradio](https://gradio.app) |
|
| 67 |
+
| **Language** | Python 3.9+ |
|
| 68 |
+
| **HTTP Requests** | `requests` |
|
| 69 |
+
| **Deployment** | Localhost / Containerized environments |
|
| 70 |
+
|
| 71 |
---
|
| 72 |
+
|
| 73 |
+
## ๐ Installation
|
| 74 |
+
|
| 75 |
+
### 1. Clone the Repository
|
| 76 |
+
|
| 77 |
+
```bash
|
| 78 |
+
git clone https://github.com/<your-username>/intelligent-doc-agent.git
|
| 79 |
+
cd intelligent-doc-agent
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
### 2. Install Dependencies
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
pip install gradio requests
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### 3. Configure Fireworks API Key
|
| 89 |
+
|
| 90 |
+
Set your API key as an environment variable:
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
export FIREWORKS_API_KEY="your_fireworks_api_key"
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
> Alternatively, enter your API key directly in the UI when prompted.
|
| 97 |
+
|
| 98 |
+
### 4. Run the Application
|
| 99 |
+
|
| 100 |
+
```bash
|
| 101 |
+
python app_gradio.py
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
Then visit **[http://127.0.0.1:7860](http://127.0.0.1:7860)** in your browser.
|
| 105 |
+
|
| 106 |
---
|
| 107 |
|
| 108 |
+
## ๐ก Usage Guide
|
| 109 |
+
|
| 110 |
+
### ๐ง Generate Documentation
|
| 111 |
+
|
| 112 |
+
1. Open the **๐ Generate Documentation** tab.
|
| 113 |
+
2. Choose an input mode:
|
| 114 |
+
|
| 115 |
+
* Paste code into the text area
|
| 116 |
+
* Upload a `.py` file
|
| 117 |
+
* Enter a GitHub file link (e.g., `https://github.com/.../file.py`)
|
| 118 |
+
3. Click **๐ Generate Documentation** to process your file.
|
| 119 |
+
4. View formatted Markdown output instantly.
|
| 120 |
+
|
| 121 |
+
### ๐ฌ Chat with Code
|
| 122 |
+
|
| 123 |
+
1. Switch to the **๐ฌ Chat with Code** tab.
|
| 124 |
+
2. Ask questions about your code (e.g., โWhat does this function do?โ or โHow can I improve performance?โ).
|
| 125 |
+
3. The model responds contextually, referencing the uploaded file.
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## ๐ง Model Integration Example
|
| 130 |
+
|
| 131 |
+
```python
|
| 132 |
+
payload = {
|
| 133 |
+
"model": "accounts/fireworks/models/glm-4p6",
|
| 134 |
+
"max_tokens": 4096,
|
| 135 |
+
"temperature": 0.6,
|
| 136 |
+
"messages": messages
|
| 137 |
+
}
|
| 138 |
+
response = requests.post(
|
| 139 |
+
"https://api.fireworks.ai/inference/v1/chat/completions",
|
| 140 |
+
headers={"Authorization": f"Bearer {FIREWORKS_API_KEY}"},
|
| 141 |
+
data=json.dumps(payload)
|
| 142 |
+
)
|
| 143 |
+
print(response.json()["choices"][0]["message"]["content"])
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
---
|
| 147 |
+
|
| 148 |
+
## ๐ฆ Project Structure
|
| 149 |
+
|
| 150 |
+
```
|
| 151 |
+
.
|
| 152 |
+
โโโ app_gradio.py # Main Gradio interface
|
| 153 |
+
โโโ README.md # Project documentation
|
| 154 |
+
โโโ requirements.txt # Dependencies (gradio, requests)
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
## ๐ฎ Future Enhancements
|
| 160 |
+
|
| 161 |
+
* **Multi-file repository analysis** with hierarchical context summarization
|
| 162 |
+
* **Semantic vector store** (Chroma / Pinecone) for persistent knowledge retrieval
|
| 163 |
+
* **Multi-agent orchestration** using LangGraph or MCP protocols
|
| 164 |
+
* **Continuous documentation updates** via Git hooks or CI/CD pipelines
|
| 165 |
+
|
| 166 |
+
---
|
| 167 |
+
|
| 168 |
+
## ๐งพ Example
|
| 169 |
+
|
| 170 |
+
**Input**
|
| 171 |
+
|
| 172 |
+
```python
|
| 173 |
+
def calculate_mean(numbers):
|
| 174 |
+
return sum(numbers) / len(numbers)
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
**Output**
|
| 178 |
+
|
| 179 |
+
```markdown
|
| 180 |
+
### Function: calculate_mean
|
| 181 |
+
Computes the arithmetic mean of a numeric list.
|
| 182 |
+
|
| 183 |
+
**Parameters:**
|
| 184 |
+
- numbers (list): Sequence of numbers to average.
|
| 185 |
+
|
| 186 |
+
**Returns:**
|
| 187 |
+
- float: Mean of the list.
|
| 188 |
+
|
| 189 |
+
**Usage Example:**
|
| 190 |
+
>>> calculate_mean([1, 2, 3, 4])
|
| 191 |
+
2.5
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
**Chat Example**
|
| 195 |
+
|
| 196 |
+
> โHow can I modify this to avoid division by zero errors?โ
|
| 197 |
+
|
| 198 |
+
---
|
| 199 |
+
|
| 200 |
+
## ๐ Best Practices
|
| 201 |
+
|
| 202 |
+
* Use **raw GitHub links** (`https://raw.githubusercontent.com/...`) for accurate file fetches.
|
| 203 |
+
* Limit input size (~4k tokens) for optimal latency and context accuracy.
|
| 204 |
+
* Keep your **API key** private โ never commit it in source files.
|
| 205 |
+
|
| 206 |
+
---
|
| 207 |
+
|
| 208 |
+
## ๐งญ License
|
| 209 |
+
|
| 210 |
+
Released under
|