mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-10-22 09:28:42 +00:00
Co-authored-by: 夏姜 <wenfengjiang.jwf@digital-engine.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: wb-lh513319 <wb-lh513319@alibaba-inc.com> Co-authored-by: csunny <cfqsunny@163.com>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
"""A proxy agent for the user."""
|
|
from typing import Optional
|
|
|
|
from .. import ActionOutput, Agent, AgentMessage
|
|
from .base_agent import ConversableAgent
|
|
from .profile import ProfileConfig
|
|
|
|
|
|
class UserProxyAgent(ConversableAgent):
|
|
"""A proxy agent for the user.
|
|
|
|
That can execute code and provide feedback to the other agents.
|
|
"""
|
|
|
|
profile: ProfileConfig = ProfileConfig(
|
|
name="User",
|
|
role="Human",
|
|
description=(
|
|
"A human admin. Interact with the planner to discuss the plan. "
|
|
"Plan execution needs to be approved by this admin."
|
|
),
|
|
)
|
|
|
|
is_human: bool = True
|
|
|
|
ask_user: bool = False
|
|
|
|
def have_ask_user(self):
|
|
"""If have ask user info in message."""
|
|
return self.ask_user
|
|
|
|
async def receive(
|
|
self,
|
|
message: AgentMessage,
|
|
sender: Agent,
|
|
reviewer: Optional[Agent] = None,
|
|
request_reply: Optional[bool] = None,
|
|
silent: Optional[bool] = False,
|
|
is_recovery: Optional[bool] = False,
|
|
is_retry_chat: bool = False,
|
|
last_speaker_name: Optional[str] = None,
|
|
) -> None:
|
|
"""Receive a message from another agent."""
|
|
if not silent:
|
|
await self._a_process_received_message(message, sender)
|
|
|
|
if message.action_report:
|
|
action_report: ActionOutput = message.action_report
|
|
if action_report.ask_user:
|
|
self.ask_user = True
|