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.74k stars 727 forks source link

BrowsingAgent get_completion() returns a generator object #138

Closed Omotade-MY closed 4 months ago

Omotade-MY commented 5 months ago

I tried running the example notebook on browsing agent and it worked fine. However, in the notebook the demo_gradio() method ws used to start the agent. But I want to run the agent in a script so I used the get_completion() method by calling on the agent instance but it keeps returning a generator object. What should I do to get the response.

Below is the code I ran and the output

` def agency_agent(task): """

    :param task: A string of the user task prompt.
    :type task: str

    :return: The output of running the modified task using the Agency Swarm.
    :rtype: Any
    """

    report_manager = Agent(name="Report Manager",
        description="The Report Manager Agent is responsible for supervising data collection,  task completion from various  websites,  and compiling reports as necessary.",
        instructions=dedent("""As a Report Manager Agent, your role involves direct interaction and oversight of the BrowsingAgent's operations.
                               Your primary duty is to guarantee that the user's task is comprehensively and accurately completed. 
                               Achieve this by methodically breaking down each task from the user into smaller steps required to complete it. Then, issue each step of the task as a distinct message to the BrowsingAgent.
                               Make sure to always tell the browsing agent to go back to google search results before proceeding to the the next source. After the necessary data is collection, compile a report and send it to the user.
                               Make sure to ask the browsing agent for direct links to the sources and include them into report. Try to trouble shoot any issues that may arise along the way with the other agents first, before reporting back to the user.
                               Do not respond to the user until the report is complete or you have encountered an issue that you cannot resolve yourself.""")
                            )

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

    browsing_agent = BrowsingAgent(selenium_config=selenium_config)

    agency = Agency([report_manager,
               [report_manager, browsing_agent]],
               shared_instructions=dedent("""You are a part of a web browsing agency with the goal to find the most relevant information, fill forms, create account, analyse stock prices, and compile reports.
                                    Your core value is autonomy and you are free to use any means necessary to achieve your goal. You do not stop until you have found the information you need or you have exhausted all possible means.
                                    You always to compile a comprehensive report with as much information from the web pages as possible.""")
                   )

    completion_output = agency.get_completion(task, yield_messages=True)

    return completion_output
`

`task_2 = "'https://relevanceai.com/pricing/', Extract the pricing info"

agency_output = agency_agent(task=task_2)
print(agency_output)

`

Here is the output I got:

Files folder '/opt/anaconda3/envs/fastapis/lib/python3.10/site-packages/agency_swarm/agents/BrowsingAgent/files' is not a directory. Skipping... Schemas folder path is not a directory. Skipping... /opt/anaconda3/envs/fastapis/lib/python3.10/site-packages/agency_swarm/agents/BrowsingAgent/schemas Error parsing tool file ClickElement.py: invalid syntax (<string>, line 1). Skipping... Error parsing tool file GoBack.py: invalid syntax (<string>, line 1). Skipping... Error parsing tool file ExportFile.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 SendKeys.py: invalid syntax (<string>, line 1). Skipping... Error parsing tool file WebPageSummarizer.py: invalid syntax (<string>, line 1). Skipping... Error parsing tool file SelectDropdown.py: invalid syntax (<string>, line 1). Skipping... Error parsing tool file SolveCaptcha.py: invalid syntax (<string>, line 1). Skipping... Updating agent... Report Manager Updating agent... BrowsingAgent <generator object Thread.get_completion at 0x7fc0ff97bf40>

VRSEN commented 5 months ago

Just set yield_messages=False in get_completion method

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity. Please upgrade to the latest version and test it again.

github-actions[bot] commented 4 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale. If the issue still persists, please reopen.