Skip to content

Commit

Permalink
feat(agent):Agent App
Browse files Browse the repository at this point in the history
1.Fix the display problem under dashboboard
2.Support Awel Agent to arrange fixed targets
  • Loading branch information
yhjun1026 committed Feb 19, 2024
1 parent ba57257 commit 2989dc2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
32 changes: 22 additions & 10 deletions dbgpt/serve/agent/team/layout/agent_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,30 @@ async def map(
self,
input_value: AgentGenerateContext,
) -> AgentGenerateContext:
now_rely_messages: List[Dict] = []

now_message = input_value.message
agent = await self.get_agent(input_value)
if agent.fixed_subgoal and len(agent.fixed_subgoal) > 0:
# Isolate the message delivery mechanism and pass it to the operator
input_value.message["current_gogal"] = (
f"[{agent.name if agent.name else agent.profile}]:"
+ agent.fixed_subgoal
)
now_message["content"] = agent.fixed_subgoal
else:
# Isolate the message delivery mechanism and pass it to the operator
input_value.message["current_gogal"] = (
f"[{agent.name if agent.name else agent.profile}]:"
+ input_value.message["content"]
)

# Isolate the message delivery mechanism and pass it to the operator
input_value.message["current_gogal"] = (
f"[{agent.name if agent.name else agent.profile}]:"
+ input_value.message["content"]
)
now_rely_messages: List[Dict] = []
###What was received was the User message
human_message = input_value.message.copy()
human_message["role"] = ModelMessageRoleType.HUMAN
now_rely_messages.append(human_message)

###Send a message (no reply required) and pass the message content
now_message = input_value.message

if input_value.rely_messages and len(input_value.rely_messages) > 0:
now_message = input_value.rely_messages[-1]
await input_value.sender.a_send(now_message, agent, input_value.reviewer, False)
Expand Down Expand Up @@ -200,9 +208,13 @@ async def get_agent(
llm_config = LLMConfig(llm_client=input_value.llm_client)
else:
llm_config = LLMConfig(llm_client=self.llm_client)

kwargs = {}
if self.awel_agent.role_name:
kwargs["name"] = self.awel_agent.role_name
if self.awel_agent.fixed_subgoal:
kwargs["fixed_subgoal"] = self.awel_agent.fixed_subgoal
agent = (
await agent_cls(name=self.awel_agent.role_name)
await agent_cls(**kwargs)
.bind(input_value.memory)
.bind(llm_config)
.bind(input_value.agent_context)
Expand Down
9 changes: 9 additions & 0 deletions dbgpt/serve/agent/team/layout/agent_operator_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def pre_fill(cls, values: Dict[str, Any]) -> Dict[str, Any]:
default=None,
description="The agent role name.",
),
Parameter.build_from(
label="Fixed Gogal",
name="fixed_subgoal",
type=str,
optional=True,
default=None,
description="The agent fixed gogal.",
),
Parameter.build_from(
label="Agent Resource",
name="agent_resource",
Expand All @@ -162,6 +170,7 @@ class AwelAgent(BaseModel):
role_name: Optional[str] = None
llm_config: Optional[LLMConfig] = None
resources: List[AgentResource] = Field(default_factory=list)
fixed_subgoal: Optional[str] = None

class Config:
arbitrary_types_allowed = True
Expand Down
8 changes: 6 additions & 2 deletions dbgpt/serve/agent/team/plan/team_auto_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ async def a_act(
reviewer: Optional[ConversableAgent] = None,
) -> Optional[ActionOutput]:
speaker = sender
final_message = message
for i in range(self.max_round):
plans = self.memory.plans_memory.get_by_conv_id(self.agent_context.conv_id)

Expand Down Expand Up @@ -153,7 +154,7 @@ async def a_act(
# complete
return ActionOutput(
is_exe_success=True,
content=f"{plans[-1].result}", # work results message
content=final_message, # work results message
)
else:
try:
Expand Down Expand Up @@ -201,19 +202,21 @@ async def a_act(
)

plan_result = ""
final_message = reply_message["content"]
if is_success:
if reply_message:
action_report = reply_message.get("action_report", None)
if action_report:
plan_result = action_report.get("content", "")
final_message = action_report["view"]

### The current planned Agent generation verification is successful
##Plan executed successfully
self.memory.plans_memory.complete_task(
self.agent_context.conv_id,
now_plan.sub_task_num,
plan_result,
)

else:
plan_result = reply_message["content"]
self.memory.plans_memory.update_task(
Expand All @@ -228,6 +231,7 @@ async def a_act(
return ActionOutput(
is_exe_success=False, content=plan_result
)

except Exception as e:
logger.exception(
f"An exception was encountered during the execution of the current plan step.{str(e)}"
Expand Down

0 comments on commit 2989dc2

Please sign in to comment.