Gpts app v0.4 (#1169)

This commit is contained in:
明天
2024-02-19 17:38:05 +08:00
committed by GitHub
parent 37f7ad12cd
commit 63ab612e75
7 changed files with 60 additions and 27 deletions

View File

@@ -135,22 +135,30 @@ class AwelAgentOperator(
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)
@@ -200,9 +208,13 @@ class AwelAgentOperator(
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)

View File

@@ -139,6 +139,14 @@ class AwelAgentConfig(LLMConfig):
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",
@@ -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

View File

@@ -117,6 +117,7 @@ class AutoPlanChatManager(ManagerAgent):
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)
@@ -153,7 +154,7 @@ class AutoPlanChatManager(ManagerAgent):
# complete
return ActionOutput(
is_exe_success=True,
content=f"{plans[-1].result}", # work results message
content=final_message, # work results message
)
else:
try:
@@ -201,11 +202,14 @@ class AutoPlanChatManager(ManagerAgent):
)
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(
@@ -213,7 +217,6 @@ class AutoPlanChatManager(ManagerAgent):
now_plan.sub_task_num,
plan_result,
)
else:
plan_result = reply_message["content"]
self.memory.plans_memory.update_task(
@@ -228,6 +231,7 @@ class AutoPlanChatManager(ManagerAgent):
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)}"