Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -33,7 +33,7 @@ def extract_article_content(url):
|
|
| 33 |
|
| 34 |
return ARTICLE
|
| 35 |
except Exception as e:
|
| 36 |
-
return
|
| 37 |
|
| 38 |
|
| 39 |
@app.post("/summarize-v1")
|
|
@@ -52,7 +52,7 @@ async def root(item: Item):
|
|
| 52 |
}
|
| 53 |
headers = {
|
| 54 |
"content-type": "application/json",
|
| 55 |
-
"X-RapidAPI-Key":"",
|
| 56 |
"X-RapidAPI-Host": "text-analysis12.p.rapidapi.com"
|
| 57 |
}
|
| 58 |
|
|
@@ -78,8 +78,10 @@ async def root(item: Item):
|
|
| 78 |
|
| 79 |
article = extract_article_content(item.url)
|
| 80 |
|
|
|
|
|
|
|
| 81 |
response = requests.post('https://fumes-api.onrender.com/llama3',
|
| 82 |
-
json={'prompt': "{ 'User': 'Summarize the following news article: '" + article + "}",
|
| 83 |
"temperature":0.6,
|
| 84 |
"topP":0.9,
|
| 85 |
"maxTokens": 200}, stream=True)
|
|
|
|
| 33 |
|
| 34 |
return ARTICLE
|
| 35 |
except Exception as e:
|
| 36 |
+
return ""
|
| 37 |
|
| 38 |
|
| 39 |
@app.post("/summarize-v1")
|
|
|
|
| 52 |
}
|
| 53 |
headers = {
|
| 54 |
"content-type": "application/json",
|
| 55 |
+
"X-RapidAPI-Key":"836bb8ca1fmsh79ad9dd5bf8734fp1460bejsn5eac87118b33",
|
| 56 |
"X-RapidAPI-Host": "text-analysis12.p.rapidapi.com"
|
| 57 |
}
|
| 58 |
|
|
|
|
| 78 |
|
| 79 |
article = extract_article_content(item.url)
|
| 80 |
|
| 81 |
+
if len(article) == 0:
|
| 82 |
+
return {'summary': ""}
|
| 83 |
response = requests.post('https://fumes-api.onrender.com/llama3',
|
| 84 |
+
json={'prompt': "{ 'User': 'Summarize the following news article in english: '" + article + "}",
|
| 85 |
"temperature":0.6,
|
| 86 |
"topP":0.9,
|
| 87 |
"maxTokens": 200}, stream=True)
|