OuroborosM commited on
Commit
233aef1
·
1 Parent(s): 10fbdc8

update browser status

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -73,6 +73,7 @@ from langchain.schema import (
73
  Generation,
74
  LLMResult
75
  )
 
76
 
77
  class GPTRemote(LLM):
78
  n: int
@@ -146,11 +147,17 @@ GPTfake = GPTRemote(n=0)
146
 
147
 
148
  async def start_playwright(question: str):
 
149
  pw = await async_playwright().start()
150
  browser = await pw.chromium.launch(headless=True)
 
 
 
151
  # browser = await pw.webkit.launch(headless=True)
152
  page = await browser.new_page()
153
-
 
 
154
  # note all methods are async (use the "await" keyword)
155
  await page.goto("https://basicchatbot.azurewebsites.net/")
156
  # print("Title of Web: ", await page.title())
@@ -164,13 +171,13 @@ async def start_playwright(question: str):
164
  # print("Content of Web: ", await page.content())
165
  # await page.locator("//button[@class='css-1wi2cd3 e1d2x3se3']").click()
166
  await page.locator("//textarea").press("Enter")
167
- await page.wait_for_timeout(2000)
168
  # print("Content of Web: ", await page.content())
169
  # print("output_text 1", await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text())
170
  # output_text = await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text()
171
  # print("output_text 1", output_text)
172
  output_history = "NOTHING"
173
- for i in range(40):
174
  output_text = await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text()
175
  print("output_text... :")
176
 
@@ -180,6 +187,8 @@ async def start_playwright(question: str):
180
  await page.wait_for_timeout(500)
181
  output_history = output_text
182
  print("-------- Final Answer-----------\n", output_text)
 
 
183
  await browser.close()
184
 
185
 
@@ -1532,7 +1541,7 @@ if __name__ == '__main__':
1532
  # CreatDb()
1533
  # QAQuery("what is COFOR ?")
1534
  # CreatDb_P()
1535
- QAQuery_p("what is PDP ?")
1536
  # question = "what is PDP?"
1537
  # output = asyncio.run(start_playwright(question))
1538
 
 
73
  Generation,
74
  LLMResult
75
  )
76
+ import time
77
 
78
  class GPTRemote(LLM):
79
  n: int
 
147
 
148
 
149
  async def start_playwright(question: str):
150
+ start_t = time.time()
151
  pw = await async_playwright().start()
152
  browser = await pw.chromium.launch(headless=True)
153
+ end_t = time.time()
154
+ print("Init Browser Done:", end_t - start_t)
155
+ start_t = end_t
156
  # browser = await pw.webkit.launch(headless=True)
157
  page = await browser.new_page()
158
+ end_t = time.time()
159
+ print("New Page Done:", end_t - start_t)
160
+ start_t = end_t
161
  # note all methods are async (use the "await" keyword)
162
  await page.goto("https://basicchatbot.azurewebsites.net/")
163
  # print("Title of Web: ", await page.title())
 
171
  # print("Content of Web: ", await page.content())
172
  # await page.locator("//button[@class='css-1wi2cd3 e1d2x3se3']").click()
173
  await page.locator("//textarea").press("Enter")
174
+ await page.wait_for_timeout(1000)
175
  # print("Content of Web: ", await page.content())
176
  # print("output_text 1", await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text())
177
  # output_text = await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text()
178
  # print("output_text 1", output_text)
179
  output_history = "NOTHING"
180
+ for i in range(100):
181
  output_text = await page.locator("//div[@aria-label='Chat message from assistant']").last.inner_text()
182
  print("output_text... :")
183
 
 
187
  await page.wait_for_timeout(500)
188
  output_history = output_text
189
  print("-------- Final Answer-----------\n", output_text)
190
+ end_t = time.time()
191
+ print("Output Done:", end_t - start_t)
192
  await browser.close()
193
 
194
 
 
1541
  # CreatDb()
1542
  # QAQuery("what is COFOR ?")
1543
  # CreatDb_P()
1544
+ # QAQuery_p("what is PDP ?")
1545
  # question = "what is PDP?"
1546
  # output = asyncio.run(start_playwright(question))
1547