Pentameric commited on
Commit
eb63c73
·
1 Parent(s): 4b8569a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -8
app.py CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  import requests
2
 
3
  API_URL = "https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill"
@@ -5,12 +9,24 @@ headers = {"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
5
 
6
  def query(payload):
7
  response = requests.post(API_URL, headers=headers, json=payload)
8
- return response.json()
 
 
 
 
 
9
 
10
- output = query({
11
- "inputs": {
12
- "past_user_inputs": ["Which movie is the best ?"],
13
- "generated_responses": ["It's Die Hard for sure."],
14
- "text": "Can you explain why ?"
15
- },
16
- })
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+
5
  import requests
6
 
7
  API_URL = "https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill"
 
9
 
10
  def query(payload):
11
  response = requests.post(API_URL, headers=headers, json=payload)
12
+ return response.json()
13
+
14
+ inputs=[]
15
+ outputs=[]
16
+
17
+ def greet(name):
18
 
19
+ output = query({
20
+ "inputs": {
21
+ "past_user_inputs": inputs,
22
+ "generated_responses": outputs,
23
+ "text": name
24
+ },
25
+ })
26
+ inputs.append(name)
27
+ outputs.append(output)
28
+
29
+ return output
30
+
31
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
32
+ iface.launch()