Create InferenceAPI
Browse files- InferenceAPI +16 -0
InferenceAPI
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
API_URL = "https://api-inference.huggingface.co/models/microsoft/DialoGPT-medium"
|
4 |
+
headers = {"Authorization": "Bearer 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"}
|
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 |
+
})
|