MERGE CONFLICTS SOLVED
Browse files- .gitattributes +35 -0
- README.md +14 -14
- docs/DEPLOYMENT.md +218 -0
- website +1 -1
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -142,20 +142,20 @@ The frontend at `app/static/index.html` calls the API with `fetch`:
|
|
| 142 |
|
| 143 |
```html
|
| 144 |
<script>
|
| 145 |
-
async function analyze(username) {
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
| 155 |
}
|
| 156 |
-
|
| 157 |
-
return response.json();
|
| 158 |
-
}
|
| 159 |
</script>
|
| 160 |
```
|
| 161 |
|
|
@@ -165,7 +165,7 @@ Use a full base URL only when the HTML is hosted somewhere else:
|
|
| 165 |
fetch("https://your-domain.com/analyze", {
|
| 166 |
method: "POST",
|
| 167 |
headers: { "Content-Type": "application/json" },
|
| 168 |
-
body: JSON.stringify({ username: "octocat" })
|
| 169 |
});
|
| 170 |
```
|
| 171 |
|
|
|
|
| 142 |
|
| 143 |
```html
|
| 144 |
<script>
|
| 145 |
+
async function analyze(username) {
|
| 146 |
+
const response = await fetch("/analyze", {
|
| 147 |
+
method: "POST",
|
| 148 |
+
headers: { "Content-Type": "application/json" },
|
| 149 |
+
body: JSON.stringify({ username }),
|
| 150 |
+
});
|
| 151 |
+
|
| 152 |
+
if (!response.ok) {
|
| 153 |
+
const error = await response.json();
|
| 154 |
+
throw new Error(error.detail || "Analyze request failed");
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
return response.json();
|
| 158 |
}
|
|
|
|
|
|
|
|
|
|
| 159 |
</script>
|
| 160 |
```
|
| 161 |
|
|
|
|
| 165 |
fetch("https://your-domain.com/analyze", {
|
| 166 |
method: "POST",
|
| 167 |
headers: { "Content-Type": "application/json" },
|
| 168 |
+
body: JSON.stringify({ username: "octocat" }),
|
| 169 |
});
|
| 170 |
```
|
| 171 |
|
docs/DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deployment Guide: Hugging Face Spaces
|
| 2 |
+
|
| 3 |
+
This guide deploys the FastAPI app as a Hugging Face Docker Space.
|
| 4 |
+
|
| 5 |
+
Hugging Face Spaces supports Docker apps, and a Docker Space is configured by adding `sdk: docker` to the YAML block at the top of the Space `README.md`. Docker Spaces commonly expose port `7860`; the app, Dockerfile, and Space metadata must all use the same port.
|
| 6 |
+
|
| 7 |
+
Official references:
|
| 8 |
+
|
| 9 |
+
- Hugging Face Docker Spaces: https://huggingface.co/docs/hub/main/spaces-sdks-docker
|
| 10 |
+
- Hugging Face Spaces overview: https://huggingface.co/docs/hub/main/spaces-overview
|
| 11 |
+
|
| 12 |
+
## What Gets Deployed
|
| 13 |
+
|
| 14 |
+
The Hugging Face Space should deploy the backend API and built-in analyzer UI:
|
| 15 |
+
|
| 16 |
+
- `GET /` serves `app/static/index.html`
|
| 17 |
+
- `GET /health` returns API health
|
| 18 |
+
- `POST /analyze` rates a GitHub username
|
| 19 |
+
|
| 20 |
+
The separate React documentation website in `website/` can be deployed separately as a static site. The Space deployment described here focuses on the FastAPI app.
|
| 21 |
+
|
| 22 |
+
## Prerequisites
|
| 23 |
+
|
| 24 |
+
1. A Hugging Face account.
|
| 25 |
+
2. Git installed locally.
|
| 26 |
+
3. Optional but recommended: a valid GitHub token for higher API limits.
|
| 27 |
+
|
| 28 |
+
Create a GitHub token and save it as a Hugging Face Space secret named:
|
| 29 |
+
|
| 30 |
+
```text
|
| 31 |
+
GITHUB_TOKEN
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Public/no-token mode works, but GitHub rate limits unauthenticated requests heavily.
|
| 35 |
+
|
| 36 |
+
## Create The Space
|
| 37 |
+
|
| 38 |
+
1. Go to https://huggingface.co/spaces
|
| 39 |
+
2. Click **Create new Space**.
|
| 40 |
+
3. Choose an owner and Space name.
|
| 41 |
+
4. Select **Docker** as the SDK.
|
| 42 |
+
5. Choose public or private visibility.
|
| 43 |
+
6. Create the Space.
|
| 44 |
+
|
| 45 |
+
## Space README Metadata
|
| 46 |
+
|
| 47 |
+
In the Hugging Face Space repository, the top of `README.md` should include:
|
| 48 |
+
|
| 49 |
+
```yaml
|
| 50 |
+
---
|
| 51 |
+
title: GitHub Profile AI Reviewer
|
| 52 |
+
emoji: 🧪
|
| 53 |
+
colorFrom: green
|
| 54 |
+
colorTo: blue
|
| 55 |
+
sdk: docker
|
| 56 |
+
app_port: 7860
|
| 57 |
+
---
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
The important lines are:
|
| 61 |
+
|
| 62 |
+
```yaml
|
| 63 |
+
sdk: docker
|
| 64 |
+
app_port: 7860
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## Hugging Face Dockerfile
|
| 68 |
+
|
| 69 |
+
Hugging Face expects the app to listen on the configured Space port. Use this Dockerfile for the Space:
|
| 70 |
+
|
| 71 |
+
```dockerfile
|
| 72 |
+
FROM python:3.12-slim
|
| 73 |
+
|
| 74 |
+
WORKDIR /app
|
| 75 |
+
|
| 76 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 77 |
+
ENV PYTHONUNBUFFERED=1
|
| 78 |
+
ENV APP_HOST=0.0.0.0
|
| 79 |
+
ENV APP_PORT=7860
|
| 80 |
+
|
| 81 |
+
COPY requirements.txt ./
|
| 82 |
+
RUN pip install --no-cache-dir --upgrade pip \
|
| 83 |
+
&& pip install --no-cache-dir -r requirements.txt
|
| 84 |
+
|
| 85 |
+
COPY . .
|
| 86 |
+
|
| 87 |
+
EXPOSE 7860
|
| 88 |
+
|
| 89 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
Why this differs from local Docker:
|
| 93 |
+
|
| 94 |
+
- Hugging Face Docker Spaces commonly expose `7860`.
|
| 95 |
+
- The production API does not require `torch` or `transformers`; default `requirements.txt` is enough.
|
| 96 |
+
- `requirements-ml.txt` is optional and should not be installed unless you intentionally want the heavier ML stack.
|
| 97 |
+
|
| 98 |
+
## Environment Variables And Secrets
|
| 99 |
+
|
| 100 |
+
Set these in the Hugging Face Space **Settings** tab.
|
| 101 |
+
|
| 102 |
+
Secrets:
|
| 103 |
+
|
| 104 |
+
```text
|
| 105 |
+
GITHUB_TOKEN=your_valid_github_token_here
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
Variables:
|
| 109 |
+
|
| 110 |
+
```text
|
| 111 |
+
GITHUB_API_URL=https://api.github.com/graphql
|
| 112 |
+
GITHUB_REST_API_URL=https://api.github.com
|
| 113 |
+
GITHUB_PUBLIC_REPO_LIMIT=20
|
| 114 |
+
GITHUB_FETCH_COMMIT_COUNTS=false
|
| 115 |
+
GITHUB_CACHE_TTL_SECONDS=900
|
| 116 |
+
APP_HOST=0.0.0.0
|
| 117 |
+
APP_PORT=7860
|
| 118 |
+
SCORING_BACKEND=heuristic
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
Do not commit `.env` to Hugging Face or GitHub. Use Hugging Face Space secrets for private values.
|
| 122 |
+
|
| 123 |
+
## Push Code To The Space
|
| 124 |
+
|
| 125 |
+
From your local repo:
|
| 126 |
+
|
| 127 |
+
```bash
|
| 128 |
+
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
| 129 |
+
git push hf main
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
If your app is on another branch, push that branch to `main` on the Space:
|
| 133 |
+
|
| 134 |
+
```bash
|
| 135 |
+
git push hf your-branch:main
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
Hugging Face rebuilds the Space automatically after each push.
|
| 139 |
+
|
| 140 |
+
## Test The Deployed App
|
| 141 |
+
|
| 142 |
+
After the Space finishes building:
|
| 143 |
+
|
| 144 |
+
```text
|
| 145 |
+
https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space/
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
Health check:
|
| 149 |
+
|
| 150 |
+
```text
|
| 151 |
+
https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space/health
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
Analyze request:
|
| 155 |
+
|
| 156 |
+
```bash
|
| 157 |
+
curl -X POST https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space/analyze \
|
| 158 |
+
-H "Content-Type: application/json" \
|
| 159 |
+
-d '{"username":"octocat"}'
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
Expected response includes:
|
| 163 |
+
|
| 164 |
+
```json
|
| 165 |
+
{
|
| 166 |
+
"username": "octocat",
|
| 167 |
+
"rating_score": 72,
|
| 168 |
+
"public_activity": {
|
| 169 |
+
"public_commits": 18,
|
| 170 |
+
"public_prs_created": 4
|
| 171 |
+
},
|
| 172 |
+
"model_info": {
|
| 173 |
+
"data_source": "graphql"
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
## Troubleshooting
|
| 179 |
+
|
| 180 |
+
### Space stuck on Starting
|
| 181 |
+
|
| 182 |
+
Check that all three ports match:
|
| 183 |
+
|
| 184 |
+
- Space README: `app_port: 7860`
|
| 185 |
+
- Dockerfile: `EXPOSE 7860`
|
| 186 |
+
- Uvicorn command: `--port 7860`
|
| 187 |
+
|
| 188 |
+
### GitHub API rate limit exceeded
|
| 189 |
+
|
| 190 |
+
Add a valid `GITHUB_TOKEN` as a Hugging Face Space secret and restart/rebuild the Space.
|
| 191 |
+
|
| 192 |
+
### Bad credentials
|
| 193 |
+
|
| 194 |
+
Your `GITHUB_TOKEN` is invalid or expired. Replace it in Space secrets, then restart the Space.
|
| 195 |
+
|
| 196 |
+
### Module import errors
|
| 197 |
+
|
| 198 |
+
Make sure `requirements.txt` is installed in the Dockerfile. Do not rely on local virtual environments.
|
| 199 |
+
|
| 200 |
+
### Heavy image or slow build
|
| 201 |
+
|
| 202 |
+
Use the lightweight `requirements.txt`. Avoid installing `requirements-ml.txt` unless you actually need `torch`, `transformers`, and `langgraph`.
|
| 203 |
+
|
| 204 |
+
## React Documentation Website
|
| 205 |
+
|
| 206 |
+
The React documentation website lives in `website/`.
|
| 207 |
+
|
| 208 |
+
To deploy it separately:
|
| 209 |
+
|
| 210 |
+
```bash
|
| 211 |
+
cd website
|
| 212 |
+
npm install
|
| 213 |
+
npm run build
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
Deploy `website/dist/` to a static host such as Hugging Face Static HTML Space, Netlify, Vercel, or GitHub Pages.
|
| 217 |
+
|
| 218 |
+
If deploying the React docs to a Hugging Face Static HTML Space, configure the Space as Static HTML and upload the built `dist/` contents.
|
website
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
Subproject commit
|
|
|
|
| 1 |
+
Subproject commit d56651de4c2c696137145547e8277055cd25d500
|