File size: 798 Bytes
c0eef7a
 
 
 
3dafbca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from fastapi import FastAPI
import nest_asyncio
from pyngrok import ngrok
import uvicorn
import gradio as gr

app = FastAPI()

url = "https://sentiment-analysis9.p.rapidapi.com/sentiment"

def call_sentiment_api(user_input):
    payload = [{
        "id": "1",
        "language": "en",
        "text": user_input
    }]
    headers = {
        "content-type": "application/json",
        "Accept": "application/json",
        "X-RapidAPI-Key": "5cf8fcaf61msh613f010a34f3576p1953e5jsn110a1e6c667d",
        "X-RapidAPI-Host": "sentiment-analysis9.p.rapidapi.com"
    }

    response = requests.post(url, json=payload, headers=headers)

    return response.json()









iface7 = gr.Interface(get_sentiment, inputs= "text", outputs= "text", title="Sentiment Analysis")

iface7.launch(inline=False)