Skip to content

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

chore: prompt support Message type.

刘棒棒8ef05bb19f2e
diff --git a/metagpt/actions/plan.py b/metagpt/actions/plan.py
index d46783ba2..ab3963c72 100644
--- a/metagpt/actions/plan.py
+++ b/metagpt/actions/plan.py
@@ -4,6 +4,8 @@
@Author : orange-crow
@File : plan.py
"""
+from typing import Union
+
from metagpt.actions import Action
from metagpt.prompts.plan import TASK_PLAN_SYSTEM_MSG
from metagpt.schema import Message
@@ -13,8 +15,8 @@ class Plan(Action):
def __init__(self, llm=None):
super().__init__("", None, llm)
- async def run(self, prompt: str, role: str = None, system_msg: str = None) -> str:
+ async def run(self, prompt: Union[str, Message], role: str = None, system_msg: str = None) -> str:
if role:
system_msg = TASK_PLAN_SYSTEM_MSG.format(role=role)
- rsp = await self._aask(system_msg + prompt)
+ rsp = self._aask(system_msg + prompt.content) if isinstance(prompt, Message) else await self._aask(system_msg + prompt)
return Message(rsp, role="assistant", sent_from=self.__class__.__name__)