Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

Merge branch 'dev' into dev_make_tools

刘棒棒ea7e11665d38
diff --cc metagpt/actions/write_analysis_code.py
index c41e0fc5a,6970fb4f0..839184cdc
--- a/metagpt/actions/write_analysis_code.py
+++ b/metagpt/actions/write_analysis_code.py
@@@ -5,13 -5,10 +5,15 @@@
@File : write_code_v2.py
"""
from typing import Dict, List, Union, Tuple
+from tenacity import retry, stop_after_attempt, wait_fixed
+from pathlib import Path
+import re
+import json
+ import yaml
+
from metagpt.actions import Action
+from metagpt.llm import LLM
from metagpt.logs import logger
from metagpt.prompts.ml_engineer import (
TOOL_RECOMMENDATION_PROMPT,
diff --cc metagpt/roles/ml_engineer.py
index b039c61e7,3755e7bac..28ff9fb3d
--- a/metagpt/roles/ml_engineer.py
+++ b/metagpt/roles/ml_engineer.py
@@@ -119,21 -157,31 +157,35 @@@ class MLEngineer(Role)
# print(context)
# print("*" * 10)
# breakpoint()
-
- if not self.use_tools or self.plan.current_task.task_type == "other":
- # code = "print('abc')"
+ if counter > 0 and self.use_tools:
+ code = await DebugCode().run(
+ plan=self.plan.current_task.instruction,
+ code=code,
+ runtime_result=self.working_memory.get(),
+ context=debug_context
+ )
+ logger.info(f"new code \n{code}")
+ cause_by = DebugCode
+ elif not self.use_tools or self.plan.current_task.task_type == "other":
+ logger.info("Write code with pure generation")
code = await WriteCodeByGenerate().run(
- context=context, plan=self.plan, code_steps=code_steps, temperature=0.0
+ context=context, plan=self.plan, temperature=0.0
)
+ debug_context = [self.get_useful_memories(task_exclude_field={'result', 'code_steps'})[0]]
cause_by = WriteCodeByGenerate
+ # make and save tools.
+ make_tools = MakeTools()
+ tool_code = await make_tools.run(code)
+ make_tools.save(tool_code)
else:
- code = await WriteCodeWithTools().run(
- context=context, plan=self.plan, code_steps=code_steps, data_desc=""
+ logger.info("Write code with tools")
+ schema_path = PROJECT_ROOT / "metagpt/tools/functions/schemas"
+ tool_context, code = await WriteCodeWithTools(schema_path=schema_path).run(
+ context=context,
+ plan=self.plan,
+ column_info=self.data_desc.get("column_info", ""),
)
+ debug_context = tool_context
cause_by = WriteCodeWithTools
self.working_memory.add(