mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
rm make tools in ci for now
This commit is contained in:
parent
93538cc848
commit
f1a4197a82
3 changed files with 6 additions and 44 deletions
|
|
@ -25,7 +25,7 @@ The current task is about feature engineering. when performing it, please adhere
|
|||
# Prompt for using tools of "model_train" type
|
||||
MODEL_TRAIN_PROMPT = """
|
||||
The current task is about training a model, please ensure high performance:
|
||||
- Keep in mind that your user prioritizes results and is highly focused on model performance. So, when needed, feel free to use models of any complexity to improve effectiveness, such as lightGBM, XGBoost, CatBoost, etc.
|
||||
- Keep in mind that your user prioritizes results and is highly focused on model performance. So, when needed, feel free to use models of any complexity to improve effectiveness, such as XGBoost, CatBoost, etc.
|
||||
- If non-numeric columns exist, perform label encode together with all steps.
|
||||
- Use the data from previous task result directly, do not mock or reload data yourself.
|
||||
- Set suitable hyperparameters for the model, make metrics as high as possible.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
from datetime import datetime
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from metagpt.actions.ask_review import ReviewConst
|
||||
|
|
@ -8,15 +6,12 @@ from metagpt.actions.write_analysis_code import WriteCodeByGenerate, WriteCodeWi
|
|||
from metagpt.actions.write_code_steps import WriteCodeSteps
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import Role
|
||||
from metagpt.roles.tool_maker import ToolMaker
|
||||
from metagpt.schema import Message, Task, TaskResult
|
||||
from metagpt.utils.save_code import save_code_file
|
||||
|
||||
|
||||
class CodeInterpreter(Role):
|
||||
auto_run: bool = True
|
||||
use_tools: bool = False
|
||||
make_udfs: bool = False # whether to save user-defined functions
|
||||
use_code_steps: bool = False
|
||||
execute_code: ExecutePyCode = Field(default_factory=ExecutePyCode, exclude=True)
|
||||
tools: list[str] = []
|
||||
|
|
@ -47,19 +42,6 @@ class CodeInterpreter(Role):
|
|||
def working_memory(self):
|
||||
return self.rc.working_memory
|
||||
|
||||
async def _plan_and_act(self):
|
||||
rsp = await super()._plan_and_act()
|
||||
|
||||
# save code using datetime.now or keywords related to the goal of your project (plan.goal).
|
||||
project_record = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
save_code_file(name=project_record, code_context=self.execute_code.nb, file_format="ipynb")
|
||||
|
||||
# make tools out of workable codes for future use
|
||||
if self.make_udfs:
|
||||
await self.make_tools()
|
||||
|
||||
return rsp
|
||||
|
||||
async def _act_on_task(self, current_task: Task) -> TaskResult:
|
||||
code, result, is_success = await self._write_and_exec_code()
|
||||
task_result = TaskResult(code=code, result=result, is_success=is_success)
|
||||
|
|
@ -108,12 +90,3 @@ class CodeInterpreter(Role):
|
|||
code = await todo.run(context=context, plan=self.planner.plan, temperature=0.0)
|
||||
|
||||
return code, todo
|
||||
|
||||
async def make_tools(self):
|
||||
"""Make user-defined functions(udfs, aka tools) for pure generation code."""
|
||||
logger.info("Plan completed. Now start to make tools ...")
|
||||
tool_maker = ToolMaker()
|
||||
for task in self.planner.plan.get_finished_tasks():
|
||||
await tool_maker.make_tool(
|
||||
code=task.code, instruction=task.instruction, task_id=task.task_id, auto_run=self.auto_run
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ from metagpt.schema import Plan
|
|||
from metagpt.utils.recovery_util import load_history, save_history
|
||||
|
||||
|
||||
async def run_code_interpreter(
|
||||
role_class, requirement, auto_run, use_tools, use_code_steps, make_udfs, use_udfs, save_dir, tools
|
||||
):
|
||||
async def run_code_interpreter(role_class, requirement, auto_run, use_tools, use_code_steps, save_dir, tools):
|
||||
"""
|
||||
The main function to run the MLEngineer with optional history loading.
|
||||
|
||||
|
|
@ -25,16 +23,13 @@ async def run_code_interpreter(
|
|||
"""
|
||||
|
||||
if role_class == "ci":
|
||||
role = CodeInterpreter(
|
||||
goal=requirement, auto_run=auto_run, use_tools=use_tools, make_udfs=make_udfs, tools=tools
|
||||
)
|
||||
role = CodeInterpreter(goal=requirement, auto_run=auto_run, use_tools=use_tools, tools=tools)
|
||||
else:
|
||||
role = MLEngineer(
|
||||
goal=requirement,
|
||||
auto_run=auto_run,
|
||||
use_tools=use_tools,
|
||||
use_code_steps=use_code_steps,
|
||||
make_udfs=make_udfs,
|
||||
tools=tools,
|
||||
)
|
||||
|
||||
|
|
@ -50,10 +45,10 @@ async def run_code_interpreter(
|
|||
try:
|
||||
await role.run(requirement)
|
||||
except Exception as e:
|
||||
save_path = save_history(role, save_dir)
|
||||
|
||||
logger.exception(f"An error occurred: {e}, save trajectory here: {save_path}")
|
||||
|
||||
save_history(role, save_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# requirement = "Run data analysis on sklearn Iris dataset, include a plot"
|
||||
|
|
@ -73,8 +68,6 @@ if __name__ == "__main__":
|
|||
role_class = "mle"
|
||||
auto_run = True
|
||||
use_tools = True
|
||||
make_udfs = False
|
||||
use_udfs = False
|
||||
tools = []
|
||||
# tools = ["FillMissingValue", "CatCross", "non_existing_test"]
|
||||
|
||||
|
|
@ -84,13 +77,9 @@ if __name__ == "__main__":
|
|||
auto_run: bool = auto_run,
|
||||
use_tools: bool = use_tools,
|
||||
use_code_steps: bool = False,
|
||||
make_udfs: bool = make_udfs,
|
||||
use_udfs: bool = use_udfs,
|
||||
save_dir: str = save_dir,
|
||||
tools=tools,
|
||||
):
|
||||
await run_code_interpreter(
|
||||
role_class, requirement, auto_run, use_tools, use_code_steps, make_udfs, use_udfs, save_dir, tools
|
||||
)
|
||||
await run_code_interpreter(role_class, requirement, auto_run, use_tools, use_code_steps, save_dir, tools)
|
||||
|
||||
fire.Fire(main)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue