From 8ef05bb19f2ebbea8df60dc93813957e19cedbac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=A3=92=E6=A3=92?= Date: Wed, 22 Nov 2023 17:56:43 +0800 Subject: [PATCH] chore: prompt support Message type. --- metagpt/actions/plan.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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__)