Spaces:
Sleeping
Sleeping
Add application fil2e
Browse files
app.py
CHANGED
@@ -1,7 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|