Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def get_sentiment(input_text):
|
4 |
+
return sentiment(input_text)
|
5 |
+
|
6 |
+
import requests
|
7 |
+
|
8 |
+
app = FastAPI()
|
9 |
+
|
10 |
+
url = "https://sentiment-analysis9.p.rapidapi.com/sentiment"
|
11 |
+
|
12 |
+
def call_sentiment_api(user_input):
|
13 |
+
payload = [{
|
14 |
+
"id": "1",
|
15 |
+
"language": "en",
|
16 |
+
"text": user_input
|
17 |
+
}]
|
18 |
+
headers = {
|
19 |
+
"content-type": "application/json",
|
20 |
+
"Accept": "application/json",
|
21 |
+
"X-RapidAPI-Key": "5cf8fcaf61msh613f010a34f3576p1953e5jsn110a1e6c667d",
|
22 |
+
"X-RapidAPI-Host": "sentiment-analysis9.p.rapidapi.com"
|
23 |
+
}
|
24 |
+
|
25 |
+
response = requests.post(url, json=payload, headers=headers)
|
26 |
+
|
27 |
+
return response.json()
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
iface7 = gr.Interface(get_sentiment, inputs= "text", outputs= "text", title="Sentiment Analysis")
|
38 |
+
|
39 |
+
iface7.launch(inline=False)
|