mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-17 15:35:21 +02:00
feat: Merge geekan:env_refactore
This commit is contained in:
commit
20ae74e99d
117 changed files with 657 additions and 671 deletions
|
|
@ -15,6 +15,7 @@ from metagpt.logs import logger
|
|||
from metagpt.roles import Role
|
||||
from metagpt.schema import Message
|
||||
from metagpt.software_company import SoftwareCompany
|
||||
|
||||
from metagpt.utils.common import any_to_str
|
||||
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ class Trump(Role):
|
|||
async def _observe(self) -> int:
|
||||
await super()._observe()
|
||||
# accept messages sent (from opponent) to self, disregard own messages from the last round
|
||||
|
||||
self._rc.news = [msg for msg in self._rc.news if msg.send_to == {self.name}]
|
||||
return len(self._rc.news)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,19 +19,15 @@ async def main():
|
|||
Path("../tests/data/invoices/invoice-1.pdf"),
|
||||
Path("../tests/data/invoices/invoice-2.png"),
|
||||
Path("../tests/data/invoices/invoice-3.jpg"),
|
||||
Path("../tests/data/invoices/invoice-4.zip")
|
||||
Path("../tests/data/invoices/invoice-4.zip"),
|
||||
]
|
||||
# The absolute path of the file
|
||||
absolute_file_paths = [Path.cwd() / path for path in relative_paths]
|
||||
|
||||
for path in absolute_file_paths:
|
||||
role = InvoiceOCRAssistant()
|
||||
await role.run(Message(
|
||||
content="Invoicing date",
|
||||
instruct_content={"file_path": path}
|
||||
))
|
||||
await role.run(Message(content="Invoicing date", instruct_content={"file_path": path}))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ from metagpt.logs import logger
|
|||
async def main():
|
||||
llm = LLM()
|
||||
claude = Claude()
|
||||
logger.info(await claude.aask('你好,请进行自我介绍'))
|
||||
logger.info(await llm.aask('hello world'))
|
||||
logger.info(await llm.aask_batch(['hi', 'write python hello world.']))
|
||||
logger.info(await claude.aask("你好,请进行自我介绍"))
|
||||
logger.info(await llm.aask("hello world"))
|
||||
logger.info(await llm.aask_batch(["hi", "write python hello world."]))
|
||||
|
||||
hello_msg = [{'role': 'user', 'content': 'count from 1 to 10. split by newline.'}]
|
||||
hello_msg = [{"role": "user", "content": "count from 1 to 10. split by newline."}]
|
||||
logger.info(await llm.acompletion(hello_msg))
|
||||
logger.info(await llm.acompletion_batch([hello_msg]))
|
||||
logger.info(await llm.acompletion_batch_text([hello_msg]))
|
||||
|
|
@ -27,5 +27,5 @@ async def main():
|
|||
await llm.acompletion_text(hello_msg, stream=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ async def main():
|
|||
print(f"save report to {RESEARCH_PATH / f'{topic}.md'}.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -15,5 +15,5 @@ async def main():
|
|||
await Searcher().run("What are some good sun protection products?")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from metagpt.roles import Sales
|
|||
|
||||
|
||||
async def search():
|
||||
store = FaissStore(DATA_PATH / 'example.json')
|
||||
store = FaissStore(DATA_PATH / "example.json")
|
||||
role = Sales(profile="Sales", store=store)
|
||||
|
||||
queries = ["Which facial cleanser is good for oily skin?", "Is L'Oreal good to use?"]
|
||||
|
|
@ -22,5 +22,5 @@ async def search():
|
|||
logger.info(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(search())
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ from metagpt.tools import SearchEngineType
|
|||
|
||||
async def main():
|
||||
# Serper API
|
||||
#await Searcher(engine = SearchEngineType.SERPER_GOOGLE).run(["What are some good sun protection products?","What are some of the best beaches?"])
|
||||
# await Searcher(engine = SearchEngineType.SERPER_GOOGLE).run(["What are some good sun protection products?","What are some of the best beaches?"])
|
||||
# SerpAPI
|
||||
#await Searcher(engine=SearchEngineType.SERPAPI_GOOGLE).run("What are the best ski brands for skiers?")
|
||||
# await Searcher(engine=SearchEngineType.SERPAPI_GOOGLE).run("What are the best ski brands for skiers?")
|
||||
# Google API
|
||||
await Searcher(engine=SearchEngineType.DIRECT_GOOGLE).run("What are the most interesting human facts?")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
'''
|
||||
"""
|
||||
Filename: MetaGPT/examples/use_off_the_shelf_agent.py
|
||||
Created Date: Tuesday, September 19th 2023, 6:52:25 pm
|
||||
Author: garylin2099
|
||||
'''
|
||||
"""
|
||||
import asyncio
|
||||
|
||||
from metagpt.roles.product_manager import ProductManager
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles.product_manager import ProductManager
|
||||
|
||||
|
||||
async def main():
|
||||
msg = "Write a PRD for a snake game"
|
||||
|
|
@ -14,5 +15,6 @@ async def main():
|
|||
result = await role.run(msg)
|
||||
logger.info(result.content[:100])
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -16,6 +16,5 @@ async def main():
|
|||
await role.run(topic)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue