Spaces:
Sleeping
Sleeping
File size: 652 Bytes
77fb0a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import os
import requests, json
from dotenv import load_dotenv, find_dotenv
from ..constants.constants import CNN_API_URL
load_dotenv(find_dotenv())
huggingFaceAPIToken = os.environ['HF_API_KEY']
def completion_message(inputs, parameters=None,ENDPOINT_URL=CNN_API_URL):
headers = {
"Authorization": f"Bearer {huggingFaceAPIToken}",
"Content-Type": "application/json"
}
data = { "inputs": inputs }
if parameters is not None:
data.update({"parameters": parameters})
response = requests.request("POST",ENDPOINT_URL, headers=headers,data=json.dumps(data))
return json.loads(response.content.decode("utf-8")) |