Spaces:
Build error
Build error
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,231 +1,20 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
```text
|
| 22 |
-
streamlit==1.32.0 # Web UI framework
|
| 23 |
-
pandas==2.0.0 # Data manipulation
|
| 24 |
-
matplotlib==3.7.0 # Basic visualization
|
| 25 |
-
seaborn==0.12.2 # Advanced plots
|
| 26 |
-
plotly==5.18.0 # Interactive charts
|
| 27 |
-
requests==2.31.0 # API calls (Groq)
|
| 28 |
-
langchain==0.1.0 # LLM interface (if used)
|
| 29 |
-
python-dotenv==1.0.0 # Environment variables
|
| 30 |
-
```
|
| 31 |
-
|
| 32 |
-
### **Optional/Implicit Dependencies**
|
| 33 |
-
```text
|
| 34 |
-
numpy==1.24.0 # (Auto-installed with pandas)
|
| 35 |
-
scipy==1.10.0 # (For stats operations)
|
| 36 |
-
fuzzywuzzy==0.18.0 # (For column name matching - if used)
|
| 37 |
-
```
|
| 38 |
-
|
| 39 |
-
---
|
| 40 |
-
|
| 41 |
-
### **Notes**:
|
| 42 |
-
1. **Groq API**: No Python SDK required (uses raw `requests`).
|
| 43 |
-
2. **Virtual Environment**: Recommended to avoid conflicts:
|
| 44 |
-
```bash
|
| 45 |
-
python -m venv venv
|
| 46 |
-
source venv/bin/activate # Linux/Mac
|
| 47 |
-
venv\Scripts\activate # Windows
|
| 48 |
-
pip install -r requirements.txt
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
3. **Production Considerations**:
|
| 52 |
-
- Add `gunicorn` for deployment:
|
| 53 |
-
```text
|
| 54 |
-
gunicorn==20.1.0
|
| 55 |
-
```
|
| 56 |
-
- For Windows, use `waitress`:
|
| 57 |
-
```text
|
| 58 |
-
waitress==2.1.2
|
| 59 |
-
```
|
| 60 |
-
|
| 61 |
-
Let me know if you need version adjustments or encounter dependency conflicts!
|
| 62 |
-
---
|
| 63 |
-
|
| 64 |
-
## **2. System Architecture**
|
| 65 |
-
|
| 66 |
-
### **2.1 Component Diagram**
|
| 67 |
-
```mermaid
|
| 68 |
-
flowchart TB
|
| 69 |
-
subgraph Frontend
|
| 70 |
-
A[Streamlit UI] --> B[File Uploader]
|
| 71 |
-
A --> C[Code Editor]
|
| 72 |
-
A --> D[Output Display]
|
| 73 |
-
end
|
| 74 |
-
|
| 75 |
-
subgraph Backend
|
| 76 |
-
B --> E[Data Processor]
|
| 77 |
-
C --> F[Code Executor]
|
| 78 |
-
C --> G[Groq LLM API]
|
| 79 |
-
F --> H[Session State]
|
| 80 |
-
end
|
| 81 |
-
|
| 82 |
-
subgraph External
|
| 83 |
-
G -->|API Calls| I[Groq Cloud]
|
| 84 |
-
end
|
| 85 |
-
```
|
| 86 |
-
|
| 87 |
-
### **2.2 Data Flow**
|
| 88 |
-
1. **Input**: CSV files → Pandas DataFrame
|
| 89 |
-
2. **Processing**: Merge/clean data → Modified DataFrame
|
| 90 |
-
3. **Execution**: Python code → Results (text/plots/variables)
|
| 91 |
-
4. **Output**: Visualizations + Export files
|
| 92 |
-
|
| 93 |
-
---
|
| 94 |
-
|
| 95 |
-
## **3. Installation**
|
| 96 |
-
|
| 97 |
-
### **3.1 Prerequisites**
|
| 98 |
-
- Python 3.8+
|
| 99 |
-
- `pip` package manager
|
| 100 |
-
|
| 101 |
-
### **3.2 Setup**
|
| 102 |
-
```bash
|
| 103 |
-
# Clone repository
|
| 104 |
-
git clone https://github.com/yourrepo/datacoder-ai.git
|
| 105 |
-
cd datacoder-ai
|
| 106 |
-
|
| 107 |
-
# Install dependencies
|
| 108 |
-
pip install -r requirements.txt
|
| 109 |
-
|
| 110 |
-
# Run the app
|
| 111 |
-
streamlit run app.py
|
| 112 |
-
```
|
| 113 |
-
|
| 114 |
-
### **3.3 Configuration**
|
| 115 |
-
Rename `.env.example` to `.env` and add your Groq API key:
|
| 116 |
-
```env
|
| 117 |
-
GROQ_API_KEY=your_api_key_here
|
| 118 |
-
```
|
| 119 |
-
|
| 120 |
-
---
|
| 121 |
-
|
| 122 |
-
## **4. User Guide**
|
| 123 |
-
|
| 124 |
-
### **4.1 Data Upload**
|
| 125 |
-
1. Click **"Upload CSV file(s)"**
|
| 126 |
-
2. Select 1+ CSV files
|
| 127 |
-
3. Configure merge options:
|
| 128 |
-
- **Horizontal**: Combine columns (align by index)
|
| 129 |
-
- **Vertical**: Stack rows
|
| 130 |
-
|
| 131 |
-
### **4.2 Data Cleaning**
|
| 132 |
-
| Feature | How to Use |
|
| 133 |
-
|------------------|----------------------------------------|
|
| 134 |
-
| Handle NaN | Select: Keep/Remove/Fill with mean |
|
| 135 |
-
| Remove Duplicates| Choose: Keep first/last/all |
|
| 136 |
-
| Rename Columns | Enter: `old_name:new_name` |
|
| 137 |
-
| Drop Columns | Enter comma-separated column names |
|
| 138 |
-
|
| 139 |
-
### **4.3 Code Execution**
|
| 140 |
-
#### **Auto-Run Mode**
|
| 141 |
-
1. Type request (e.g., "Plot sales distribution")
|
| 142 |
-
2. Click **▶️ Execute** → AI generates and runs code
|
| 143 |
-
|
| 144 |
-
#### **Manual Mode**
|
| 145 |
-
1. Write/edit Python code
|
| 146 |
-
2. Click **▶️ Execute**
|
| 147 |
-
|
| 148 |
-
### **4.4 Chat Assistant**
|
| 149 |
-
Ask questions like:
|
| 150 |
-
- _"How to normalize this data?"_
|
| 151 |
-
- _"Explain the output of this code"_
|
| 152 |
-
|
| 153 |
-
---
|
| 154 |
-
|
| 155 |
-
## **5. API Reference**
|
| 156 |
-
|
| 157 |
-
### **5.1 Core Functions**
|
| 158 |
-
#### `execute_code(code: str, df: pd.DataFrame) -> dict`
|
| 159 |
-
**Parameters**:
|
| 160 |
-
- `code`: Python code to execute
|
| 161 |
-
- `df`: Target DataFrame
|
| 162 |
-
|
| 163 |
-
**Returns**:
|
| 164 |
-
```python
|
| 165 |
-
{
|
| 166 |
-
"success": bool,
|
| 167 |
-
"stdout": str, # Console output
|
| 168 |
-
"figure": Figure, # Matplotlib plot
|
| 169 |
-
"variables": dict # New variables created
|
| 170 |
-
}
|
| 171 |
-
```
|
| 172 |
-
|
| 173 |
-
#### `analyze_code_execution(code: str, execution_result: dict, df: pd.DataFrame) -> str`
|
| 174 |
-
Generates natural language analysis of results in **Indonesian**.
|
| 175 |
-
|
| 176 |
-
### **5.2 LLM Classes**
|
| 177 |
-
#### `GroqLLM()`
|
| 178 |
-
- **Model**: `qwen-2.5-coder-32b`
|
| 179 |
-
- **Temperature**: 0.3
|
| 180 |
-
- **Purpose**: Code generation
|
| 181 |
-
|
| 182 |
-
#### `GroqTextLLM()`
|
| 183 |
-
- **Model**: `deepseek-r1-distill-llama-70b`
|
| 184 |
-
- **Temperature**: 0.7
|
| 185 |
-
- **Purpose**: Chat explanations
|
| 186 |
-
|
| 187 |
-
---
|
| 188 |
-
|
| 189 |
-
## **6. Examples**
|
| 190 |
-
|
| 191 |
-
### **6.1 Sample Workflow**
|
| 192 |
-
```python
|
| 193 |
-
# AI-Generated Code Example (Auto-Run)
|
| 194 |
-
import matplotlib.pyplot as plt
|
| 195 |
-
plt.figure(figsize=(10, 6))
|
| 196 |
-
df['sales'].plot(kind='hist', bins=20)
|
| 197 |
-
plt.title('Sales Distribution')
|
| 198 |
-
plt.show()
|
| 199 |
-
```
|
| 200 |
-
|
| 201 |
-
### **6.2 Expected Output**
|
| 202 |
-
1. Histogram plot rendered
|
| 203 |
-
2. Console output:
|
| 204 |
-
```text
|
| 205 |
-
Plot generated for column: sales
|
| 206 |
-
```
|
| 207 |
-
|
| 208 |
-
---
|
| 209 |
-
|
| 210 |
-
## **7. Troubleshooting**
|
| 211 |
-
|
| 212 |
-
| Issue | Solution |
|
| 213 |
-
|--------------------------------|----------------------------------------|
|
| 214 |
-
| Groq API errors | Check quota/network connection |
|
| 215 |
-
| CSV parsing fails | Verify delimiter (use `delimiter=';'`)|
|
| 216 |
-
| Plot not showing | Ensure `plt.show()` is called |
|
| 217 |
-
|
| 218 |
-
---
|
| 219 |
-
|
| 220 |
-
## **8. License & Contribution**
|
| 221 |
-
- **License**: MIT
|
| 222 |
-
- **Contribute**: Fork + PRs welcome
|
| 223 |
-
|
| 224 |
-
---
|
| 225 |
-
|
| 226 |
-
**Notes for Production**:
|
| 227 |
-
1. Replace hardcoded API keys with environment variables
|
| 228 |
-
2. Add user authentication for multi-user support
|
| 229 |
-
3. Implement rate limiting for Groq API calls
|
| 230 |
-
|
| 231 |
-
For full source code, visit: [GitHub Repository Link]
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: DataCoder AI
|
| 3 |
+
emoji: 📊
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: pink
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
sdk_version: 1.31.1
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
short_description: 🚀 A web-based interactive data analysis tool using LLM mode
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
tress`:
|
| 15 |
+
```text
|
| 16 |
+
waitress==2.1.2
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
Let me know if you need version adjustments or encounter dependency conflicts!
|
| 20 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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