File size: 919 Bytes
e253ff6
 
 
 
 
 
 
 
 
 
 
 
 
 
eb7040d
 
 
e253ff6
 
 
eb7040d
 
e253ff6
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
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)