nhathuy07 commited on
Commit
380b164
·
verified ·
1 Parent(s): 425e817

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -4
main.py CHANGED
@@ -159,7 +159,7 @@ async def __parse_paragraphs (content: str, batching: bool = False):
159
  header=_n
160
  h_cnt = __h_cnt
161
  # print(_n, len(_n))
162
- elif (len(_n.replace('#',''))):
163
  # remove accidental /n's in converted HTML content
164
 
165
  if (batching and len(_p_json) >= 1):
@@ -171,7 +171,8 @@ async def __parse_paragraphs (content: str, batching: bool = False):
171
  continue
172
 
173
  _p_json.append({'header': header, 'h_cnt': h_cnt, 'content': _n.replace('\n',' '), 'count': 1})
174
-
 
175
 
176
  except:
177
  continue
@@ -203,7 +204,10 @@ async def __query_ml_predict(qtype: QType, content: str, header: str, token_limi
203
  )
204
 
205
  print(time() - stopwatch)
206
- if _r.status_code != 200: app_logger.info(_r.json())
 
 
 
207
  return {"content": _r.json()['choices'][0]['message']['content'], "style": QType.WH}
208
 
209
  case QType.STMT:
@@ -223,7 +227,10 @@ async def __query_ml_predict(qtype: QType, content: str, header: str, token_limi
223
  }),
224
  timeout=None
225
  )
226
- if _r.status_code != 200: app_logger.info(_r.json())
 
 
 
227
  _r_content = _r.json()['choices'][0]['message']['content'].split('\n\n',1)[1]
228
  async with httpx.AsyncClient() as client:
229
  _w = await client.post(
 
159
  header=_n
160
  h_cnt = __h_cnt
161
  # print(_n, len(_n))
162
+ elif (len(_n.replace('#','').strip())):
163
  # remove accidental /n's in converted HTML content
164
 
165
  if (batching and len(_p_json) >= 1):
 
171
  continue
172
 
173
  _p_json.append({'header': header, 'h_cnt': h_cnt, 'content': _n.replace('\n',' '), 'count': 1})
174
+
175
+
176
 
177
  except:
178
  continue
 
204
  )
205
 
206
  print(time() - stopwatch)
207
+ if _r.status_code != 200:
208
+ app_logger.info(_r.json())
209
+ return {"content": "", "style": QType.WH}
210
+
211
  return {"content": _r.json()['choices'][0]['message']['content'], "style": QType.WH}
212
 
213
  case QType.STMT:
 
227
  }),
228
  timeout=None
229
  )
230
+ if _r.status_code != 200:
231
+ app_logger.info(_r.json())
232
+ return {"content": "", "style": QType.STMT}
233
+
234
  _r_content = _r.json()['choices'][0]['message']['content'].split('\n\n',1)[1]
235
  async with httpx.AsyncClient() as client:
236
  _w = await client.post(