Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -90,6 +90,26 @@ async def root(item: Item):
|
|
| 90 |
return {"error": str(e), "status_code": 500}
|
| 91 |
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
|
| 95 |
|
|
|
|
| 90 |
return {"error": str(e), "status_code": 500}
|
| 91 |
|
| 92 |
|
| 93 |
+
@app.post("/summarize-v2")
|
| 94 |
+
async def root(item: Item):
|
| 95 |
+
|
| 96 |
+
try:
|
| 97 |
+
|
| 98 |
+
article = extract_article_content(item.url)
|
| 99 |
+
|
| 100 |
+
if len(article) == 0:
|
| 101 |
+
return {'summary': ""}
|
| 102 |
+
|
| 103 |
+
summ = summarizer(article, max_length=1000, min_length=30, do_sample=False)
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
#return {clean_response}
|
| 107 |
+
return {
|
| 108 |
+
"summary":summ}
|
| 109 |
+
|
| 110 |
+
except requests.RequestException as e:
|
| 111 |
+
return {"error": str(e), "status_code": 500}
|
| 112 |
+
|
| 113 |
|
| 114 |
|
| 115 |
|