mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-27 14:25:20 +02:00
chore: prompt support Message type.
This commit is contained in:
parent
fa400a0b0d
commit
8ef05bb19f
1 changed files with 4 additions and 2 deletions
|
|
@ -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__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue