rishi1985 commited on
Commit
6ee94f3
1 Parent(s): 1d23542

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -24,6 +24,7 @@ from selenium.webdriver.chrome.service import Service
24
  import threading
25
  import random
26
  import string
 
27
  import time
28
 
29
 
@@ -125,11 +126,16 @@ def do_ML_LLAMA(text:str, trycount:int):
125
  textarea_xpath = "//textarea[@data-testid='textbox' and @class='scroll-hide svelte-1kcgrqr' and @dir='ltr' and @placeholder='Type a message...']"
126
  textarea_element = driver.find_element(By.XPATH,textarea_xpath)
127
 
128
- textarea_element.send_keys(text)
 
 
 
 
129
  break
130
  except:
131
  continue
132
  while True:
 
133
  if(currtime>starttime+10):
134
  return "Requested Could not be proceed"
135
 
@@ -150,7 +156,7 @@ def do_ML_LLAMA(text:str, trycount:int):
150
  # time.sleep(2)
151
  while True:
152
  time.sleep(0.5)
153
- # currtime= time.time()
154
 
155
  if(currtime>starttime+120):
156
  driver.delete_all_cookies()
@@ -164,7 +170,10 @@ def do_ML_LLAMA(text:str, trycount:int):
164
  print(element.text)
165
  # Extract the text from the div element
166
  text = element.text
167
- print("text from llama",text)
 
 
 
168
  if prev!="":
169
 
170
  try:
@@ -235,19 +244,23 @@ def do_ML_MPT(text:str, trycount:int):
235
 
236
  while True:
237
  currtime= time.time()
238
- if(currtime>starttime+10):
239
  return "Requested Could not be proceed"
240
  try:
241
  textarea_xpath = "//textarea[@data-testid='textbox' and @class='scroll-hide svelte-1pie7s6' and @placeholder='Chat Message Box']"
242
  textarea_element = driver.find_element(By.XPATH,textarea_xpath)
243
 
244
- textarea_element.send_keys(text)
 
 
 
245
  break
246
  except:
247
  continue
248
 
249
  while True:
250
- if(currtime>starttime+10):
 
251
  return "Requested Could not be proceed"
252
  try:
253
 
@@ -268,7 +281,7 @@ def do_ML_MPT(text:str, trycount:int):
268
  # time.sleep(2)
269
  while True:
270
  time.sleep(0.5)
271
- # currtime= time.time()
272
 
273
  if(currtime>starttime+120):
274
  driver.delete_all_cookies()
 
24
  import threading
25
  import random
26
  import string
27
+ from selenium.webdriver.common.keys import Keys
28
  import time
29
 
30
 
 
126
  textarea_xpath = "//textarea[@data-testid='textbox' and @class='scroll-hide svelte-1kcgrqr' and @dir='ltr' and @placeholder='Type a message...']"
127
  textarea_element = driver.find_element(By.XPATH,textarea_xpath)
128
 
129
+ for line in text.split('\n'):
130
+ textarea_element.send_keys(line)
131
+ # Simulate pressing the 'Shift + Enter' keys to add a newline without triggering submit
132
+ textarea_element.send_keys(Keys.SHIFT + Keys.ENTER)
133
+
134
  break
135
  except:
136
  continue
137
  while True:
138
+ currtime= time.time()
139
  if(currtime>starttime+10):
140
  return "Requested Could not be proceed"
141
 
 
156
  # time.sleep(2)
157
  while True:
158
  time.sleep(0.5)
159
+ currtime= time.time()
160
 
161
  if(currtime>starttime+120):
162
  driver.delete_all_cookies()
 
170
  print(element.text)
171
  # Extract the text from the div element
172
  text = element.text
173
+ # print("text from llama",text)
174
+
175
+
176
+
177
  if prev!="":
178
 
179
  try:
 
244
 
245
  while True:
246
  currtime= time.time()
247
+ if(currtime>starttime+20):
248
  return "Requested Could not be proceed"
249
  try:
250
  textarea_xpath = "//textarea[@data-testid='textbox' and @class='scroll-hide svelte-1pie7s6' and @placeholder='Chat Message Box']"
251
  textarea_element = driver.find_element(By.XPATH,textarea_xpath)
252
 
253
+ for line in text.split('\n'):
254
+ textarea_element.send_keys(line)
255
+ # Simulate pressing the 'Shift + Enter' keys to add a newline without triggering submit
256
+ textarea_element.send_keys(Keys.SHIFT + Keys.ENTER)
257
  break
258
  except:
259
  continue
260
 
261
  while True:
262
+ currtime= time.time()
263
+ if(currtime>starttime+20):
264
  return "Requested Could not be proceed"
265
  try:
266
 
 
281
  # time.sleep(2)
282
  while True:
283
  time.sleep(0.5)
284
+ currtime= time.time()
285
 
286
  if(currtime>starttime+120):
287
  driver.delete_all_cookies()