🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
support tool recommender spec during init
yzlin8d4567ea199b
diff --git a/metagpt/roles/di/data_interpreter.py b/metagpt/roles/di/data_interpreter.pyindex a8534b710..1943b4234 100644--- a/metagpt/roles/di/data_interpreter.py+++ b/metagpt/roles/di/data_interpreter.py@@ -1,7 +1,7 @@from __future__ import annotationsimport json-from typing import Literal, Union+from typing import Literalfrom pydantic import Field, model_validator@@ -39,7 +39,7 @@ class DataInterpreter(Role):use_plan: bool = Trueuse_reflection: bool = Falseexecute_code: ExecuteNbCode = Field(default_factory=ExecuteNbCode, exclude=True)- tools: Union[str, list[str]] = [] # Use special symbol ["<all>"] to indicate use of all registered tools+ tools: list[str] = [] # Use special symbol ["<all>"] to indicate use of all registered toolstool_recommender: ToolRecommender = Nonereact_mode: Literal["plan_and_act", "react"] = "plan_and_act"max_react_loop: int = 10 # used for react mode@@ -50,7 +50,7 @@ class DataInterpreter(Role):self.use_plan = (self.react_mode == "plan_and_act") # create a flag for convenience, overwrite any passed-in value- if self.tools:+ if self.tools and not self.tool_recommender:self.tool_recommender = BM25ToolRecommender(tools=self.tools)self.set_actions([WriteAnalysisCode])self._set_state(0)@@ -104,7 +104,7 @@ class DataInterpreter(Role):plan_status = self.planner.get_plan_status() if self.use_plan else ""# tool info- if self.tools:+ if self.tool_recommender:context = (self.working_memory.get()[-1].content if self.working_memory.get() else "") # thoughts from _think stage in 'react' mode