aisrini commited on
Commit
606a35d
ยท
verified ยท
1 Parent(s): edf481b

Update Readme.md

Browse files
Files changed (1) hide show
  1. README.md +207 -11
README.md CHANGED
@@ -1,14 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: Intelligent Documentation Generator Agent
3
- emoji: ๐Ÿ˜ป
4
- colorFrom: blue
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 5.49.1
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: Intelligent Documentation Generator Agent
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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