Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,30 @@
|
|
1 |
-
|
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
|
|
|
8 |
headers = {
|
9 |
"Authorization": f"Bearer {hf_api_key}",
|
10 |
"Content-Type": "application/json"
|
11 |
}
|
12 |
-
|
|
|
|
|
13 |
if parameters is not None:
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
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):
|