mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
reformatting done
This commit is contained in:
parent
a5f278c297
commit
cbfbecb487
2 changed files with 7 additions and 34 deletions
|
|
@ -11,6 +11,7 @@ import platform
|
|||
from typing import Any
|
||||
|
||||
import fire
|
||||
|
||||
from metagpt.actions import Action, UserRequirement
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import Role
|
||||
|
|
@ -34,9 +35,7 @@ class SpeakAloud(Action):
|
|||
name: str = "SpeakAloud"
|
||||
|
||||
async def run(self, context: str, name: str, opponent_name: str):
|
||||
prompt = self.PROMPT_TEMPLATE.format(
|
||||
context=context, name=name, opponent_name=opponent_name
|
||||
)
|
||||
prompt = self.PROMPT_TEMPLATE.format(context=context, name=name, opponent_name=opponent_name)
|
||||
# logger.info(prompt)
|
||||
|
||||
rsp = await self._aask(prompt)
|
||||
|
|
@ -68,9 +67,7 @@ class Debator(Role):
|
|||
context = "\n".join(f"{msg.sent_from}: {msg.content}" for msg in memories)
|
||||
# print(context)
|
||||
|
||||
rsp = await todo.run(
|
||||
context=context, name=self.name, opponent_name=self.opponent_name
|
||||
)
|
||||
rsp = await todo.run(context=context, name=self.name, opponent_name=self.opponent_name)
|
||||
|
||||
msg = Message(
|
||||
content=rsp,
|
||||
|
|
@ -91,9 +88,7 @@ async def debate(idea: str, investment: float = 3.0, n_round: int = 5):
|
|||
team = Team()
|
||||
team.hire([Biden, Trump])
|
||||
team.invest(investment)
|
||||
team.run_project(
|
||||
idea, send_to="Biden"
|
||||
) # send debate topic to Biden and let him speak first
|
||||
team.run_project(idea, send_to="Biden") # send debate topic to Biden and let him speak first
|
||||
await team.run(n_round=n_round)
|
||||
|
||||
|
||||
|
|
@ -111,6 +106,4 @@ def main(idea: str, investment: float = 3.0, n_round: int = 10):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
fire.Fire(
|
||||
main
|
||||
) # run as python debate.py --idea="TOPIC" --investment=3.0 --n_round=5
|
||||
fire.Fire(main) # run as python debate.py --idea="TOPIC" --investment=3.0 --n_round=5
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ 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():
|
||||
|
|
@ -14,27 +14,7 @@ async def main():
|
|||
|
||||
search = Config.default().search
|
||||
kwargs = {"api_key": search.api_key, "cse_id": search.cse_id, "proxy": None}
|
||||
|
||||
if search.api_type == SearchEngineType.DIRECT_GOOGLE:
|
||||
# Google API
|
||||
await Searcher(
|
||||
search_engine=SearchEngine(engine=SearchEngineType.DIRECT_GOOGLE, **kwargs)
|
||||
).run(question)
|
||||
elif search.api_type == SearchEngineType.SERPER_GOOGLE:
|
||||
# Serper API
|
||||
await Searcher(
|
||||
search_engine=SearchEngine(engine=SearchEngineType.SERPER_GOOGLE, **kwargs)
|
||||
).run(question)
|
||||
elif search.api_type == SearchEngineType.SERPAPI_GOOGLE:
|
||||
# SerpAPI
|
||||
await Searcher(
|
||||
search_engine=SearchEngine(engine=SearchEngineType.SERPAPI_GOOGLE, **kwargs)
|
||||
).run(question)
|
||||
else:
|
||||
# DDG API
|
||||
await Searcher(
|
||||
search_engine=SearchEngine(engine=SearchEngineType.DUCK_DUCK_GO, **kwargs)
|
||||
).run(question)
|
||||
await Searcher(search_engine=SearchEngine(engine=search.api_type, **kwargs)).run(question)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue