thorunn's picture
various-fixes (#4)
e253ff6 verified
raw history blame
No virus
919 Bytes
"""
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"
# Set your Hugging Face API key as an environment variable
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": "", # Can be left empty.
"input_a": "<text A>", # Required for all tasks.
"input_b": "<text B>", # Required for task 2 but not for task 1 or 3.
"task": 1 | 2 | 3, # Choose the task number.
"parameters": {
# Can be left empty
},
}
)
print(output)