Spaces:
Runtime error
Runtime error
File size: 838 Bytes
894acf1 661dbc7 bd20ae5 913861e bd20ae5 894acf1 661dbc7 894acf1 5bc117d 661dbc7 894acf1 661dbc7 894acf1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
from fastapi import FastAPI
from pydantic import BaseModel
from transformers import pipeline
# FastAPI app
app = FastAPI(title="Check-In Expansion API")
@app.get("/")
def read_root():
return {"status": "ok"}
# Load model
generator = pipeline(
"summarization", # use summarization since text2text-generation is deprecated in HF metadata
model="Dc-4nderson/checkin-model",
tokenizer="Dc-4nderson/checkin-model"
)
# Request/Response schema
class CheckInRequest(BaseModel):
task: str
class CheckInResponse(BaseModel):
checkin: str
@app.post("/predict", response_model=CheckInResponse)
def predict(request: CheckInRequest):
"""Expand a short input into a detailed check-in."""
result = generator(request.task, max_length=200, num_beams=4, do_sample=False)
return {"checkin": result[0]["summary_text"]}
|