|
""" |
|
Script for running the model using the Hugging Face endpoint. An authorized Hugging Face API key is required. |
|
""" |
|
|
|
import requests |
|
import os |
|
|
|
API_URL = "https://otaf5w2ge8huxngl.eu-west-1.aws.endpoints.huggingface.cloud" |
|
|
|
api_key = os.environ.get("HF_API_KEY") |
|
headers = { |
|
"Accept": "application/json", |
|
"Authorization": f"Bearer {api_key}", |
|
"Content-Type": "application/json", |
|
} |
|
|
|
|
|
def query(payload): |
|
response = requests.post(API_URL, headers=headers, json=payload) |
|
return response.json() |
|
|
|
|
|
output = query( |
|
{ |
|
"inputs": "", |
|
"input_a": "<text A>", |
|
"input_b": "<text B>", |
|
"task": 1 | 2 | 3, |
|
"parameters": { |
|
|
|
}, |
|
} |
|
) |
|
print(output) |
|
|