Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
def query(payload, model_id, api_token):
|
4 |
+
headers = {"Authorization": f"Bearer {api_token}"}
|
5 |
+
API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
|
6 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
7 |
+
return response.json()
|
8 |
+
|
9 |
+
model_id = "distilbert-base-uncased"
|
10 |
+
api_token = "hf_XXXXXXXX" # get yours at hf.co/settings/tokens
|
11 |
+
data = query("The goal of life is [MASK].", model_id, api_token)
|