Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -281,9 +281,12 @@ async def __query_ml_predict(qtype: QType, content: str, header: str, token_limi
|
|
281 |
print(time() - stopwatch)
|
282 |
if _r.status_code != 200:
|
283 |
app_logger.info(_r.json())
|
284 |
-
return {"content": "", "style":
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
287 |
|
288 |
case QType.STMT:
|
289 |
|
@@ -302,11 +305,20 @@ async def __query_ml_predict(qtype: QType, content: str, header: str, token_limi
|
|
302 |
}),
|
303 |
timeout=None
|
304 |
)
|
305 |
-
if _r.status_code !=
|
306 |
app_logger.info(_r.json())
|
307 |
-
return {"content": "", "style": QType.STMT}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
-
_r_content = _r.json()['choices'][0]['message']['content'].split('\n\n',1)[1]
|
310 |
async with httpx.AsyncClient() as client:
|
311 |
_w = await client.post(
|
312 |
url="https://api.awanllm.com/v1/chat/completions",
|
@@ -322,12 +334,19 @@ async def __query_ml_predict(qtype: QType, content: str, header: str, token_limi
|
|
322 |
timeout=None
|
323 |
)
|
324 |
|
|
|
|
|
|
|
|
|
|
|
325 |
try:
|
326 |
_w_content = _w.json()['choices'][0]['message']['content'].split('\n\n',1)[1]
|
327 |
#print(time() - stopwatch)
|
328 |
return {"content": f"{_r_content}\n{_w_content}", "style": QType.STMT, "success": True}
|
329 |
except:
|
330 |
-
|
|
|
|
|
331 |
|
332 |
|
333 |
async def parse_wh_question(raw_qa_list, pgph_i):
|
|
|
281 |
print(time() - stopwatch)
|
282 |
if _r.status_code != 200:
|
283 |
app_logger.info(_r.json())
|
284 |
+
return {"content": "", "style": None "success": False}
|
285 |
+
|
286 |
+
try:
|
287 |
+
return {"content": _r.json()['choices'][0]['message']['content'], "style": QType.WH, "success": True}
|
288 |
+
except:
|
289 |
+
return {"content": "", "style": None, "success": False}
|
290 |
|
291 |
case QType.STMT:
|
292 |
|
|
|
305 |
}),
|
306 |
timeout=None
|
307 |
)
|
308 |
+
if _r.status_code//100 != 2:
|
309 |
app_logger.info(_r.json())
|
310 |
+
return {"content": "", "style": QType.STMT, "success": False}
|
311 |
+
|
312 |
+
try:
|
313 |
+
_r_content = _r.json()['choices'][0]['message']['content']
|
314 |
+
except:
|
315 |
+
return {"content": "", "style":None, "success":False}
|
316 |
+
|
317 |
+
try:
|
318 |
+
_r_content = _r.json()['choices'][0]['message']['content'].split('\n\n',1)[1]
|
319 |
+
except:
|
320 |
+
_r_content = _r.json()['choices'][0]['message']['content'].split('\n',1)[1]
|
321 |
|
|
|
322 |
async with httpx.AsyncClient() as client:
|
323 |
_w = await client.post(
|
324 |
url="https://api.awanllm.com/v1/chat/completions",
|
|
|
334 |
timeout=None
|
335 |
)
|
336 |
|
337 |
+
try:
|
338 |
+
_ch = _w.json()['choices'][0]['message']['content']
|
339 |
+
except:
|
340 |
+
return {"content": "", "style": None, "success":False}
|
341 |
+
|
342 |
try:
|
343 |
_w_content = _w.json()['choices'][0]['message']['content'].split('\n\n',1)[1]
|
344 |
#print(time() - stopwatch)
|
345 |
return {"content": f"{_r_content}\n{_w_content}", "style": QType.STMT, "success": True}
|
346 |
except:
|
347 |
+
_w_content = _w.json()['choices'][0]['message']['content'].split('\n',1)[1]
|
348 |
+
#print(time() - stopwatch)
|
349 |
+
return {"content": f"{_r_content}\n{_w_content}", "style": QType.STMT, "success": True}
|
350 |
|
351 |
|
352 |
async def parse_wh_question(raw_qa_list, pgph_i):
|