guayn commited on
Commit
359af7e
1 Parent(s): cb22179
Files changed (2) hide show
  1. app.py +24 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import requests
4
+ import os
5
+
6
+ API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment-latest"
7
+
8
+ bt = os.environ['HACKAITHONBEARERTOKEN']
9
+ headers = {"Authorization": bt }
10
+
11
+ def query(data):
12
+ response = requests.post(API_URL, headers=headers, json=data)
13
+ return "V2"+str(response.json())
14
+
15
+ def greet(howareyoufeeling):
16
+ output = query({"inputs":howareyoufeeling})
17
+ print (str(output))
18
+ return str(output)
19
+
20
+ sentiDemo = gr.Interface(
21
+ fn=greet, inputs=["text"], outputs=["text"],
22
+ )
23
+
24
+ sentiDemo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ gradio==3.50.2
3
+ requests
4
+ fastai