adding an action

This commit is contained in:
unknown 2023-09-12 23:39:36 +08:00
parent 471f5d68ea
commit 307ff81790

View file

@ -5,31 +5,30 @@
@Author : fisherdeng
@File : detail_mining.py
"""
from metagpt.actions import Action, ActionOutput
from metagpt.logs import logger
PROMPT_TEMPLATE = """
##讨论目标
##TOPIC
{topic}
##讨论记录
##RECORD
{record}
##Format example
{format_example}
-----
任务: 参考 ##讨论目标 和 ##讨论记录 进一步询问你感兴趣的细节字数不多于150字
特别注意1你只是单纯地询问不要赞同或否定任何人的任何观点
特别注意2:本次输出,仅包含 ##OUTPUT 这一主题,不要增加、减少或改变主题。输出时,以'##OUTPUT'开头,然后马上换行,再正式输出内容,仔细参考"##Format example"中的格式。
Task: Refer to the "##TOPIC" (discussion objectives) and "##RECORD" (discussion records) to further inquire about the details that interest you, within a word limit of 150 words.
Special Note 1: Your intention is solely to ask questions without endorsing or negating any individual's viewpoints.
Special Note 2: This output should only include the topic "##OUTPUT". Do not add, remove, or modify the topic. Begin the output with '##OUTPUT', followed by an immediate line break, and then proceed to provide the content in the specified format as outlined in the "##Format example" section.
"""
FORMAT_EXAMPLE = """
##
##OUTPUT
...(请在这里输出你想询问的细节)
...(Please provide the specific details you would like to inquire about here.)
##
@ -41,11 +40,12 @@ OUTPUT_MAPPING = {
class DetailMining(Action):
"""This class allows LLM to further mine noteworthy details based on specific "##TOPIC"(discussion topic) and "##RECORD" (discussion records), thereby deepening the discussion.
"""
def __init__(self, name="", context=None, llm=None):
super().__init__(name, context, llm)
async def run(self, topic, record) -> ActionOutput:
prompt = PROMPT_TEMPLATE.format(topic,record,format_example=FORMAT_EXAMPLE)
prompt = PROMPT_TEMPLATE.format(topic, record, format_example=FORMAT_EXAMPLE)
rsp = await self._aask_v1(prompt, "detail_mining", OUTPUT_MAPPING)
return rsp