Spaces:
Running
Running
ming
commited on
Commit
Β·
56b5c90
1
Parent(s):
c7cef80
docs: update README with live deployment status and working URLs
Browse files- Add live deployment section with working Space URL
- Update all code examples to use actual deployed Space
- Add quick test commands for live API
- Document successful 404 fix and proxy-aware setup
- Include test script usage instructions
README.md
CHANGED
|
@@ -40,6 +40,24 @@ POST /api/v1/summarize/pipeline/stream
|
|
| 40 |
POST /api/v2/summarize/stream
|
| 41 |
```
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
**Request Format (V1 and V2 compatible):**
|
| 44 |
```json
|
| 45 |
{
|
|
@@ -153,10 +171,11 @@ pytest --cov=app
|
|
| 153 |
### V1 API (Ollama)
|
| 154 |
```python
|
| 155 |
import requests
|
|
|
|
| 156 |
|
| 157 |
# V1 streaming summarization
|
| 158 |
response = requests.post(
|
| 159 |
-
"https://
|
| 160 |
json={
|
| 161 |
"text": "Your long article or text here...",
|
| 162 |
"max_tokens": 256
|
|
@@ -172,14 +191,14 @@ for line in response.iter_lines():
|
|
| 172 |
break
|
| 173 |
```
|
| 174 |
|
| 175 |
-
### V2 API (HuggingFace Streaming)
|
| 176 |
```python
|
| 177 |
import requests
|
| 178 |
import json
|
| 179 |
|
| 180 |
# V2 streaming summarization (same request format as V1)
|
| 181 |
response = requests.post(
|
| 182 |
-
"https://
|
| 183 |
json={
|
| 184 |
"text": "Your long article or text here...",
|
| 185 |
"max_tokens": 128 # V2 uses max_new_tokens
|
|
@@ -200,7 +219,7 @@ for line in response.iter_lines():
|
|
| 200 |
// Android SSE client example
|
| 201 |
val client = OkHttpClient()
|
| 202 |
val request = Request.Builder()
|
| 203 |
-
.url("https://
|
| 204 |
.post(RequestBody.create(
|
| 205 |
MediaType.parse("application/json"),
|
| 206 |
"""{"text": "Your text...", "max_tokens": 128}"""
|
|
@@ -227,17 +246,26 @@ client.newCall(request).enqueue(object : Callback {
|
|
| 227 |
|
| 228 |
### cURL Examples
|
| 229 |
```bash
|
| 230 |
-
#
|
| 231 |
-
curl
|
|
|
|
|
|
|
|
|
|
| 232 |
-H "Content-Type: application/json" \
|
| 233 |
-d '{"text": "Your text...", "max_tokens": 256}'
|
| 234 |
|
| 235 |
-
# V2 API (
|
| 236 |
-
curl -X POST "https://
|
| 237 |
-H "Content-Type: application/json" \
|
| 238 |
-d '{"text": "Your text...", "max_tokens": 128}'
|
| 239 |
```
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
## π Security
|
| 242 |
|
| 243 |
- Non-root user execution
|
|
@@ -279,5 +307,20 @@ MIT License - see LICENSE file for details.
|
|
| 279 |
|
| 280 |
---
|
| 281 |
|
| 282 |
-
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
POST /api/v2/summarize/stream
|
| 41 |
```
|
| 42 |
|
| 43 |
+
## π Live Deployment
|
| 44 |
+
|
| 45 |
+
**β
Successfully deployed and tested on Hugging Face Spaces!**
|
| 46 |
+
|
| 47 |
+
- **Live Space:** https://colin730-SummarizerApp.hf.space
|
| 48 |
+
- **API Documentation:** https://colin730-SummarizerApp.hf.space/docs
|
| 49 |
+
- **Health Check:** https://colin730-SummarizerApp.hf.space/health
|
| 50 |
+
- **V2 Streaming API:** https://colin730-SummarizerApp.hf.space/api/v2/summarize/stream
|
| 51 |
+
|
| 52 |
+
### Quick Test
|
| 53 |
+
```bash
|
| 54 |
+
# Test the live deployment
|
| 55 |
+
curl https://colin730-SummarizerApp.hf.space/health
|
| 56 |
+
curl -X POST https://colin730-SummarizerApp.hf.space/api/v2/summarize/stream \
|
| 57 |
+
-H "Content-Type: application/json" \
|
| 58 |
+
-d '{"text":"This is a test of the live API.","max_tokens":50}'
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
**Request Format (V1 and V2 compatible):**
|
| 62 |
```json
|
| 63 |
{
|
|
|
|
| 171 |
### V1 API (Ollama)
|
| 172 |
```python
|
| 173 |
import requests
|
| 174 |
+
import json
|
| 175 |
|
| 176 |
# V1 streaming summarization
|
| 177 |
response = requests.post(
|
| 178 |
+
"https://colin730-SummarizerApp.hf.space/api/v1/summarize/stream",
|
| 179 |
json={
|
| 180 |
"text": "Your long article or text here...",
|
| 181 |
"max_tokens": 256
|
|
|
|
| 191 |
break
|
| 192 |
```
|
| 193 |
|
| 194 |
+
### V2 API (HuggingFace Streaming) - Recommended
|
| 195 |
```python
|
| 196 |
import requests
|
| 197 |
import json
|
| 198 |
|
| 199 |
# V2 streaming summarization (same request format as V1)
|
| 200 |
response = requests.post(
|
| 201 |
+
"https://colin730-SummarizerApp.hf.space/api/v2/summarize/stream",
|
| 202 |
json={
|
| 203 |
"text": "Your long article or text here...",
|
| 204 |
"max_tokens": 128 # V2 uses max_new_tokens
|
|
|
|
| 219 |
// Android SSE client example
|
| 220 |
val client = OkHttpClient()
|
| 221 |
val request = Request.Builder()
|
| 222 |
+
.url("https://colin730-SummarizerApp.hf.space/api/v2/summarize/stream")
|
| 223 |
.post(RequestBody.create(
|
| 224 |
MediaType.parse("application/json"),
|
| 225 |
"""{"text": "Your text...", "max_tokens": 128}"""
|
|
|
|
| 246 |
|
| 247 |
### cURL Examples
|
| 248 |
```bash
|
| 249 |
+
# Test live deployment
|
| 250 |
+
curl https://colin730-SummarizerApp.hf.space/health
|
| 251 |
+
|
| 252 |
+
# V1 API (if Ollama is available)
|
| 253 |
+
curl -X POST "https://colin730-SummarizerApp.hf.space/api/v1/summarize/stream" \
|
| 254 |
-H "Content-Type: application/json" \
|
| 255 |
-d '{"text": "Your text...", "max_tokens": 256}'
|
| 256 |
|
| 257 |
+
# V2 API (HuggingFace streaming - recommended)
|
| 258 |
+
curl -X POST "https://colin730-SummarizerApp.hf.space/api/v2/summarize/stream" \
|
| 259 |
-H "Content-Type: application/json" \
|
| 260 |
-d '{"text": "Your text...", "max_tokens": 128}'
|
| 261 |
```
|
| 262 |
|
| 263 |
+
### Test Script
|
| 264 |
+
```bash
|
| 265 |
+
# Use the included test script
|
| 266 |
+
./scripts/test_endpoints.sh https://colin730-SummarizerApp.hf.space
|
| 267 |
+
```
|
| 268 |
+
|
| 269 |
## π Security
|
| 270 |
|
| 271 |
- Non-root user execution
|
|
|
|
| 307 |
|
| 308 |
---
|
| 309 |
|
| 310 |
+
## β
Deployment Status
|
| 311 |
+
|
| 312 |
+
**Successfully deployed and tested on Hugging Face Spaces!** π
|
| 313 |
+
|
| 314 |
+
- β
**Proxy-aware FastAPI** with `root_path` support
|
| 315 |
+
- β
**All endpoints working** (health, docs, V2 API)
|
| 316 |
+
- β
**Real-time streaming** summarization
|
| 317 |
+
- β
**No 404 errors** - all paths correctly configured
|
| 318 |
+
- β
**Test script included** for easy verification
|
| 319 |
+
|
| 320 |
+
### Recent Fixes Applied
|
| 321 |
+
- Added `root_path=os.getenv("HF_SPACE_ROOT_PATH", "")` for HF Spaces proxy awareness
|
| 322 |
+
- Ensured binding to `0.0.0.0:7860` as required by HF Spaces
|
| 323 |
+
- Verified V2 router paths (`/api/v2/summarize/stream`) with no double prefixes
|
| 324 |
+
- Created test script for external endpoint verification
|
| 325 |
+
|
| 326 |
+
**Live Space:** https://colin730-SummarizerApp.hf.space π―
|