Text_Summarization / Text_Summarization.py
Logeswaransr's picture
Add Application File
6d67247
raw
history blame contribute delete
738 Bytes
import requests
import json
import os
def get_completion(inputs, parameters=None):
headers = {
"Authorization":f"Bearer {api_key}",
"Content-Type":"application/json"
}
data = {"inputs": inputs}
if parameters is not None:
data['parameters'] = parameters
response = requests.request("POST",
endpoint_url,
headers=headers,
data=json.dumps(data)
)
return json.loads(response.content.decode("utf-8"))
def summarize(input):
output = get_completion(input)
return output[0]['summary_text']
api_key = os.environ['HF_TOKEN']
endpoint_url = os.environ['API_URL']