File size: 592 Bytes
77b3501
b8f917c
 
 
 
77b3501
b8f917c
21cdd54
77b3501
 
b8f917c
21cdd54
b8f917c
 
77b3501
b8f917c
 
 
77b3501
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import io 
from dotenv import load_dotenv, find_dotenv
import requests, json
from transformers import pipeline
import gradio as gr
from transformers import pipeline

# Access the Hugging Face API key and endpoint URL
hf_api_key = os.getenv('HF_API_KEY')
ENDPOINT_URL = os.getenv('HF_API_SUMMARY_BASE')

#Summarization endpoint
get_completion = pipeline("summarization", model="shleifer/distilbart-cnn-12-6")

def summarize(input):
    output = get_completion(input)
    return output[0]['summary_text']

demo = gr.Interface(fn=summarize, inputs="text", outputs="text")
demo.launch()