fix bugs.

This commit is contained in:
Liu Zhicong
2024-01-25 21:48:17 -08:00
parent 9b7ca0b81a
commit c694ece59e
6 changed files with 44 additions and 28 deletions
+13 -4
View File
@@ -384,8 +384,8 @@ class AIAgent(BaseAIAgent):
logger.warning(f"agent {self.agent_id} is already wake up!")
async def _on_timer(self):
while True:
await asyncio.sleep(5)
await asyncio.sleep(5)
while True:
try:
now = time.time()
if self.last_recover_time is None:
@@ -394,17 +394,23 @@ class AIAgent(BaseAIAgent):
if now - self.last_recover_time > 60:
self.agent_energy += (now - self.last_recover_time) / 60
self.last_recover_time = now
logger.info(f"agent {self.agent_id} recover energy to {self.agent_energy}")
if self.agent_energy <= 1:
logger.info(f"agent {self.agent_id} energy is too low!, goto sleep!")
continue
await self.llm_triage_tasklist()
task_list:List[AgentTask] = await self.prviate_workspace.task_mgr.list_task()
# Get un finished tasks
#filter = {}
#filter["state"] = AgentTaskState.TASK_STATE_WAIT
filter = None
task_list:List[AgentTask] = await self.prviate_workspace.task_mgr.list_task(filter)
for task in task_list:
if self.agent_energy <= 0:
break
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
if task.can_plan():
# PLAN Task
@@ -445,6 +451,9 @@ class AIAgent(BaseAIAgent):
logger.error(f"agent {self.agent_id} on timer error:{e},{tb_str}")
continue
# Because the LLM itself is very slow, the accuracy of the system processing task is in minutes.
await asyncio.sleep(30)
+1 -1
View File
@@ -155,7 +155,7 @@ class AgentPlanTask(LLMAgentBaseProcess):
logger.error(f"execute action failed! {e}")
result_str = "execute action failed!,error:" + str(e)
worklog = AgentWorkLog.create_by_content(agent_task.task_id,"plan",llm_result.resp,self.memory.agent_id)
worklog = AgentWorkLog.create_by_content(agent_task.task_id,"tackling",llm_result.resp,self.memory.agent_id)
worklog.result = result_str
await self.memory.append_worklog(worklog)
+6 -4
View File
@@ -288,8 +288,9 @@ class LocalAgentTaskManger(AgentTaskManager):
continue
task_item = await self._get_task_by_fullpath(entry.path)
if task_item:
if task_item.is_finish():
continue
if filter is None:
if task_item.is_finish():
continue
if special_state:
if task_item.state != special_state:
@@ -516,7 +517,8 @@ class AgentWorkspace:
"title" : {"type": "string", "description": "task title,Simple and clear, try to include the task \ Related personnel \ place \ key conditions \ time element involved in the event"},
"detail" : {"type": "string", "description": "task detail(simple task can not be filled)"},
"priority" : {"type": "int", "description": "task priority from 1-10"},
"due_date" : {"type": "isoformat time string", "description": "task due date"},
#"due_date": {"type": "isoformat time string", "description": "optional,confirm task due date"},
#"expiration_time": {"type": "isoformat time string", "description": "optional,confirm task expiration time"},
"parent": {"type": "string", "description": "optional,parent task id"},
})
create_task_action = SimpleAIFunction(
@@ -573,8 +575,8 @@ class AgentWorkspace:
return "confirm task ok"
parameters = ParameterDefine.create_parameters({
"task_id": {"type": "string", "description": "task id which want to confirm"},
"expiration_time": {"type": "isoformat time string", "description": "optional,confirm task expiration time"},
"next_attention_time": {"type": "isoformat time string", "description": "optional,confirm task next attention time"},
"expiration_time": {"type": "isoformat time string", "description": "optional,confirm task expiration time"},
#"due_date": {"type": "isoformat time string", "description": "optional,confirm task due date"},
"priority": {"type": "int", "description": "optional,task priority from 1-10"},
})