Spaces:
Sleeping
Sleeping
aakarsh-yadav-tcgls
commited on
Commit
•
089621c
1
Parent(s):
1ef224d
setting up api calling
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
import requests
|
4 |
+
|
5 |
+
API_URL = "https://api-inference.huggingface.co/models/yiyanghkust/finbert-tone"
|
6 |
+
headers = {"Authorization": "Bearer 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"}
|
7 |
+
|
8 |
+
|
9 |
+
url = "YOUR_API_ENDPOINT"
|
10 |
+
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
|
11 |
+
|
12 |
+
# Replace "your_input_data" with the actual data you want to send to your model
|
13 |
+
input_data = {"inputs": "your_input_data"}
|
14 |
+
def query(payload):
|
15 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
16 |
+
return response.json()
|
17 |
+
|
18 |
+
output = query(input_data)
|
19 |
+
|
20 |
+
print(output)
|
21 |
+
# Check the response
|
22 |
+
if response.status_code == 200:
|
23 |
+
result = response.json()
|
24 |
+
print("API Response:", result)
|
25 |
+
else:
|
26 |
+
print("Error:", response.status_code, response.text)
|