Open CurtMRosenbladWheeler opened 6 months ago
🤖
Hello @CurtMRosenbladWheeler! I'm Dosu, an AI bot here to assist you with resolving issues, answering questions, and helping you contribute to LangChain. While we're waiting for a human maintainer to join us, feel free to ask me anything you might need help with. Let's work together to make LangChain even better!
Thank you for providing such a detailed description of the issue you're facing. It seems like the Playwright Browser is not behaving as expected within the LangChain framework. Let's try to troubleshoot this issue.
Firstly, it's important to ensure that the Playwright Python library is correctly installed and configured, as it is a crucial dependency for the Playwright Browser to function correctly within the LangChain framework. You can verify this by running the following command in your terminal:
pip show playwright
This command should return information about the installed Playwright package. If it doesn't return anything, it means that the Playwright library is not installed, and you should install it using the following command:
pip install playwright
After installing the Playwright library, you need to run the following command to download the necessary browser binaries:
playwright install
If the Playwright library is correctly installed and configured but the issue persists, it might be related to the specific implementation of the Playwright tools within the LangChain framework.
From the code you've shared, it seems like the issue arises when the navigate_browser
tool is invoked. This tool is likely used to navigate to different URLs or pages within the browser. If the browser is freezing during this operation, it might be due to network issues, or the page taking too long to load.
One way to debug this issue is to run the Playwright Browser in non-headless mode by setting the headless
parameter to False
when creating the browser:
playwright_async_browser = create_async_playwright_browser(headless=False)
Running the browser in non-headless mode will open a graphical browser window, allowing you to see what's happening when the navigate_browser
tool is invoked.
If the issue still persists, it would be helpful to have more information about the error. Are there any error messages being displayed in the console when the browser freezes? This information could provide valuable clues about what's causing the issue.
I hope this helps! Please let me know if you have any other questions or if there's anything else I can do to assist you.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
I had the same issue in a gradio app. I moved the use of function create_sync_playwright_browser
to a piece of code that was running at startup instead of in a function called by gradio and it worked.
Edit: not sure it's a good fix actually because I now get greenlet.error: cannot switch to a different thread
and struggle to find a workaround (I'm using the sync playwright version and don't plan on converting my codebase to async)
In the end I moved to async and am getting the same issue :
[tool/start] [1:chain:AgentExecutor > 4:tool:navigate_browser] Entering Tool run with input:
"{'url': 'https://duckduckgo.com/?q=sam+altman+birthdate'}"
hangs indefinitely
Facing a similar issue with FastAPI, cannot use either sync or async, tried messing around with all possible combos but nothing seems to work
Me too @@
System Info
System Info
LangChain Version: 0.0.354
Platform: MacOS Sonoma 14.2.1 Python Version: 3.11.6
Who can help?
@hwchase17 @agola11
Information
Related Components
Reproduction
Code sample that utilizes the Playwright Toolkit: https://python.langchain.com/docs/integrations/toolkits/playwright
For instance, when you attempt to run:
Nothing happens after 20 minutes.
The only way I have been able to get a response was by waiting a few seconds and then turning off my computer's wifi, which would return the expected:
I am utilizing the browser in an agent, and here is the code:
And when it executes a Playwright browser-related command, it just freezes and does nothing.
Here is an example that runs a Playwright browser-related command:
But when it utilizes any other tool, such as Tavily Search, it works successfully:
Expected behavior
The behavior of the Playwright Browser should return results to an input in a relatively prompt manner, but it currently freezes and returns.