From 8bb32d77d0703665d498e4d9bcfafa14d202d423 Mon Sep 17 00:00:00 2001 From: d 3 n 7 <29033313+d3n7@users.noreply.github.com> Date: Tue, 16 May 2023 02:29:06 +0200 Subject: [PATCH] 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 --- langchain/tools/playwright/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/langchain/tools/playwright/utils.py b/langchain/tools/playwright/utils.py index b5e7f136..b48ce1f3 100644 --- a/langchain/tools/playwright/utils.py +++ b/langchain/tools/playwright/utils.py @@ -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")