Spaces:
Running
Running
Commit
·
b0c97d8
1
Parent(s):
8567648
feat: made mina nd max length dynamic
Browse files
app.py
CHANGED
@@ -10,8 +10,10 @@ class SummarizationRequest(BaseModel):
|
|
10 |
|
11 |
@app.post("/summarize")
|
12 |
async def summarize_text(request: SummarizationRequest):
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
return {"summary": summary[0]["summary_text"]}
|
16 |
|
17 |
@app.get("/")
|
|
|
10 |
|
11 |
@app.post("/summarize")
|
12 |
async def summarize_text(request: SummarizationRequest):
|
13 |
+
input_length = len(request.inputs.split())
|
14 |
+
max_length = max(50, int(input_length * 0.5))
|
15 |
+
min_length = max(20, int(input_length * 0.2))
|
16 |
+
summary = summarizer(request.inputs, max_length=max_length, min_length=min_length, do_sample=False)
|
17 |
return {"summary": summary[0]["summary_text"]}
|
18 |
|
19 |
@app.get("/")
|