[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] 1. react loop not exit 2. Action.desc in role.states #1298

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[fix] 1. react loop not exit 2. Action.desc in role.states
  • Loading branch information
Wei-Jianan committed May 24, 2024
commit 02da7613ff82e9ffdb6b18f8658dfae6a1f4e344
6 changes: 3 additions & 3 deletions metagpt/roles/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
Now choose one of the following stages you need to go to in the next step:
{states}

Just answer a number between 0-{n_states}, choose the most suitable stage according to the understanding of the conversation.
Just answer a number between -1 and {n_states}, choose the most suitable stage according to the understanding of the conversation.
Please note that the answer only needs a number, no need to add any other text.
If you think you have completed your goal and don't need to go to any of the stages, return -1.
Do not answer anything else, and do not add any other information in your answer.
Expand Down Expand Up @@ -276,7 +276,7 @@ def set_actions(self, actions: list[Union[Action, Type[Action]]]):
i = action
self._init_action(i)
self.actions.append(i)
self.states.append(f"{len(self.actions) - 1}. {action}")
self.states.append(f"{len(self.actions) - 1}. {action} : {action.desc}")

def _set_react_mode(self, react_mode: str, max_react_loop: int = 1, auto_run: bool = True):
"""Set strategy of the Role reacting to observed Message. Variation lies in how
Expand Down Expand Up @@ -396,7 +396,7 @@ async def _think(self) -> bool:
if next_state == -1:
logger.info(f"End actions with {next_state=}")
self._set_state(next_state)
return True
return True if next_state >= 0 else False

async def _act(self) -> Message:
logger.info(f"{self._setting}: to do {self.rc.todo}({self.rc.todo.name})")
Expand Down
Loading