Spaces:
Sleeping

Divb30 commited on
Commit
6a7ff87
·
1 Parent(s): 4a17812

updated README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -5
README.md CHANGED
@@ -13,10 +13,102 @@ hardware: zero-gpu
13
 
14
  # 🧠 IntelliCode RAG Assistant
15
 
16
- > Fully offline-capable AI assistant for code analysis & document Q&A.
17
- > Powered by **Qwen2.5-3B-Instruct** running on GPU — zero OpenAI dependency.
18
 
19
- [![Demo](https://img.shields.io/badge/🤗-Live_Demo-blue)](https://huggingface.co/spaces/YOUR_USERNAME/intellicode-rag)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- ## Stack
22
- `Qwen2.5-3B-Instruct` · `FAISS IndexFlatL2` · `sentence-transformers` · `Python AST` · `Streamlit`
 
13
 
14
  # 🧠 IntelliCode RAG Assistant
15
 
16
+ > Dual-mode AI assistant for code analysis & document Q&A — Qwen2.5-3B · FAISS · Python AST · HuggingFace ZeroGPU
 
17
 
18
+ [![Live Demo](https://img.shields.io/badge/🤗%20Live%20Demo-HuggingFace%20Spaces-blue)](https://huggingface.co/spaces/Divb30/intellicode-rag)
19
+ [![GitHub](https://img.shields.io/badge/GitHub-IntelliCode-black?logo=github)](https://github.com/Divyanshb30/IntelliDoc-RAG-Assistant)
20
+ [![Model](https://img.shields.io/badge/Model-Qwen2.5--3B-orange)](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct)
21
+ [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
22
+
23
+ ---
24
+
25
+ ## Live Demo
26
+
27
+ **[→ Try it live on HuggingFace Spaces](https://huggingface.co/spaces/Divb30/intellicode-rag)**
28
+
29
+ GPU-accelerated via ZeroGPU (A100). No login required.
30
+
31
+ ---
32
+
33
+ ## Two Modes, Two Engines
34
+
35
+ IntelliCode runs two completely different engines depending on the task:
36
+
37
+ | | Mode 1: Document Q&A | Mode 2: Code Analysis |
38
+ |---|---|---|
39
+ | **Engine** | Qwen2.5-3B + FAISS | Python AST (local, no LLM) |
40
+ | **Speed** | GPU inference | Instant (no model call) |
41
+ | **Input** | PDF, MD, CSV, TXT | `.py` files |
42
+ | **Output** | RAG-grounded answers | Structured issue reports |
43
+
44
+ ---
45
+
46
+ ## Mode 1 — Document Q&A (RAG)
47
+
48
+ Upload any document and ask questions in natural language.
49
+
50
+ **How it works:**
51
+ 1. Document is chunked and embedded via `sentence-transformers`
52
+ 2. Embeddings stored in a local **FAISS** index
53
+ 3. On query → top-5 most relevant chunks retrieved
54
+ 4. **Qwen2.5-3B** answers strictly from retrieved context — no hallucination beyond the document
55
+
56
+ **Tools:**
57
+ - `document_search` — retrieves top-5 chunks, generates a factual answer
58
+ - `summarizer` — identifies prominent sections, returns key bullet points
59
+
60
+ ---
61
+
62
+ ## Mode 2 — Code Analysis (AST-Powered)
63
+
64
+ Python code is parsed into an **Abstract Syntax Tree locally** — no LLM involved. Faster, safer, deterministic.
65
+
66
+ ### Code Analyzer
67
+ Detects Python anti-patterns with severity classification:
68
+
69
+ | Severity | Pattern |
70
+ |---|---|
71
+ | HIGH | Mutable default arguments (`def foo(x=[])`) |
72
+ | MEDIUM | Bare `except:` clauses, overly broad exception handling |
73
+ | LOW | Unused variables, deeply nested functions, long functions, low comment coverage |
74
+
75
+ ### Security Scanner
76
+ Regex-based detection of critical vulnerabilities:
77
+ - Hardcoded API keys and passwords
78
+ - SQL injection via string formatting inside `.execute()`
79
+ - Weak hashing: `MD5`, `SHA1`
80
+ - Dangerous builtins: `eval()`, `exec()`, `os.system()`
81
+ - Insecure deserialization: `pickle.loads()`
82
+
83
+ ### ▶ Code Executor
84
+ - Runs uploaded code in an **isolated shell**
85
+ - **5-second timeout** prevents infinite loops
86
+ - Captures stdout + stderr and returns terminal output
87
+
88
+ ### Test Generator
89
+ - Reads all functions in the uploaded file
90
+ - **Infers parameter types** from naming conventions (`count` → int, `name` → str)
91
+ - Auto-generates a full `pytest` suite with edge cases (`0`, `""`, `None`)
92
+ - Writes tests to a `test/` directory
93
+
94
+ ### Code Fixer
95
+ - Takes issues found by the Analyzer
96
+ - Generates structured fix suggestions with:
97
+ - Why it's a bug
98
+ - Before/after code snippet
99
+
100
+
101
+ ## Tech Stack
102
+
103
+ | Component | Technology |
104
+ |---|---|
105
+ | LLM | Qwen2.5-3B-Instruct (HuggingFace ZeroGPU) |
106
+ | Embeddings | sentence-transformers (all-MiniLM-L6-v2) |
107
+ | Vector Store | FAISS |
108
+ | Code Analysis | Python `ast` module |
109
+ | Security Scanning | Python `re` (regex) |
110
+ | UI | Gradio |
111
+ | Hosting | HuggingFace Spaces + ZeroGPU |
112
+
113
+ ---
114