autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[Bug]: Autogen is not searching in internet

Open zioalex opened this issue 1 year ago • 3 comments

Describe the bug

I am trying to use the WebSurferAgent as described here https://nbviewer.org/github/microsoft/autogen/blob/main/notebook/agentchat_surfer.ipynb

Here is my code:

import os
import autogen
from autogen.agentchat.contrib.web_surfer import WebSurferAgent  # noqa: E402
# pip install "pyautogen[websurfer]"

BASE_URL="http://localhost:11434/v1/"
bing_api_key = os.environ["BING_API_KEY"]

# Openai Secret key 
openai_key = ""
config_list_mistral = [ {
	'base_url': BASE_URL,
        'api_key': "NULL",
	'model': "mistral",
	'timeout': 1800
    }
]


#'base_url': "http://0.0.0.0:8000",
#	'model': "ollama/llama2-uncensored",
config_list_codellama = [ {
	'base_url': BASE_URL,
        'api_key': "NULL",
	'model': "llama3:8b",
	'timeout': 1800
    }
]

llm_config_mistral={
    "config_list": config_list_mistral,
}

llm_config_codellama={
    "config_list": config_list_codellama,
}


web_surfer = WebSurferAgent(
    "web_surfer",
    llm_config=llm_config_codellama,
    summarizer_llm_config=llm_config_mistral,
    browser_config={"viewport_size": 4096, "bing_api_key": bing_api_key},
)

user_proxy = autogen.UserProxyAgent(
    "user_proxy",
    human_input_mode="NEVER",
    code_execution_config=False,
    default_auto_reply="",
    is_termination_msg=lambda x: True,
)

task1 = """
Search the web for information about Microsoft PyAutoGen. Report the found internet links.
"""

chat_res = user_proxy.initiate_chat(web_surfer, message=task1, clear_history=False)

print("Summary:", chat_res.summary)
print("Cost info:", chat_res.cost)

Steps to reproduce

  1. Created a Bing search resource in Azure
  2. Exported the Key in my shell
  3. run the code with python websearch.py
  4. It runs without error but the response is wrong and not updated

Model Used

llama3:8b and mistral

Expected Behavior

A proper internet search is done.

Screenshots and logs

No response

Additional Information

annotated-types==0.6.0
anyio==4.3.0
beautifulsoup4==4.12.3
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==42.0.5
diskcache==5.6.3
distro==1.9.0
docker==7.0.0
exceptiongroup==1.2.1
FLAML==2.1.2
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
idna==3.7
markdownify==0.12.1
numpy==1.24.4
openai==1.20.0
packaging==24.0
pathvalidate==3.2.0
pdfminer.six==20231228
pyautogen==0.2.26
pycparser==2.22
pydantic==2.7.1
pydantic-core==2.18.2
python-dotenv==1.0.1
regex==2024.4.16
requests==2.31.0
six==1.16.0
sniffio==1.3.1
soupsieve==2.5
termcolor==2.4.0
tiktoken==0.6.0
tqdm==4.66.2
typing-extensions==4.11.0
urllib3==2.2.1

zioalex avatar May 03 '24 23:05 zioalex

It runs without error but the response is wrong and not updated

What is the response?

ekzhu avatar May 04 '24 06:05 ekzhu

@zioalex please share the response or any screenshots. Thanks

Hk669 avatar May 08 '24 17:05 Hk669

@Hk669 I have a very similar setup and also have no response. Upon setting a break point and playing around in web_surfer.py, self.browser.visit_page is not called during the process. I think it's probably due to the method is not called somehow. self.browser.page_title is None. Below is my response in terminal.

user_proxy (to web_surfer):


Search the web for information about Microsoft AutoGen


--------------------------------------------------------------------------------

>>>>>>>> USING AUTO REPLY...
web_surfer (to user_proxy):

{"name": "informational_web_search", "parameters": {"query": "Microsoft AutoGen"}}

--------------------------------------------------------------------------------
user_proxy (to web_surfer):

Summarize these results

--------------------------------------------------------------------------------

>>>>>>>> USING AUTO REPLY...
web_surfer (to user_proxy):

{"name": "summarize_page", "parameters": {"url": "about:blank"}}

--------------------------------------------------------------------------------

hepengfe avatar Aug 04 '24 21:08 hepengfe