Spaces:
Running
Running
Commit
·
cb31a46
1
Parent(s):
dabf7d3
feat: adding sensible range for summarized posts
Browse files
app.py
CHANGED
@@ -14,8 +14,9 @@ class SummarizationResponse(BaseModel):
|
|
14 |
@app.post("/summarize", response_model=SummarizationResponse)
|
15 |
async def summarize_text(request: SummarizationRequest):
|
16 |
input_length = len(request.inputs.split())
|
17 |
-
|
18 |
-
|
|
|
19 |
|
20 |
summary = summarizer(request.inputs, max_length=max_length, min_length=min_length, do_sample=False)
|
21 |
return {"summary": summary[0]["summary_text"]}
|
|
|
14 |
@app.post("/summarize", response_model=SummarizationResponse)
|
15 |
async def summarize_text(request: SummarizationRequest):
|
16 |
input_length = len(request.inputs.split())
|
17 |
+
|
18 |
+
max_length = min(250, max(100, int(input_length * 0.4)))
|
19 |
+
min_length = min(100, max(50, int(input_length * 0.2)))
|
20 |
|
21 |
summary = summarizer(request.inputs, max_length=max_length, min_length=min_length, do_sample=False)
|
22 |
return {"summary": summary[0]["summary_text"]}
|