From b5aa86cc450490aad036fdc20a75b045fce8db14 Mon Sep 17 00:00:00 2001 From: unknown <10066332@qq.com> Date: Fri, 15 Sep 2023 00:05:43 +0800 Subject: [PATCH] Adding an action --- metagpt/actions/detail_mining.py | 3 ++- tests/metagpt/actions/test_detail_mining.py | 23 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/metagpt/actions/test_detail_mining.py diff --git a/metagpt/actions/detail_mining.py b/metagpt/actions/detail_mining.py index 5751b86d2..e29d6911b 100644 --- a/metagpt/actions/detail_mining.py +++ b/metagpt/actions/detail_mining.py @@ -22,6 +22,7 @@ PROMPT_TEMPLATE = """ 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. +Special Note 3: The output should be in the same language as the input. """ FORMAT_EXAMPLE = """ @@ -46,6 +47,6 @@ class DetailMining(Action): 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=topic, record=record, format_example=FORMAT_EXAMPLE) rsp = await self._aask_v1(prompt, "detail_mining", OUTPUT_MAPPING) return rsp diff --git a/tests/metagpt/actions/test_detail_mining.py b/tests/metagpt/actions/test_detail_mining.py new file mode 100644 index 000000000..c9d5331f9 --- /dev/null +++ b/tests/metagpt/actions/test_detail_mining.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +@Time : 2023/9/13 00:26 +@Author : fisherdeng +@File : test_detail_mining.py +""" +import pytest + +from metagpt.actions.detail_mining import DetailMining +from metagpt.logs import logger + +@pytest.mark.asyncio +async def test_detail_mining(): + topic = "如何做一个生日蛋糕" + record = "我认为应该先准备好材料,然后再开始做蛋糕。" + detail_mining = DetailMining("detail_mining") + rsp = await detail_mining.run(topic=topic, record=record) + logger.info(f"{rsp.content=}") + + assert '##OUTPUT' in rsp.content + assert '蛋糕' in rsp.content +