update tools according to intention

update TaskTypeDef for software development
This commit is contained in:
stellahsr 2024-04-09 17:37:49 +08:00
parent 2b56c36787
commit eef0375c6c
4 changed files with 22 additions and 15 deletions

View file

@ -98,10 +98,12 @@ To meet user requirements, the following standard operating procedure(SOP) must
{sop}
### SOP Type
{sop_type}
"""
### SOP Type
# {sop_type}
class DetectIntent(Action):
async def run(self, with_message: Message, **kwargs) -> Tuple[str, str]:

View file

@ -29,15 +29,15 @@ If you are modifying an existing plan, carefully follow the instruction, don't m
If you encounter errors on the current task, revise and output the current single task only.
Output a list of jsons following the format:
```json
[
{{
"task_id": str = "unique identifier for a task in plan, can be an ordinal",
"dependent_task_ids": list[str] = "ids of tasks prerequisite to this task",
"instruction": "what you should do in this task, one short phrase or sentence. If the SOP description is provided in the `Knowledge` section, the reference to the SOP description should be included intact in the instruction.",
"task_type": "type of this task, should be one of Available Task Types. You can refer to the hints in the `SOP Type` section to make a selection if `SOP Type` section is provided.",
}},
...
]
[
{{
"task_id": str = "unique identifier for a task in plan, can be an ordinal",
"dependent_task_ids": list[str] = "ids of tasks prerequisite to this task",
"instruction": "what you should do in this task, one short phrase or sentence",
"task_type": "type of this task, should be one of Available Task Types",
}},
...
]
```
"""

View file

@ -4,10 +4,11 @@
import asyncio
from typing import Dict
from metagpt.actions.di.detect_intent import DetectIntent
from metagpt.actions.di.detect_intent import DetectIntent, SOPItem
from metagpt.logs import logger
from metagpt.roles.di.data_interpreter import DataInterpreter
from metagpt.schema import Message
from metagpt.tools.tool_recommend import BM25ToolRecommender
class MGX(DataInterpreter):
@ -18,6 +19,10 @@ class MGX(DataInterpreter):
todo = DetectIntent(context=self.context)
request_with_sop, sop_type = await todo.run(user_msg)
logger.info(f"{sop_type} {request_with_sop}")
if sop_type == SOPItem.SOFTWARE_DEVELOPMENT.type_name:
self.tool_recommender = BM25ToolRecommender(tools=["software development"])
else:
self.tool_recommender = BM25ToolRecommender(tools=["<all>"])
return request_with_sop
async def _plan_and_act(self) -> Message: