yashxx07 commited on
Commit
3e409f4
·
verified ·
1 Parent(s): 716ee27

Update app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +4 -9
app/main.py CHANGED
@@ -6,7 +6,6 @@ import re
6
  import os
7
 
8
  token = os.environ.get("huggingface_token")
9
- key = os.environ.get("rapid_key")
10
 
11
  app = FastAPI()
12
 
@@ -54,7 +53,7 @@ async def root(item: Item):
54
  }
55
  headers = {
56
  "content-type": "application/json",
57
- "X-RapidAPI-Key": key,
58
  "X-RapidAPI-Host": "text-analysis12.p.rapidapi.com"
59
  }
60
 
@@ -106,23 +105,19 @@ async def root(item: Item):
106
 
107
  article = extract_article_content(item.url)
108
 
109
-
110
 
111
  API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
112
  headers = {'Authorization': token}
113
 
114
-
115
- def query(payload):
116
- response = requests.post(API_URL, headers=headers, json=payload)
117
- return response.json()
118
 
119
  params = {'do_sample': False}
120
 
121
-
122
- output = query({
123
  'inputs': article,
124
  'parameters': params
125
  })
 
 
126
 
127
  return {"summary": output}
128
 
 
6
  import os
7
 
8
  token = os.environ.get("huggingface_token")
 
9
 
10
  app = FastAPI()
11
 
 
53
  }
54
  headers = {
55
  "content-type": "application/json",
56
+ "X-RapidAPI-Key":"",
57
  "X-RapidAPI-Host": "text-analysis12.p.rapidapi.com"
58
  }
59
 
 
105
 
106
  article = extract_article_content(item.url)
107
 
 
108
 
109
  API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
110
  headers = {'Authorization': token}
111
 
 
 
 
 
112
 
113
  params = {'do_sample': False}
114
 
115
+ response = requests.post(API_URL, headers=headers, json={
 
116
  'inputs': article,
117
  'parameters': params
118
  })
119
+
120
+ output = response.json()
121
 
122
  return {"summary": output}
123