Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
def yes_man(message, history):
|
5 |
# if message.endswith("?"):
|
6 |
# return "Yes"
|
7 |
#else:
|
8 |
# return "Ask me anything!"
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
API_URL = "https://api-inference.huggingface.co/models/gpt2"
|
13 |
-
def query(payload):
|
14 |
-
response = requests.post(API_URL, headers=headers, json=payload)
|
15 |
-
return response.json()
|
16 |
-
data = query({"inputs": message})
|
17 |
return data
|
18 |
gr.ChatInterface(
|
19 |
yes_man,
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import os
|
4 |
+
|
5 |
+
import requests
|
6 |
+
headers = {"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"}
|
7 |
+
API_URL = "https://api-inference.huggingface.co/models/gpt2"
|
8 |
+
def query(payload):
|
9 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
10 |
+
return response.json()
|
11 |
+
|
12 |
def yes_man(message, history):
|
13 |
# if message.endswith("?"):
|
14 |
# return "Yes"
|
15 |
#else:
|
16 |
# return "Ask me anything!"
|
17 |
|
18 |
+
while not 'generated_text' not in list(data[0].keys()):
|
19 |
+
data = query({"inputs": message})
|
|
|
|
|
|
|
|
|
|
|
20 |
return data
|
21 |
gr.ChatInterface(
|
22 |
yes_man,
|