File size: 988 Bytes
d5d398f
63d0c61
9063441
 
 
 
d5d398f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9063441
 
ac0ce33
9063441
ac0ce33
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

import gradio as gr
import requests

url = "https://api.edenai.run/v2/text/sentiment_analysis"

def sentiment_analysis(inp_text):
    payload = {
        "response_as_dict": True,
        "attributes_as_list": False,
        "show_original_response": False,
        "providers": "google",
        "text": inp_text,
        "language": "ko"
    }
    headers = {
        "accept": "application/json",
        "content-type": "application/json",
        "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMWI0NzY4YzMtNmM0NC00NThiLTkyMjctNDFhMDVjZDlkZTMxIiwidHlwZSI6ImFwaV90b2tlbiJ9.6nsuq67zZlBXqpH0VUNud64Ii54ETQay0Antfslpsqg"
    }

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

    return response.text

inp_text = gr.inputs.Textbox(label='Input')
response = gr.outputs.Textbox(label='Output')

gr.Interface(function=sentiment_analysis, inputs=inp_text, outputs=response, title='Sentiment Analysis', theme='peach').launch(enable_queue=True)