handrew / browserpilot

Natural language browser automation
MIT License
497 stars 60 forks source link

Dependencies issues #4

Closed agn-7 closed 8 months ago

agn-7 commented 8 months ago

Apparently, there are dependencies issues in the current branch:

poetry run python -m browserpilot.agents.gpt_selenium_agent

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/__init__.py", line 1, in <module>
    from .gpt_selenium_agent import GPTSeleniumAgent
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/gpt_selenium_agent.py", line 11, in <module>
    from llama_index import Document, GPTVectorStoreIndex
ImportError: cannot import name 'Document' from 'llama_index' (unknown location)
agn-7 commented 8 months ago

To resolve the above issue, I added this PR #5

agn-7 commented 8 months ago

However, still have problem running the project:

poetry run python examples.py selenium prompts/examples/buffalo_wikipedia.yaml --chromedriver_path /home/benyamin/Downloads/chrome-linux64/chrome

It opens a chrome instance, however, after a while it's closed following the error below:

INFO:browserpilot.agents.gpt_selenium_agent:Using model for instructions: gpt-3.5-turbo
INFO:browserpilot.agents.gpt_selenium_agent:Using model for responses: gpt-3.5-turbo
INFO:browserpilot.agents.compilers.instruction_compiler:Using model gpt-3.5-turbo.
Traceback (most recent call last):
  File "/home/benyamin/PycharmProjects/browserpilot/examples.py", line 52, in <module>
    cli()
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/examples.py", line 26, in selenium
    agent = GPTSeleniumAgent(
            ^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/gpt_selenium_agent.py", line 137, in __init__
    self.driver = webdriver.Chrome(service=service, options=_chrome_options)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 50, in __init__
    self.service.start()
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/common/service.py", line 109, in start
    raise WebDriverException(f"Can not connect to the Service {self._path}")
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /home/benyamin/Downloads/chrome-linux64/chrome

What am I wrong?

agn-7 commented 8 months ago

I realized I should have downloaded the chromeDriver instead of chrome!

Therefore, I downloaded the latest version of chrome driver (i.e. 114.0.5735.90). Now, here's the result:

poetry run python examples.py selenium prompts/examples/buffalo_wikipedia.yaml --chromedriver_path /home/benyamin/Downloads/chromedriver_linux64/chromedriver

INFO:browserpilot.agents.gpt_selenium_agent:Using model for instructions: gpt-3.5-turbo
INFO:browserpilot.agents.gpt_selenium_agent:Using model for responses: gpt-3.5-turbo
INFO:browserpilot.agents.compilers.instruction_compiler:Using model gpt-3.5-turbo.
Traceback (most recent call last):
  File "/home/benyamin/PycharmProjects/browserpilot/examples.py", line 52, in <module>
    cli()
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/examples.py", line 26, in selenium
    agent = GPTSeleniumAgent(
            ^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/gpt_selenium_agent.py", line 137, in __init__
    self.driver = webdriver.Chrome(service=service, options=_chrome_options)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 61, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 122.0.6261.57 with binary path /usr/bin/google-chrome
Stacktrace:
#0 0x55b148a884e3 <unknown>
#1 0x55b1487b7c76 <unknown>
#2 0x55b1487e504a <unknown>
#3 0x55b1487e04a1 <unknown>
#4 0x55b1487dd029 <unknown>
#5 0x55b14881bccc <unknown>
#6 0x55b14881b47f <unknown>
#7 0x55b148812de3 <unknown>
#8 0x55b1487e82dd <unknown>
#9 0x55b1487e934e <unknown>
#10 0x55b148a483e4 <unknown>
#11 0x55b148a4c3d7 <unknown>
#12 0x55b148a56b20 <unknown>
#13 0x55b148a4d023 <unknown>
#14 0x55b148a1b1aa <unknown>
#15 0x55b148a716b8 <unknown>
#16 0x55b148a71847 <unknown>
#17 0x55b148a81243 <unknown>
#18 0x7fd7aaaf9ac3 <unknown>

Apparently, there's an inconsistency between my current chrom version (122.0.6261.5) and the web driver!

what actions should I pursue?

agn-7 commented 8 months ago

Oops, my bad. Eventually, I found the proper chrome driver link:

https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.94/linux64/chromedriver-linux64.zip

agn-7 commented 8 months ago

Now, again old interface issue:

Traceback (most recent call last):
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/compilers/instruction_compiler.py", line 284, in get_completion
    response = openai.ChatCompletion.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/openai/lib/_old_api.py", line 39, in __call__
    raise APIRemovedInV1(symbol=self._symbol)
openai.lib._old_api.APIRemovedInV1: 

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/benyamin/PycharmProjects/browserpilot/examples.py", line 52, in <module>
    cli()
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/.cache/pypoetry/virtualenvs/browserpilot-wv6QXQHP-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/examples.py", line 35, in selenium
    agent.run()
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/gpt_selenium_agent.py", line 404, in run
    self.__step_through_instructions()
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/gpt_selenium_agent.py", line 343, in __step_through_instructions
    step = self.instruction_compiler.step()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/compilers/instruction_compiler.py", line 348, in step
    action_info = self.get_action_output(instructions)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/compilers/instruction_compiler.py", line 332, in get_action_output
    completion = self.get_completion(prompt).strip()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benyamin/PycharmProjects/browserpilot/browserpilot/agents/compilers/instruction_compiler.py", line 309, in get_completion
    openai.error.RateLimitError,
    ^^^^^^^^^^^^
AttributeError: module 'openai' has no attribute 'error'

I'll fix them asap.

agn-7 commented 8 months ago

Regarding the above issue with openAI interfaces. I updated the PR #5. The problem has been resolved.