ByteMan commited on
Commit
77cdebd
·
1 Parent(s): 8637618

Add application fil2e

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -1,7 +1,21 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import requests
3
+ import os
4
 
5
+ API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment"
 
6
 
7
+ bt = os.environ['HACKAITHONBEARERTOKEN']
8
+ headers = {"Authorization": bt }
9
+
10
+ def query(data):
11
+ response = requests.post(API_URL, headers=headers, json=data)
12
+ return "V2"+str(response.json())
13
+
14
+ def greet(howareyoufeeling):
15
+ output = query({"inputs":howareyoufeeling})
16
+ print (str(output))
17
+ return str(output)
18
+
19
+ iface = gr.Interface(
20
+ fn=greet, inputs=["text"], outputs="text", allow_flagging="never")
21
+ iface.launch()