rishi1985 commited on
Commit
6a813c9
·
1 Parent(s): 43899bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -102,17 +102,17 @@ async def get_answer_llama(request: Request ):
102
  # print("recived ",text)
103
  proxy=None
104
 
105
- # try:
106
- # proxy = data['proxy']
107
- # except:
108
- # pass
109
- # print('proxy ip ', proxy )
110
  currtime= time.time()
111
  res= ""
112
  if currtime-llama_last_error<=3600:
113
- res = do_ML_LLAMA7b(text,0)
114
  else:
115
- res= do_ML_LLAMA70b_chori(text,0, proxy)
116
 
117
  dict={"LLAMA":res}
118
 
@@ -187,6 +187,7 @@ def do_ML_LLAMA70b_chori(text:str, trycount:int, proxy:str):
187
 
188
  driver.delete_all_cookies()
189
  driver.quit()
 
190
  return div_text
191
 
192
 
@@ -208,6 +209,7 @@ def do_ML_LLAMA70b_chori(text:str, trycount:int, proxy:str):
208
  def do_ML_LLAMA70b(text:str, trycount:int, proxy:str):
209
  starttime=time.time()
210
  options = ChromeOptions()
 
211
  options.add_argument('--no-sandbox')
212
  options.add_argument('-headless')
213
  options.add_argument("start-maximized")
@@ -229,6 +231,7 @@ def do_ML_LLAMA70b(text:str, trycount:int, proxy:str):
229
  if(currtime>starttime+20):
230
  driver.delete_all_cookies()
231
  driver.quit()
 
232
  return "Requested Could not be proceed"
233
  try:
234
  # xpath_expression = '//textarea[@data-testid="tex
@@ -272,11 +275,13 @@ def do_ML_LLAMA70b(text:str, trycount:int, proxy:str):
272
  element_text = element.text # Extract the text from the element
273
  driver.delete_all_cookies()
274
  driver.quit()
 
275
  return element_text
276
 
277
 
278
  driver.delete_all_cookies()
279
  driver.quit()
 
280
  return " --Error Occurred-- "
281
 
282
 
@@ -284,6 +289,7 @@ def do_ML_LLAMA70b(text:str, trycount:int, proxy:str):
284
  except:
285
  driver.delete_all_cookies()
286
  driver.quit()
 
287
  return "Error Occurred "
288
 
289
 
 
102
  # print("recived ",text)
103
  proxy=None
104
 
105
+ try:
106
+ proxy = data['proxy']
107
+ except:
108
+ pass
109
+ print('proxy ip ', proxy )
110
  currtime= time.time()
111
  res= ""
112
  if currtime-llama_last_error<=3600:
113
+ res = do_ML_LLAMA70b_chori(text,0,proxy)
114
  else:
115
+ res= do_ML_LLAMA70b(text,0, proxy)
116
 
117
  dict={"LLAMA":res}
118
 
 
187
 
188
  driver.delete_all_cookies()
189
  driver.quit()
190
+ print("Lllama chori")
191
  return div_text
192
 
193
 
 
209
  def do_ML_LLAMA70b(text:str, trycount:int, proxy:str):
210
  starttime=time.time()
211
  options = ChromeOptions()
212
+ global llama_last_error
213
  options.add_argument('--no-sandbox')
214
  options.add_argument('-headless')
215
  options.add_argument("start-maximized")
 
231
  if(currtime>starttime+20):
232
  driver.delete_all_cookies()
233
  driver.quit()
234
+ llama_last_error= currtime
235
  return "Requested Could not be proceed"
236
  try:
237
  # xpath_expression = '//textarea[@data-testid="tex
 
275
  element_text = element.text # Extract the text from the element
276
  driver.delete_all_cookies()
277
  driver.quit()
278
+ print("llama huugiing chat")
279
  return element_text
280
 
281
 
282
  driver.delete_all_cookies()
283
  driver.quit()
284
+ llama_last_error= time.time()
285
  return " --Error Occurred-- "
286
 
287
 
 
289
  except:
290
  driver.delete_all_cookies()
291
  driver.quit()
292
+ llama_last_error= time.time()
293
  return "Error Occurred "
294
 
295