Spaces:
Runtime error
Runtime error
File size: 714 Bytes
eb63c73 4b8569a 982b009 8ea1aa3 4b8569a eb63c73 e27bec7 eb63c73 d2f944c eb63c73 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
import requests
API_URL = "https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill"
headers = {"Authorization": "Bearer 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"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
inputs=[]
outputs=[]
def greet(name):
output = query({
"inputs": {
"past_user_inputs": inputs,
"generated_responses": outputs,
"text": name
},
"parameters": {
"min_length":20,
"max_length":50
}
})
inputs.append(name)
outputs.append(output['generated_text'])
return output['generated_text']
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch() |