AyushDey commited on
Commit
91ea7b8
1 Parent(s): 94429bd

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +22 -0
  2. config.json +8 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import requests
4
+ import gradio as gr
5
+ hf_key = os.environ.get('HF_API_KEY')
6
+ headers = headers = {
7
+ "Authorization": f"Bearer {hf_key}",
8
+ "Content-Type": "application/json"
9
+ }
10
+ API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
11
+ def query(payload):
12
+ data = {'inputs': payload}
13
+ response = requests.request("POST", API_URL, headers=headers, data=json.dumps(data))
14
+ return json.loads(response.content.decode("utf-8"))
15
+ def summarization(input):
16
+ output = query(input)
17
+ return output[0]['summary_text']
18
+
19
+ gr.close_all()
20
+
21
+ demo = gr.Interface(fn=summarization, inputs='text', outputs='text')
22
+ demo.launch(share=True)
config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "environment": "python",
3
+ "entrypoint": "app.py",
4
+ "command": "python3 app.py",
5
+ "env": {
6
+ "HF_API_KEY": "${{ secrets.api_key }}"
7
+ }
8
+ }