Spaces:
Runtime error
Runtime error
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,10 +1,109 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: purple
|
| 6 |
-
sdk:
|
|
|
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: DevDeCode
|
| 4 |
+
emoji: π‘
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: purple
|
| 7 |
+
sdk: gradio
|
| 8 |
+
sdk_version: 5.32.0
|
| 9 |
+
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# π‘ DevDeCode β Code Explanation API using Phi-3 & LangChain
|
| 14 |
+
|
| 15 |
+
DevDeCode is a FastAPI-powered backend that integrates Microsoft's Phi-3 Mini model using Hugging Face Transformers and LangChain. It takes Python code as input and returns a step-by-step explanation. Designed for developers and learners, this API simplifies code understanding using LLMs.
|
| 16 |
+
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
## π Features
|
| 20 |
+
|
| 21 |
+
- π§ Powered by Phi-3 Mini (4K Instruct)
|
| 22 |
+
- π Built with LangChain for structured LLM workflows
|
| 23 |
+
- π Hosted using FastAPI with auto-generated Swagger docs
|
| 24 |
+
- π CORS-enabled for easy frontend integration
|
| 25 |
+
- π§ͺ Uses `StrOutputParser` for clean output formatting
|
| 26 |
+
- π©οΈ (Optional) Ngrok integration for public URL testing
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
## π οΈ Tech Stack
|
| 31 |
+
|
| 32 |
+
| Technology | Description |
|
| 33 |
+
|----------------------|---------------------------------------------------------------------|
|
| 34 |
+
| **FastAPI** | Web framework for building the RESTful API |
|
| 35 |
+
| **LangChain** | Manages prompt templates, model pipeline, and parsing logic |
|
| 36 |
+
| **Transformers** | Hugging Face library for using and fine-tuning pretrained models |
|
| 37 |
+
| **Phi-3 Mini** | Lightweight instruction-tuned language model from Microsoft |
|
| 38 |
+
| **Hugging Face Hub** | Model access, authentication, and (optional) deployment to Spaces |
|
| 39 |
+
| **Uvicorn** | ASGI server to run the FastAPI app |
|
| 40 |
+
| **PyTorch** | Deep learning backend for model execution |
|
| 41 |
+
| **Ngrok** *(optional)* | Tunnels localhost for public access during development |
|
| 42 |
+
| **CORS Middleware** | Enables smooth frontend-to-backend communication |
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## π¦ Setup
|
| 47 |
+
|
| 48 |
+
1. **Install dependencies**
|
| 49 |
+
```bash
|
| 50 |
+
pip install -r requirements.txt
|
| 51 |
+
```
|
| 52 |
+
*Make sure your system supports CUDA or fallback to CPU by modifying `torch_dtype` and `device_map` in your code.*
|
| 53 |
+
|
| 54 |
+
2. **Run Locally**
|
| 55 |
+
```bash
|
| 56 |
+
python app.py
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## π Deployment
|
| 62 |
+
|
| 63 |
+
### Deploy to Hugging Face Spaces
|
| 64 |
+
|
| 65 |
+
Ensure your repo includes:
|
| 66 |
+
- `README.md`
|
| 67 |
+
- `requirements.txt`
|
| 68 |
+
- `app.py`
|
| 69 |
+
- `huggingface.yml` *(optional but useful)*
|
| 70 |
+
|
| 71 |
+
You can use the `huggingface_hub` Python SDK or upload via the UI.
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## ποΈ API Endpoint
|
| 76 |
+
|
| 77 |
+
- **Base URL:** `/explain`
|
| 78 |
+
- **Method:** `POST`
|
| 79 |
+
- **Input:**
|
| 80 |
+
```json
|
| 81 |
+
{
|
| 82 |
+
"code": "your_python_code_here"
|
| 83 |
+
}
|
| 84 |
+
```
|
| 85 |
+
- **Output:**
|
| 86 |
+
```json
|
| 87 |
+
{
|
| 88 |
+
"output": "Step-by-step explanation of the code..."
|
| 89 |
+
}
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
+
## π License
|
| 95 |
+
|
| 96 |
+
MIT License Β© 2025 [Your Name]
|
| 97 |
+
|
| 98 |
+
---
|
| 99 |
+
|
| 100 |
+
## π Acknowledgements
|
| 101 |
+
|
| 102 |
+
- Microsoft for Phi-3
|
| 103 |
+
- Hugging Face for their incredible ecosystem
|
| 104 |
+
- LangChain for making LLM orchestration simple
|
| 105 |
+
|
| 106 |
+
---
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
Let me know if you want me to generate the `requirements.txt` or a huggingface.yml` file for deployment!
|