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

Feature/researcher #161

Merged
merged 7 commits into from
Aug 10, 2023
Merged

Feature/researcher #161

merged 7 commits into from
Aug 10, 2023

Conversation

shenchucheng
Copy link
Collaborator

Features

  • Unified Search Engine API with support for returning structured data
  • Unified WebPage object return for the WebBrowserEngine API
  • Added DuckDuckGo as a Search Engine
  • Added a new researcher role

Search Engine API

class SearchEngine:
    @overload
    def run(self, query: str, max_results: int = 8, as_string: Literal[True] = True) -> str:
        ...

    @overload
    def run(self, query: str, max_results: int = 8, as_string: Literal[False] = False) -> list[dict[str, str]]:
        ...

    async def run(self, query: str, max_results: int = 8, as_string: bool = True) -> str | list[dict[str, str]]:
        """Run a search query.

        Args:
            query: The search query.
            max_results: The maximum number of results to return. Defaults to 8.
            as_string: Whether to return the results as a string or a list of dictionaries. Defaults to True.

        Returns:
            The search results as a string or a list of dictionaries.
        """
        ...

WebBrowserEngine API

class WebBrowserEngine:
    @overload
    async def run(self, url: str) -> WebPage:
        ...

    @overload
    async def run(self, url: str, *urls: str) -> list[WebPage]:
        ...

    async def run(self, url: str, *urls: str) -> WebPage | list[WebPage]:
        ...

@daviskeene
Copy link

This is awesome!

@stellaHSR
Copy link
Collaborator

LGTM

examples/research.py Outdated Show resolved Hide resolved
metagpt/actions/research.py Outdated Show resolved Hide resolved
metagpt/actions/research.py Outdated Show resolved Hide resolved
metagpt/actions/research.py Outdated Show resolved Hide resolved
metagpt/actions/research.py Outdated Show resolved Hide resolved
metagpt/roles/researcher.py Show resolved Hide resolved
metagpt/tools/search_engine_serper.py Show resolved Hide resolved
metagpt/utils/parse_html.py Outdated Show resolved Hide resolved
metagpt/utils/text.py Show resolved Hide resolved
metagpt/tools/search_engine_googleapi.py Show resolved Hide resolved
@better629
Copy link
Collaborator

@shenchucheng Can you provide an execution log file as attachment of Researcher?

@shenchucheng
Copy link
Collaborator Author

@shenchucheng Can you provide an execution log file as attachment of Researcher?

logs: log.txt
report: dataiku vs. datarobot.md

@better629
Copy link
Collaborator

LGTM

@stellaHSR stellaHSR merged commit 2e1e647 into geekan:main Aug 10, 2023
@RonTuretzky
Copy link

I'm getting

File "/home//.local/lib/python3.10/site-packages/yarl/_url.py", line 946, in _query_var
raise TypeError(
TypeError: Invalid variable type: value should be str, int or float, got None of type <class 'NoneType'>

@shenchucheng
Copy link
Collaborator Author

I'm getting

File "/home//.local/lib/python3.10/site-packages/yarl/_url.py", line 946, in _query_var raise TypeError( TypeError: Invalid variable type: value should be str, int or float, got None of type <class 'NoneType'>

This issue arises due to the absence of a set SERPAPI_API_KEY for the SerpAPI search engine, and there's a lack of a user-friendly error message. You can locate the SERPAPI_API_KEY in config.yaml#L28 for reference.

And in pr #240, there will be a check implemented during the execution of the SearchEngine to verify if the required packages or configurations meet the criteria. If the prerequisites are not met, an exception will be triggered, accompanied by user-friendly suggestions for necessary modifications.

@RonTuretzky
Copy link

@shenchucheng Thank you, that worked!

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

Successfully merging this pull request may close these issues.

None yet

5 participants