cjell
commited on
Commit
·
207903e
1
Parent(s):
ea92f6d
fixing
Browse files- app.py +1 -1
- test_sentiment.py +13 -0
app.py
CHANGED
|
@@ -35,5 +35,5 @@ def predict_toxic(query: Query):
|
|
| 35 |
|
| 36 |
@app.post("/sentiment")
|
| 37 |
def predict_sentiment(query: Query):
|
| 38 |
-
result =
|
| 39 |
return {"label": result["label"], "score": result["score"]}
|
|
|
|
| 35 |
|
| 36 |
@app.post("/sentiment")
|
| 37 |
def predict_sentiment(query: Query):
|
| 38 |
+
result = sentiment(query.text)[0]
|
| 39 |
return {"label": result["label"], "score": result["score"]}
|
test_sentiment.py
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
url = "https://cjell-Demo.hf.space/sentiment"
|
| 4 |
+
|
| 5 |
+
payload = {"text": "I am not happy, I am very upset."}
|
| 6 |
+
|
| 7 |
+
response = requests.post(url, json=payload)
|
| 8 |
+
|
| 9 |
+
print("Status:", response.status_code)
|
| 10 |
+
try:
|
| 11 |
+
print("JSON:", response.json())
|
| 12 |
+
except Exception:
|
| 13 |
+
print("Raw text:", response.text)
|