Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,26 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Load
|
| 5 |
generator = pipeline(
|
| 6 |
-
"summarization", #
|
| 7 |
model="andersondequan5/checkin-bart-model",
|
| 8 |
tokenizer="andersondequan5/checkin-bart-model"
|
| 9 |
)
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
result = generator(task, max_length=200, num_beams=4, do_sample=False)
|
| 14 |
-
return result[0]["summary_text"]
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
description="Submit a short input task and get a polished daily check-in expansion."
|
| 23 |
-
)
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Load model
|
| 6 |
generator = pipeline(
|
| 7 |
+
"summarization", # use summarization since text2text-generation is deprecated in HF metadata
|
| 8 |
model="andersondequan5/checkin-bart-model",
|
| 9 |
tokenizer="andersondequan5/checkin-bart-model"
|
| 10 |
)
|
| 11 |
|
| 12 |
+
# FastAPI app
|
| 13 |
+
app = FastAPI(title="Check-In Expansion API")
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
# Request/Response schema
|
| 16 |
+
class CheckInRequest(BaseModel):
|
| 17 |
+
task: str
|
| 18 |
+
|
| 19 |
+
class CheckInResponse(BaseModel):
|
| 20 |
+
checkin: str
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
@app.post("/predict", response_model=CheckInResponse)
|
| 23 |
+
def predict(request: CheckInRequest):
|
| 24 |
+
"""Expand a short input into a detailed check-in."""
|
| 25 |
+
result = generator(request.task, max_length=200, num_beams=4, do_sample=False)
|
| 26 |
+
return {"checkin": result[0]["summary_text"]}
|