VRSEN / agency-swarm

The only reliable agent framework built on top of the latest OpenAI Assistants API.
https://vrsen.github.io/agency-swarm/
MIT License
2.05k stars 537 forks source link

Browsing Agent Is not working #128

Open okoliechykwuka opened 1 month ago

okoliechykwuka commented 1 month ago

This is directly from the Browsing Agent Notebook, The only added changes are in line one.

from agency_swarm.agents import BrowsingAgent to from agency_swarm.agents.BrowsingAgent import BrowsingAgent

from agency_swarm.agents.BrowsingAgent import BrowsingAgent
from agency_swarm import Agency, Agent
import openai

openai.api_key = "what_ever"

selenium_config = {
    # your canary profile path
    # "chrome_profile_path": "/Users/vrsen/Library/Application Support/Google/Chrome Canary/Profile 1",
    "headless": False,
    "full_page_screenshot": False,
}

browsing_agent = BrowsingAgent(selenium_config=selenium_config)

agency = Agency([browsing_agent])

demo = agency.demo_gradio(height=700) # Reload the notebook each time you run this cell

ERROR TRACRBACK

Files folder '/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/agency_swarm/agents/BrowsingAgent/files' is not a directory. Skipping...
Schemas folder path is not a directory. Skipping...  /home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/agency_swarm/agents/BrowsingAgent/schemas
Error parsing tool file SelectDropdown.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file ExportFile.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file ClickElement.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file WebPageSummarizer.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file Scroll.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file ReadURL.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file GoBack.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file SolveCaptcha.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file AnalyzeContent.py: invalid syntax (<string>, line 1). Skipping...
Error parsing tool file SendKeys.py: invalid syntax (<string>, line 1). Skipping...
Updating assistant... BrowsingAgent
/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
Running on local URL:  http://127.0.0.1:7860/

To create a public link, set `share=True` in `launch()`.

WHEN I TYPE "what is the current AAPL stock price in the radio text box, I get the below error.

IMPORTANT: You are using gradio version 4.26.0, however version 4.29.0 is available, please upgrade.
--------
Message files:  []
THREAD:[ user -> BrowsingAgent ]: URL https://platform.openai.com/playground?assistant=asst_XIwdgiDFb73zbZ5ySRtranGK&mode=assistant&thread=thread_duQMs2Ji1fsfimOjmUsaTGSG
/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/pydantic/main.py:347: UserWarning: Pydantic serializer warnings:
  Expected `Union[RunStepDeltaMessageDelta, ToolCallDeltaObject]` but got `ToolCallDeltaObject` - serialized value may not be as expected
  Expected `Union[CodeInterpreterToolCallDelta, RetrievalToolCallDelta, FunctionToolCallDelta]` but got `CodeInterpreterToolCallDelta` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(
Exception in thread Thread-9 (get_completion_stream):
Traceback (most recent call last):
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/ipykernel/ipkernel.py", line 761, in run_closure
    _threading_Thread_run(self)
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 147, in get_completion_stream
    next(gen)
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 69, in get_completion
    self._create_run(recipient_agent, additional_instructions, event_handler)
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 196, in _create_run
    stream.until_done()
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 102, in until_done
    consume_sync_iterator(self)
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/openai/_utils/_streams.py", line 6, in consume_sync_iterator
    for _ in iterator:
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 69, in __iter__
    for item in self._iterator:
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 405, in __stream__
...
  File "/home/chukypedro15/anaconda3/envs/pyxellenv/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 266, in on_tool_call_created
    if tool_call.type == "function":
       ^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'type'
emdagon commented 1 month ago

I'm facing the same problem.

Eunomiac commented 1 month ago

Exact same problem here --- both when importing from agency-swarm, and when importing from a custom module I created after importing BrowserAgent via the CLI agency-swarm import-agent command.

VRSEN commented 1 month ago

Hey guys, please install from main branch using pip install --no-cache -e . and let me know if this persists

kinghotelwelco commented 1 month ago

Hey guys, please install from main branch using pip install --no-cache -e . and let me know if this persists

Still not working as of now.

okoliechykwuka commented 1 month ago

I am using requirement or poetry . How can I install the module without using pip install --no-cache -e . so that I can use the browsing agent

pip install --no-cache -e . method can only work in development.

VRSEN commented 1 month ago

Pass local path to latest agency swarm into pip install or in your poetry dependencies. Alternatively install from github pip install --no-cache git+https://github.com/VRSEN/agency-swarm.git @okoliechykwuka

Javitito commented 3 weeks ago

After attempting to resolve the issue with the proposed solution, I am still encountering an error. I'm not sure how severe it is, but here is the error message:

Files folder 'C:\Users\javi\Documents\PROGRAMAS_PYTHON\agency-swarm\agency_swarm\agents\BrowsingAgent\files' is not a directory. Skipping... Schemas folder path is not a directory. Skipping... C:\Users\javi\Documents\PROGRAMAS_PYTHON\agency-swarm\agency_swarm\agents\BrowsingAgent\schemas Updating agent... GenesisCEO Updating agent... ToolCreator Updating agent... AgentCreator Updating agent... OpenAPICreator Updating agent... BrowsingAgent Any guidance on how to fix this would be greatly appreciated.

AmirAlsad commented 3 weeks ago

I'm running the exact same code and the BrowsingAgent is loaded in fine, but when you ask it to search anything, it shoots the following error:

  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/ipykernel/ipkernel.py", line 761, in run_closure
    _threading_Thread_run(self)
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 196, in get_completion_stream
    next(res)
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 118, in get_completion
    self._create_run(recipient_agent, additional_instructions, event_handler, tool_choice)
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 274, in _create_run
    stream.until_done()
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 102, in until_done
    consume_sync_iterator(self)
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/openai/_utils/_streams.py", line 6, in consume_sync_iterator
    for _ in iterator:
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 69, in __iter__
    for item in self._iterator:
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 405, in __stream__
    self._emit_sse_event(event)
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 368, in _emit_sse_event
    self.on_tool_call_created(self._current_tool_call)
  File "/opt/anaconda3/envs/AgencySwarmNotebooks/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 392, in on_tool_call_created
    raise ValueError("Invalid tool call type: " + tool_call["type"])
ValueError: Invalid tool call type: browser

This happens when I ask the agent to search anything up, including @okoliechykwuka's original prompt. It seems that it doesn't have an actual browser tool to make any searches?

okoliechykwuka commented 3 weeks ago

Aside from the bugs, the Framework is too expensive to use.

AmirAlsad commented 3 weeks ago

Just added a SearchWeb tool to the BrowsingAgent in my fork ( #146 ), which resolves some of the bugs. I've also made the agent rely less on the user when navigating by taking more screenshots. Just as a note, don't leave your chrome profile path in the selenium config if you have that chrome profile already open because it will just throw an error (you can't have the same profile open more than once). Other than that make sure you're importing the agent from the right place.