Skip to content

Commit

Permalink
Merge pull request #965 from Abhishek0075/exampleChange
Browse files Browse the repository at this point in the history
Improvement made : by automating search engine configuration in example search_in_search_engine.py
  • Loading branch information
iorisa authored Mar 11, 2024
2 parents 5e02f4c + cbfbecb commit ea70fd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/debate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@Modified By: mashenquan, 2023-11-1. In accordance with Chapter 2.1.3 of RFC 116, modify the data type of the `send_to`
value of the `Message` object; modify the argument type of `get_by_actions`.
"""

import asyncio
import platform
from typing import Any
Expand Down Expand Up @@ -105,4 +106,4 @@ def main(idea: str, investment: float = 3.0, n_round: int = 10):


if __name__ == "__main__":
fire.Fire(main)
fire.Fire(main) # run as python debate.py --idea="TOPIC" --investment=3.0 --n_round=5
16 changes: 6 additions & 10 deletions examples/search_with_specific_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@
"""
import asyncio

from metagpt.config2 import Config
from metagpt.roles import Searcher
from metagpt.tools.search_engine import SearchEngine, SearchEngineType
from metagpt.tools.search_engine import SearchEngine


async def main():
question = "What are the most interesting human facts?"
kwargs = {"api_key": "", "cse_id": "", "proxy": None}
# Serper API
# await Searcher(search_engine=SearchEngine(engine=SearchEngineType.SERPER_GOOGLE, **kwargs)).run(question)
# SerpAPI
# await Searcher(search_engine=SearchEngine(engine=SearchEngineType.SERPAPI_GOOGLE, **kwargs)).run(question)
# Google API
# await Searcher(search_engine=SearchEngine(engine=SearchEngineType.DIRECT_GOOGLE, **kwargs)).run(question)
# DDG API
await Searcher(search_engine=SearchEngine(engine=SearchEngineType.DUCK_DUCK_GO, **kwargs)).run(question)

search = Config.default().search
kwargs = {"api_key": search.api_key, "cse_id": search.cse_id, "proxy": None}
await Searcher(search_engine=SearchEngine(engine=search.api_type, **kwargs)).run(question)


if __name__ == "__main__":
Expand Down

0 comments on commit ea70fd5

Please sign in to comment.