Commit ·
1a1dc00
1
Parent(s): fdb66ba
update
Browse filesCo-authored-by: Copilot <copilot@github.com>
README.md
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# GitConnect FastAPI Service
|
| 2 |
|
| 3 |
-
FastAPI backend with two
|
| 4 |
-
|
| 5 |
-
-
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
- Uses local Hugging Face sentence embeddings (default: `sentence-transformers/all-MiniLM-L6-v2`).
|
| 9 |
-
- Uses FAISS (`IndexFlatIP` with L2-normalized vectors) for similarity search.
|
| 10 |
-
- Gemini is used for summarization and chatbot generation.
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
2. Install dependencies:
|
| 16 |
|
| 17 |
```bash
|
| 18 |
pip install -r requirements.txt
|
| 19 |
```
|
| 20 |
|
| 21 |
-
3. Create `.env` from `.env.example` and
|
| 22 |
-
4. Run
|
| 23 |
|
| 24 |
```bash
|
| 25 |
uvicorn app.main:app --reload
|
|
@@ -31,36 +46,39 @@ uvicorn app.main:app --reload
|
|
| 31 |
- `POST /api/syllabus/process`
|
| 32 |
- `POST /api/chat`
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
Files used for deployment:
|
| 39 |
- `Dockerfile`
|
| 40 |
- `requirements.txt`
|
| 41 |
- `app/`
|
| 42 |
- `.github/workflows/deploy-hf-space.yml`
|
| 43 |
|
| 44 |
-
Files
|
|
|
|
| 45 |
- `.env` and `app/.env`
|
| 46 |
-
- `data/`
|
| 47 |
- local caches and `__pycache__/`
|
| 48 |
|
| 49 |
-
GitHub Action deployment:
|
| 50 |
-
- Trigger: push to `main` or manual run
|
| 51 |
-
- Workflow file: `.github/workflows/deploy-hf-space.yml`
|
| 52 |
-
|
| 53 |
-
Required GitHub repository secrets:
|
| 54 |
-
- `HF_TOKEN`: Hugging Face write token
|
| 55 |
-
- `HF_SPACE_REPO_ID`: in format `username/space-name`
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
|
| 60 |
-
- `STUDENT_PERFORMANCE_URL_TEMPLATE` (default)
|
| 61 |
-
- `https://git-connect-backend-v2.vercel.app/api/student/{student_id}/performance`
|
| 62 |
|
| 63 |
-
|
| 64 |
|
| 65 |
```json
|
| 66 |
[
|
|
@@ -74,7 +92,7 @@ Student performance is fetched from:
|
|
| 74 |
]
|
| 75 |
```
|
| 76 |
|
| 77 |
-
|
| 78 |
|
| 79 |
```json
|
| 80 |
{
|
|
@@ -83,8 +101,12 @@ Student performance is fetched from:
|
|
| 83 |
{"role": "user", "content": "Hi"},
|
| 84 |
{"role": "assistant", "content": "Hello"}
|
| 85 |
],
|
| 86 |
-
"student_id":
|
| 87 |
"lang_code": "en",
|
| 88 |
"semester": 5
|
| 89 |
}
|
| 90 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: GitConnect FastAPI Service
|
| 3 |
+
emoji: "🚀"
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
sdk_version: "1.0.0"
|
| 8 |
+
python_version: "3.12"
|
| 9 |
+
app_file: app.py
|
| 10 |
+
pinned: false
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
# GitConnect FastAPI Service
|
| 14 |
|
| 15 |
+
FastAPI backend with two primary features:
|
| 16 |
+
|
| 17 |
+
- Syllabus processing from PDF URLs with FAISS indexing and multilingual AI summaries.
|
| 18 |
+
- Chatbot responses grounded with RAG from both syllabus content and student performance data.
|
| 19 |
|
| 20 |
+
## Core Stack
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
- API: FastAPI + Uvicorn
|
| 23 |
+
- Embeddings: sentence-transformers/all-MiniLM-L6-v2
|
| 24 |
+
- Vector Search: FAISS (IndexFlatIP with normalized vectors)
|
| 25 |
+
- LLM generation/summarization: Gemini
|
| 26 |
|
| 27 |
+
## Local Setup
|
| 28 |
+
|
| 29 |
+
1. Create and activate a virtual environment.
|
| 30 |
2. Install dependencies:
|
| 31 |
|
| 32 |
```bash
|
| 33 |
pip install -r requirements.txt
|
| 34 |
```
|
| 35 |
|
| 36 |
+
3. Create `.env` from `.env.example` and set `GEMINI_API_KEY`.
|
| 37 |
+
4. Run the service:
|
| 38 |
|
| 39 |
```bash
|
| 40 |
uvicorn app.main:app --reload
|
|
|
|
| 46 |
- `POST /api/syllabus/process`
|
| 47 |
- `POST /api/chat`
|
| 48 |
|
| 49 |
+
Student performance source:
|
| 50 |
+
|
| 51 |
+
- `STUDENT_PERFORMANCE_URL_TEMPLATE` (default)
|
| 52 |
+
- `https://git-connect-backend-v2.vercel.app/api/student/{student_id}/performance`
|
| 53 |
+
|
| 54 |
+
## Hugging Face Spaces Deployment
|
| 55 |
+
|
| 56 |
+
This repository is set up for Docker Spaces deployment.
|
| 57 |
|
| 58 |
+
Deployment-critical files:
|
| 59 |
|
|
|
|
| 60 |
- `Dockerfile`
|
| 61 |
- `requirements.txt`
|
| 62 |
- `app/`
|
| 63 |
- `.github/workflows/deploy-hf-space.yml`
|
| 64 |
|
| 65 |
+
Files excluded from git push:
|
| 66 |
+
|
| 67 |
- `.env` and `app/.env`
|
| 68 |
+
- generated `data/` files
|
| 69 |
- local caches and `__pycache__/`
|
| 70 |
|
| 71 |
+
GitHub Action deployment workflow:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
- Trigger: push to `main` or manual run
|
| 74 |
+
- Workflow: `.github/workflows/deploy-hf-space.yml`
|
| 75 |
+
- Required repository secrets:
|
| 76 |
+
- `HF_TOKEN`
|
| 77 |
+
- `HF_SPACE_REPO_ID` (format: `username/space-name`)
|
| 78 |
|
| 79 |
+
## Sample Requests
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
Syllabus processing:
|
| 82 |
|
| 83 |
```json
|
| 84 |
[
|
|
|
|
| 92 |
]
|
| 93 |
```
|
| 94 |
|
| 95 |
+
Chat:
|
| 96 |
|
| 97 |
```json
|
| 98 |
{
|
|
|
|
| 101 |
{"role": "user", "content": "Hi"},
|
| 102 |
{"role": "assistant", "content": "Hello"}
|
| 103 |
],
|
| 104 |
+
"student_id": 2,
|
| 105 |
"lang_code": "en",
|
| 106 |
"semester": 5
|
| 107 |
}
|
| 108 |
```
|
| 109 |
+
|
| 110 |
+
Configuration reference:
|
| 111 |
+
|
| 112 |
+
- https://huggingface.co/docs/hub/spaces-config-reference
|