Spaces:
Sleeping
Sleeping
Commit ·
dabf7d3
1
Parent(s): 20dbd9d
feat: post_id is not needed to be returned since we are summarizing one at a time
Browse files
app.py
CHANGED
|
@@ -7,10 +7,8 @@ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
|
| 7 |
|
| 8 |
class SummarizationRequest(BaseModel):
|
| 9 |
inputs: str
|
| 10 |
-
post_id: str
|
| 11 |
|
| 12 |
class SummarizationResponse(BaseModel):
|
| 13 |
-
post_id: str
|
| 14 |
summary: str
|
| 15 |
|
| 16 |
@app.post("/summarize", response_model=SummarizationResponse)
|
|
@@ -20,7 +18,7 @@ async def summarize_text(request: SummarizationRequest):
|
|
| 20 |
min_length = max(20, int(input_length * 0.2))
|
| 21 |
|
| 22 |
summary = summarizer(request.inputs, max_length=max_length, min_length=min_length, do_sample=False)
|
| 23 |
-
return {"
|
| 24 |
|
| 25 |
@app.get("/")
|
| 26 |
def greet_json():
|
|
|
|
| 7 |
|
| 8 |
class SummarizationRequest(BaseModel):
|
| 9 |
inputs: str
|
|
|
|
| 10 |
|
| 11 |
class SummarizationResponse(BaseModel):
|
|
|
|
| 12 |
summary: str
|
| 13 |
|
| 14 |
@app.post("/summarize", response_model=SummarizationResponse)
|
|
|
|
| 18 |
min_length = max(20, int(input_length * 0.2))
|
| 19 |
|
| 20 |
summary = summarizer(request.inputs, max_length=max_length, min_length=min_length, do_sample=False)
|
| 21 |
+
return {"summary": summary[0]["summary_text"]}
|
| 22 |
|
| 23 |
@app.get("/")
|
| 24 |
def greet_json():
|