mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-14 15:25:17 +02:00
fix role add actions
This commit is contained in:
parent
83dbf97819
commit
7d523b3922
4 changed files with 23 additions and 16 deletions
|
|
@ -7,6 +7,7 @@ Author: garylin2099
|
|||
"""
|
||||
import asyncio
|
||||
import platform
|
||||
from typing import Any
|
||||
|
||||
import fire
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ from metagpt.team import Team
|
|||
class SpeakAloud(Action):
|
||||
"""Action: Speak out aloud in a debate (quarrel)"""
|
||||
|
||||
PROMPT_TEMPLATE = """
|
||||
PROMPT_TEMPLATE: str = """
|
||||
## BACKGROUND
|
||||
Suppose you are {name}, you are in a debate with {opponent_name}.
|
||||
## DEBATE HISTORY
|
||||
|
|
@ -30,9 +31,7 @@ class SpeakAloud(Action):
|
|||
Now it's your turn, you should closely respond to your opponent's latest argument, state your position, defend your arguments, and attack your opponent's arguments,
|
||||
craft a strong and emotional response in 80 words, in {name}'s rhetoric and viewpoints, your will argue:
|
||||
"""
|
||||
|
||||
def __init__(self, name="SpeakAloud", context=None, llm=None):
|
||||
super().__init__(name, context, llm)
|
||||
name: str = "SpeakAloud"
|
||||
|
||||
async def run(self, context: str, name: str, opponent_name: str):
|
||||
prompt = self.PROMPT_TEMPLATE.format(context=context, name=name, opponent_name=opponent_name)
|
||||
|
|
@ -44,17 +43,14 @@ class SpeakAloud(Action):
|
|||
|
||||
|
||||
class Debator(Role):
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
profile: str,
|
||||
opponent_name: str,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(name, profile, **kwargs)
|
||||
name: str = ""
|
||||
profile: str = ""
|
||||
opponent_name: str = ""
|
||||
|
||||
def __init__(self, **data: Any):
|
||||
super().__init__(**data)
|
||||
self._init_actions([SpeakAloud])
|
||||
self._watch([UserRequirement, SpeakAloud])
|
||||
self.opponent_name = opponent_name
|
||||
|
||||
async def _observe(self) -> int:
|
||||
await super()._observe()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue