saljoofri commited on
Commit
ba5c8ab
1 Parent(s): f5046f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -1,23 +1,30 @@
1
- # Helper function
2
  import os, requests, json
3
 
4
  hf_api_key = os.environ['HF_API_KEY']
 
5
 
6
  #Summarization endpoint
7
- def get_completion(inputs, parameters=None, ENDPOINT_URL="shleifer/distilbart-cnn-12-6"):
 
8
  headers = {
9
  "Authorization": f"Bearer {hf_api_key}",
10
  "Content-Type": "application/json"
11
  }
12
- data = { "inputs": inputs }
 
 
13
  if parameters is not None:
14
- data.update({"parameters": parameters})
15
- response = requests.request("POST",
16
- ENDPOINT_URL, headers=headers,
17
- data=json.dumps(data)
18
- )
 
19
  return json.loads(response.content.decode("utf-8"))
20
 
 
 
21
  import gradio as gr
22
 
23
  def summarize(input):
 
1
+ ### Helper function
2
  import os, requests, json
3
 
4
  hf_api_key = os.environ['HF_API_KEY']
5
+ ENDPOINT_URL=os.environ['HF_API_SUMMARY_BASE']
6
 
7
  #Summarization endpoint
8
+ def get_completion(inputs, parameters=None):
9
+
10
  headers = {
11
  "Authorization": f"Bearer {hf_api_key}",
12
  "Content-Type": "application/json"
13
  }
14
+
15
+ payload = { "inputs": inputs }
16
+
17
  if parameters is not None:
18
+ payload.update({"parameters": parameters})
19
+
20
+ response = requests.post(ENDPOINT_URL,
21
+ headers=headers,
22
+ data=json.dumps(payload))
23
+
24
  return json.loads(response.content.decode("utf-8"))
25
 
26
+ ### Gradio App
27
+
28
  import gradio as gr
29
 
30
  def summarize(input):