mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-11 15:15:18 +02:00
hard rule to ask human
This commit is contained in:
parent
cc949edc99
commit
78462d5199
2 changed files with 18 additions and 0 deletions
|
|
@ -80,6 +80,18 @@ Review and reflect on the history carefully, provide a different response.
|
|||
Describe if you should terminate using **end** command, or use **RoleZero.ask_human** to ask human for help, or try a different approach and output different commands. You are NOT allowed to provide the same commands again.
|
||||
Your reflection, then the commands in a json array:
|
||||
"""
|
||||
ASK_HUMAN_COMMAND = """
|
||||
```json
|
||||
[
|
||||
{
|
||||
"command_name": "RoleZero.ask_human",
|
||||
"args": {
|
||||
"question": "I'm a little uncertain about the next step, could you provide me with some guidance?"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
"""
|
||||
JSON_REPAIR_PROMPT = """
|
||||
## json data
|
||||
{json_data}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from metagpt.exp_pool.context_builders import RoleZeroContextBuilder
|
|||
from metagpt.exp_pool.serializers import RoleZeroSerializer
|
||||
from metagpt.logs import logger
|
||||
from metagpt.prompts.di.role_zero import (
|
||||
ASK_HUMAN_COMMAND,
|
||||
CMD_PROMPT,
|
||||
JSON_REPAIR_PROMPT,
|
||||
QUICK_THINK_PROMPT,
|
||||
|
|
@ -272,6 +273,11 @@ class RoleZero(Role):
|
|||
# If an identical response is detected, it is a bad response, mostly due to LLM repeating generated content
|
||||
# In this case, ask human for help and regenerate
|
||||
# TODO: switch to llm_cached_aask
|
||||
|
||||
# Hard rule to ask human for help
|
||||
if past_rsp.count(command_rsp) >= 3:
|
||||
return ASK_HUMAN_COMMAND
|
||||
# Try correction by self
|
||||
logger.warning(f"Duplicate response detected: {command_rsp}")
|
||||
regenerate_req = req + [UserMessage(content=REGENERATE_PROMPT)]
|
||||
regenerate_req = self.llm.format_msg(regenerate_req)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue