Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,20 +11,19 @@ headers = {"Authorization": f"Bearer {api_token}"}
|
|
11 |
@spaces.GPU
|
12 |
|
13 |
# Texte à analyser
|
14 |
-
input_text = "Can you please let us know more details about your "
|
15 |
-
|
16 |
# Envoi de la requête
|
17 |
-
output = query({
|
18 |
-
"inputs": input_text,
|
19 |
-
})
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
interface = gr.Interface(
|
29 |
fn=analyze_sentiment,
|
30 |
inputs="text",
|
|
|
11 |
@spaces.GPU
|
12 |
|
13 |
# Texte à analyser
|
|
|
|
|
14 |
# Envoi de la requête
|
|
|
|
|
|
|
15 |
|
16 |
+
def query(payload):
|
17 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
18 |
+
return response.json()
|
19 |
+
def analyze_sentiment(input_text):
|
20 |
+
output = query({"inputs": input_text})
|
21 |
+
label = output[0]['label']
|
22 |
+
if label == 'POSITIVE':
|
23 |
+
return 'Positif'
|
24 |
+
else:
|
25 |
+
return 'Négatif'
|
26 |
+
|
27 |
interface = gr.Interface(
|
28 |
fn=analyze_sentiment,
|
29 |
inputs="text",
|