forked from Archives/langchain
Update utils.py to make headless an optional argument (#4745)
Making headless an optional argument for create_async_playwright_browser() and create_sync_playwright_browser() By default no functionality is changed. This allows for disabled people to use a web browser intelligently with their voice, for example, while still seeing the content on the screen. As well as many other use cases --------- Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
This commit is contained in:
parent
a9dbe90447
commit
8bb32d77d0
@ -33,18 +33,18 @@ def get_current_page(browser: SyncBrowser) -> SyncPage:
|
||||
return context.pages[-1]
|
||||
|
||||
|
||||
def create_async_playwright_browser() -> AsyncBrowser:
|
||||
def create_async_playwright_browser(headless: bool = True) -> AsyncBrowser:
|
||||
from playwright.async_api import async_playwright
|
||||
|
||||
browser = run_async(async_playwright().start())
|
||||
return run_async(browser.chromium.launch(headless=True))
|
||||
return run_async(browser.chromium.launch(headless=headless))
|
||||
|
||||
|
||||
def create_sync_playwright_browser() -> SyncBrowser:
|
||||
def create_sync_playwright_browser(headless: bool = True) -> SyncBrowser:
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
browser = sync_playwright().start()
|
||||
return browser.chromium.launch(headless=True)
|
||||
return browser.chromium.launch(headless=headless)
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
|
Loading…
Reference in New Issue
Block a user