Напиши на основе данного фреймворка агента, который будет при диалоге с пользователем на каждом шагу оценивать, на какой стадии согласно лестнице [Redacted Person] находится клиент
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
I'll help you create an agent using MetaGPT that evaluates a client's position on [Redacted Person]'s ladder during conversation. Here's the implementation:
python
from typing import Optional
from metagpt.actions import Action
from metagpt.roles import Role
from metagpt.schema import Message
class EvaluateClientStage(Action):
"""Action to evaluate client's stage on [Redacted Person]'s ladder"""
def __init__(self, context=None):
super().__init__(context=context)
async def run(self, client_message: str) -> Message:
# Prompt to analyze client's message and determine their stage
prompt = """
Based on [Redacted Person]'s ladder stages (from bottom to top):
1. Denial - Rejects or ignores the situation
2. Anger - Feels frustrated and looks for someone to blame
3. Bargaining - Tries to negotiate or find easy solutions
4. Depression - Feels hopeless about the situation
5. Acceptance - Acknowledges reality and ready to take action
6. Growth - Actively working on solutions and personal development
Analyze the following client message and determine their current stage.
Provide reasoning for your assessment.
Client message: {message}
Return your analysis in the following format:
Stage: [stage number and name]
Reasoning: [your explanation]
Recommended approach: [how to best communicate with client at this stage]
"""
response = await self._aask(prompt.format(message=client_message))
return Message(content=response, role="assistant")
class ClientStageAnalyzer(Role):
"""Role that analyzes client's psychological stage during conversation"""
name: str = "Client Stage Analyzer"
profile: str = "Expert in analyzing psychological stages based on [Redacted Person]'s ladder"
goal: str = "Help understand client's current psychological stage and provide appropriate responses"
constraints: str = """
- Always be empathetic and supportive
- Avoid making assumptions without evidence
- Base analysis on actual client statements
- Maintain professional boundaries
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_actions([EvaluateClientStage])
async def _act(self) -> Message:
"""Process the latest message and evaluate client's stage"""
latest_message = self.rc.memory.get()[-1]
if not latest_message:
return None
todo = self.rc.todo
result = await todo.run(latest_message.content)
return result
# Usage example:
"""
import asyncio
async def main():
analyzer = ClientStageAnalyzer()
# Simulate conversation
await analyzer.run("This whole situation is ridiculous! I can't believe they're making these changes!")
await analyzer.run("Maybe if I work extra hours, I can avoid dealing with the changes...")
await analyzer.run("I understand now that change is necessary, what steps should I take?")
if __name__ == "__main__":
asyncio.run(main())
"""
This implementation creates:
EvaluateClientStage action that:
Takes a client message as input
Uses a structured prompt to analyze the message
Determines the client's stage on [Redacted Person]'s ladder
Provides reasoning and recommended approach
ClientStageAnalyzer role that:
Processes incoming messages
Uses the EvaluateClientStage action to analyze them
Returns detailed analysis of client's current stage
Key features:
Evaluates 6 stages of [Redacted Person]'s ladder
Provides reasoning for stage assessment
Gives recommendations for communication approach
Maintains conversation history
Uses empathetic and professional tone
To use this agent:
Create an instance of ClientStageAnalyzer
Send client messages through the run() method
Get back analysis including:
Current stage
Reasoning for assessment
Recommended communication approach
The agent will help track client progression through the stages and adjust communication strategies accordingly.
Remember to configure your MetaGPT environment with appropriate API keys and settings before running the agent.