Create new file
Browse files
index.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
API_URL = "https://api-inference.huggingface.co/models/google/tapas-base-finetuned-wtq"
|
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 |
+
"query": "How many stars does the transformers repository have?",
|
13 |
+
"table": {
|
14 |
+
"Repository": ["Transformers", "Datasets", "Tokenizers"],
|
15 |
+
"Stars": ["36542", "4512", "3934"],
|
16 |
+
"Contributors": ["651", "77", "34"],
|
17 |
+
"Programming language": [
|
18 |
+
"Python",
|
19 |
+
"Python",
|
20 |
+
"Rust, Python and NodeJS"
|
21 |
+
]
|
22 |
+
}
|
23 |
+
},
|
24 |
+
})
|