File size: 1,116 Bytes
bfbbbf7 |
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 35 36 37 38 |
```
Copied
import json
import requests
headers = {"Authorization": f"Bearer {API_TOKEN}"}
API_URL = "https://api-inference.huggingface.co/models/sillon/DialoGPT-small-HospitalBot"
def query(payload):
data = json.dumps(payload)
response = requests.request("POST", API_URL, headers=headers, data=data)
return json.loads(response.content.decode("utf-8"))
data = query(
{
"inputs": {
"past_user_inputs": ["Which movie is the best ?"],
"generated_responses": ["It's Die Hard for sure."],
"text": "Can you explain why ?",
},
}
)
# Response
self.assertEqual(
data,
{
"generated_text": "It's the best movie ever.",
"conversation": {
"past_user_inputs": [
"Which movie is the best ?",
"Can you explain why ?",
],
"generated_responses": [
"It's Die Hard for sure.",
"It's the best movie ever.",
],
},
"warnings": ["Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation."],
},
)
``` |