🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
Merge branch 'dev' into feat_new_env
better6292d372a886397
diff --cc metagpt/actions/action_node.pyindex bd2f0d11f,a3efb214e..09da4a988--- a/metagpt/actions/action_node.py+++ b/metagpt/actions/action_node.py@@@ -466,9 -495,9 +509,9 @@@ class ActionNodefor _, i in self.children.items():if exclude and i.key in exclude:continue- child = await i.simple_fill(schema=schema, mode=mode, timeout=timeout, exclude=exclude)+ child = await i.simple_fill(schema=schema, mode=mode, images=images, timeout=timeout, exclude=exclude)tmp.update(child.instruct_content.model_dump())- cls = self.create_children_class()+ cls = self._create_children_class()self.instruct_content = cls(**tmp)return selfdiff --cc tests/metagpt/actions/test_action_node.pyindex 8aee071d4,1ec9f4f8d..18b4d0d0d--- a/tests/metagpt/actions/test_action_node.py+++ b/tests/metagpt/actions/test_action_node.py@@@ -243,17 -241,46 +243,57 @@@ def test_create_model_class_with_mappinassert value == ["game.py", "app.py", "static/css/styles.css", "static/js/script.js", "templates/index.html"]+async def test_action_node_with_image():+ invoice = ActionNode(+ key="invoice", expected_type=bool, instruction="if it's a invoice file, return True else False", example="False"+ )++ invoice_path = Path(__file__).parent.joinpath("..", "..", "data", "invoices", "invoice-2.png")+ img_base64 = encode_image(invoice_path)+ node = await invoice.fill(context="", llm=LLM(), images=[img_base64])+ assert node.instruct_content.invoice++ class ToolDef(BaseModel):+ tool_name: str = Field(default="a", description="tool name", examples=[])+ description: str = Field(default="b", description="tool description", examples=[])+++ class Task(BaseModel):+ task_id: int = Field(default=1, description="task id", examples=[1, 2, 3])+ name: str = Field(default="Get data from ...", description="task name", examples=[])+ dependent_task_ids: List[int] = Field(default=[], description="dependent task ids", examples=[1, 2, 3])+ tool: ToolDef = Field(default=ToolDef(), description="tool use", examples=[])+++ class Tasks(BaseModel):+ tasks: List[Task] = Field(default=[], description="tasks", examples=[])+++ def test_action_node_from_pydantic_and_print_everything():+ node = ActionNode.from_pydantic(Task)+ print("1. Tasks")+ print(Task().model_dump_json(indent=4))+ print(Tasks.model_json_schema())+ print("2. Task")+ print(Task.model_json_schema())+ print("3. ActionNode")+ print(node)+ print("4. node.compile prompt")+ prompt = node.compile(context="")+ assert "tool_name" in prompt, "tool_name should be in prompt"+ print(prompt)+ print("5. node.get_children_mapping")+ print(node._get_children_mapping())+ print("6. node.create_children_class")+ children_class = node._create_children_class()+ print(children_class)+ import inspect++ code = inspect.getsource(Tasks)+ print(code)+ assert "tasks" in code, "tasks should be in code"+if __name__ == "__main__":test_create_model_class()