Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BrowserbaseLoadTool needs an update with newer Browserbase python SDK #140

Open
filip-michalsky opened this issue Dec 4, 2024 · 1 comment

Comments

@filip-michalsky
Copy link

the newer Browserbase python SDK seems to not pass env vars into the browserbase object which causes an error here:

https://github.com/crewAIInc/crewAI-tools/blob/main/crewai_tools/tools/browserbase_load_tool/browserbase_load_tool.py#L42

@reproduce-bot
Copy link

The following script is generated by AI Agent to help reproduce the issue:

# crewAI-tools/crewai_tools/tools/browserbase_load_tool/reproduce.py
import os
import sys
from unittest.mock import MagicMock, patch

# Mock the browserbase module
mock_browserbase = MagicMock()
sys.modules['browserbase'] = mock_browserbase
mock_browserbase.Browserbase.return_value.load_url.return_value = "Mocked content"

from crewai_tools.tools.browserbase_load_tool.browserbase_load_tool import BrowserbaseLoadTool

def test_browserbase_load_tool():
    # Set environment variables
    os.environ['BROWSERBASE_API_KEY'] = 'test_api_key'
    os.environ['BROWSERBASE_PROJECT_ID'] = 'test_project_id'

    try:
        tool = BrowserbaseLoadTool()
        # Simulate the issue by checking if the environment variables are not passed to the browserbase object
        if tool.browserbase.api_key != os.environ['BROWSERBASE_API_KEY'] or tool.browserbase.project_id != os.environ['BROWSERBASE_PROJECT_ID']:
            raise AssertionError("Environment variables not passed to the browserbase object correctly.")
        try:
            result = tool._run("https://example.com")
            print("Test passed successfully with no errors!")
        except Exception as e:
            raise AssertionError(e)
    except Exception as e:
        raise AssertionError(e)

if __name__ == "__main__":
    test_browserbase_load_tool()

How to run:

python3 crewAI-tools/crewai_tools/tools/browserbase_load_tool/reproduce.py

Expected Result:

Traceback (most recent call last):
  File "crewAI-tools/crewai_tools/tools/browserbase_load_tool/reproduce.py", line 21, in test_browserbase_load_tool
    raise AssertionError("Environment variables not passed to the browserbase object correctly.")
AssertionError: Environment variables not passed to the browserbase object correctly.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "crewAI-tools/crewai_tools/tools/browserbase_load_tool/reproduce.py", line 31, in <module>
    test_browserbase_load_tool()
  File "crewAI-tools/crewai_tools/tools/browserbase_load_tool/reproduce.py", line 28, in test_browserbase_load_tool
    raise AssertionError(e)
AssertionError: Environment variables not passed to the browserbase object correctly.

Thank you for your valuable contribution to this project and we appreciate your feedback! Please respond with an emoji if you find this script helpful. Feel free to comment below if any improvements are needed.

Best regards from an AI Agent!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants