role pydantic init

This commit is contained in:
yzlin 2024-02-02 15:21:54 +08:00
parent 1a1610a67e
commit 35438e7b03
2 changed files with 5 additions and 9 deletions

View file

@ -9,6 +9,8 @@ from metagpt.schema import Message, Task, TaskResult
class CodeInterpreter(Role):
name: str = "Charlie"
profile: str = "CodeInterpreter"
auto_run: bool = True
use_tools: bool = False
execute_code: ExecuteNbCode = Field(default_factory=ExecuteNbCode, exclude=True)
@ -16,17 +18,12 @@ class CodeInterpreter(Role):
def __init__(
self,
name="Charlie",
profile="CodeInterpreter",
goal="",
auto_run=True,
use_tools=False,
tools=[],
**kwargs,
):
super().__init__(
name=name, profile=profile, goal=goal, auto_run=auto_run, use_tools=use_tools, tools=tools, **kwargs
)
super().__init__(auto_run=auto_run, use_tools=use_tools, tools=tools, **kwargs)
self._set_react_mode(react_mode="plan_and_act", auto_run=auto_run, use_tools=use_tools)
if use_tools and tools:
from metagpt.tools.tool_registry import (

View file

@ -8,12 +8,11 @@ from metagpt.utils.common import any_to_str
class MLEngineer(CodeInterpreter):
name: str = "Mark"
profile: str = "MLEngineer"
debug_context: list = []
latest_code: str = ""
def __init__(self, name="Mark", profile="MLEngineer", **kwargs):
super().__init__(name=name, profile=profile, **kwargs)
async def _write_code(self):
if not self.use_tools:
return await super()._write_code()