🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
update examples
yzlina680a1a82fd1
diff --git a/examples/di/crawl_webpage.py b/examples/di/crawl_webpage.pyindex f06b85d9b..b8226f4f4 100644--- a/examples/di/crawl_webpage.py+++ b/examples/di/crawl_webpage.py@@ -7,13 +7,31 @@from metagpt.roles.di.data_interpreter import DataInterpreter+PAPER_LIST_REQ = """"+Get data from `paperlist` table in https://papercopilot.com/statistics/iclr-statistics/iclr-2024-statistics/,+and save it to a csv file. paper title must include `multiagent` or `large language model`. *notice: print key variables*+"""++ECOMMERCE_REQ = """+Get products data from website https://scrapeme.live/shop/ and save it as a csv file.+**Notice: Firstly parse the web page encoding and the text HTML structure;+The first page product name, price, product URL, and image URL must be saved in the csv;**+"""++NEWS_36KR_REQ = """从36kr创投平台https://pitchhub.36kr.com/financing-flash 所有初创企业融资的信息, **注意: 这是一个中文网站**;+下面是一个大致流程, 你会根据每一步的运行结果对当前计划中的任务做出适当调整:+1. 爬取并本地保存html结构;+2. 直接打印第7个*`快讯`*关键词后2000个字符的html内容, 作为*快讯的html内容示例*;+3. 反思*快讯的html内容示例*中的规律, 设计正则匹配表达式来获取*`快讯`*的标题、链接、时间;+4. 筛选最近3天的初创企业融资*`快讯`*, 以list[dict]形式打印前5个。+5. 将全部结果存在本地csv中+"""+async def main():- prompt = """Get data from `paperlist` table in https://papercopilot.com/statistics/iclr-statistics/iclr-2024-statistics/,- and save it to a csv file. paper title must include `multiagent` or `large language model`. *notice: print key variables*"""- di = DataInterpreter(use_tools=True)+ di = DataInterpreter(tools=["scrape_web_playwright"])- await di.run(prompt)+ await di.run(ECOMMERCE_REQ)if __name__ == "__main__":diff --git a/examples/di/data_visualization.py b/examples/di/data_visualization.pyindex 9af72dc42..1a21ab7cb 100644--- a/examples/di/data_visualization.py+++ b/examples/di/data_visualization.py@@ -4,7 +4,7 @@ from metagpt.roles.di.data_interpreter import DataInterpreterasync def main(requirement: str = ""):- di = DataInterpreter(use_tools=False)+ di = DataInterpreter()await di.run(requirement)diff --git a/examples/di/email_summary.py b/examples/di/email_summary.pyindex af081fee2..7c112767c 100644--- a/examples/di/email_summary.py+++ b/examples/di/email_summary.py@@ -22,7 +22,7 @@ async def main():Firstly, Please help me fetch the latest 5 senders and full letter contents.Then, summarize each of the 5 emails into one sentence (you can do this by yourself, no need to import other models to do this) and output them in a markdown format."""- di = DataInterpreter(use_tools=True)+ di = DataInterpreter()await di.run(prompt)diff --git a/examples/di/imitate_webpage.py b/examples/di/imitate_webpage.pyindex e2c99b874..b00157d9d 100644--- a/examples/di/imitate_webpage.py+++ b/examples/di/imitate_webpage.py@@ -15,7 +15,7 @@ Firstly, utilize Selenium and WebDriver for rendering.Secondly, convert image to a webpage including HTML, CSS and JS in one go.Finally, save webpage in a text file.Note: All required dependencies and environments have been fully installed and configured."""- di = DataInterpreter(use_tools=True)+ di = DataInterpreter(tools=["GPTvGenerator"])await di.run(prompt)diff --git a/examples/di/ml_engineer_with_tools.py b/examples/di/machine_learning_with_tools.pysimilarity index 88%rename from examples/di/ml_engineer_with_tools.pyrename to examples/di/machine_learning_with_tools.pyindex 6119ad843..42c0ef55b 100644--- a/examples/di/ml_engineer_with_tools.py+++ b/examples/di/machine_learning_with_tools.py@@ -1,10 +1,10 @@import asyncio-from metagpt.roles.di.ml_engineer import MLEngineer+from metagpt.roles.di.data_interpreter import DataInterpreterasync def main(requirement: str):- role = MLEngineer(auto_run=True, use_tools=True)+ role = DataInterpreter(tools=["<all>"])await role.run(requirement)diff --git a/examples/di/rm_image_background.py b/examples/di/rm_image_background.pyindex b74a79eeb..cb7900a0a 100644--- a/examples/di/rm_image_background.py+++ b/examples/di/rm_image_background.py@@ -4,7 +4,7 @@ from metagpt.roles.di.data_interpreter import DataInterpreterasync def main(requirement: str = ""):- di = DataInterpreter(use_tools=False)+ di = DataInterpreter()await di.run(requirement)diff --git a/examples/di/sd_tool_usage.py b/examples/di/sd_tool_usage.pyindex 69c7df5bd..b373a6251 100644--- a/examples/di/sd_tool_usage.py+++ b/examples/di/sd_tool_usage.py@@ -8,7 +8,7 @@ from metagpt.roles.di.data_interpreter import DataInterpreterasync def main(requirement: str = ""):- di = DataInterpreter(use_tools=True, goal=requirement)+ di = DataInterpreter(tools=["SDEngine"])await di.run(requirement)diff --git a/examples/di/solve_math_problems.py b/examples/di/solve_math_problems.pyindex 35a69c953..ae2c1b942 100644--- a/examples/di/solve_math_problems.py+++ b/examples/di/solve_math_problems.py@@ -4,7 +4,7 @@ from metagpt.roles.di.data_interpreter import DataInterpreterasync def main(requirement: str = ""):- di = DataInterpreter(use_tools=False)+ di = DataInterpreter()await di.run(requirement)diff --git a/metagpt/roles/di/data_interpreter.py b/metagpt/roles/di/data_interpreter.pyindex 0a149e901..7eb5b9e8a 100644--- a/metagpt/roles/di/data_interpreter.py+++ b/metagpt/roles/di/data_interpreter.py@@ -9,7 +9,7 @@ from metagpt.actions.di.ask_review import ReviewConstfrom metagpt.actions.di.execute_nb_code import ExecuteNbCodefrom metagpt.actions.di.write_analysis_code import CheckData, WriteCodeWithToolsfrom metagpt.logs import logger-from metagpt.prompts.mi.write_analysis_code import DATA_INFO+from metagpt.prompts.di.write_analysis_code import DATA_INFOfrom metagpt.roles import Rolefrom metagpt.schema import Message, Task, TaskResultfrom metagpt.strategy.task_type import TaskTypediff --git a/metagpt/tools/libs/sd_engine.py b/metagpt/tools/libs/sd_engine.pyindex 0e3042f5c..b62e39db8 100644--- a/metagpt/tools/libs/sd_engine.py+++ b/metagpt/tools/libs/sd_engine.py@@ -14,7 +14,6 @@ import requestsfrom aiohttp import ClientSessionfrom PIL import Image, PngImagePlugin-#from metagpt.const import SD_OUTPUT_FILE_REPO, SOURCE_ROOTfrom metagpt.logs import loggerfrom metagpt.tools.tool_registry import register_tooldiff --git a/metagpt/tools/tool_recommend.py b/metagpt/tools/tool_recommend.pyindex fcdbc4254..9e9bf4a01 100644--- a/metagpt/tools/tool_recommend.py+++ b/metagpt/tools/tool_recommend.py@@ -57,8 +57,7 @@ class RecommendTool(Action):class ToolRecommender(BaseModel):"""The default ToolRecommender:- 1. Recall: If plan exists, use exact match between task type and tool type to recall tools;- If plan doesn't exist (e.g. we use ReAct), return all user-specified tools;+ 1. Recall: To be implemented in subclasses. Recall tools based on the given context and plan.2. Rank: Use LLM to select final candidates from recalled set."""