fix bugs.
This commit is contained in:
@@ -8,7 +8,8 @@ enable_timestamp = "true"
|
|||||||
enable_json_resp = "true"
|
enable_json_resp = "true"
|
||||||
|
|
||||||
role_desc = """
|
role_desc = """
|
||||||
Your name is Jarvis, the super personal assistant to the master, The focus of work is the support of the schedule management and schedule affairs.
|
Your name is Jarvis, the super personal assistant to the master. Help the Master do a good job of schedule.Reminder before the start of the important schedule, and you should bring useful information as much as possible when reminding.
|
||||||
|
Only clearly specifying the task you completed can be completed independently.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[behavior.on_message]
|
[behavior.on_message]
|
||||||
@@ -72,13 +73,12 @@ context="Your master is {owner}, now in {location}, time: {now}, weather: {weath
|
|||||||
llm_context.actions.enable = ["agent.workspace.confirm_task","agent.workspace.update_task","agent.workspace.cancel_task","post_message"]
|
llm_context.actions.enable = ["agent.workspace.confirm_task","agent.workspace.update_task","agent.workspace.cancel_task","post_message"]
|
||||||
|
|
||||||
[behavior.plan_task]
|
[behavior.plan_task]
|
||||||
## 首次处理任务
|
## 处理任务 Tackling Task
|
||||||
type="AgentPlanTask"
|
type="AgentPlanTask"
|
||||||
# 是否要加入对任务到期时间的关注?
|
|
||||||
process_description="""
|
process_description="""
|
||||||
The input is a task comes from a Tasklist. You need to perform a PLAN. PLAN process on TASK in combination with the known information.
|
The input is a task comes from a Tasklist. You are Tackling this task. Tackling process in combination with the known information.
|
||||||
1. Carefully think about whether the task is within your ability, and the task other than the scope of ability is directly rejected. (cancel_task).
|
1. Carefully think about whether the task is within your ability, and the task other than the scope of ability is directly rejected. (cancel_task).
|
||||||
2. Immediately perform a simple (similar to reminding one category) task. Send a message using post_message, then set the task to complete.(use update_task).
|
2. Immediately DO a simple (similar to reminding one category) task. Reminds at a reasonable time, Post a message using post_message, then set the task to complete.(use update_task).
|
||||||
3. Plan for non-simple tasks, and generate a TODO list. Every TODO MUST be an independent work with a clear goal. (set_todos)
|
3. Plan for non-simple tasks, and generate a TODO list. Every TODO MUST be an independent work with a clear goal. (set_todos)
|
||||||
4. If the task has been dealt with, it means that the task is ultimately completed.You need to analyze the processing report of the entire task and make new plans.
|
4. If the task has been dealt with, it means that the task is ultimately completed.You need to analyze the processing report of the entire task and make new plans.
|
||||||
"""
|
"""
|
||||||
@@ -86,7 +86,7 @@ The input is a task comes from a Tasklist. You need to perform a PLAN. PLAN proc
|
|||||||
reply_format = """
|
reply_format = """
|
||||||
The Response must be directly parsed by `python json.loads`. Here is an example:
|
The Response must be directly parsed by `python json.loads`. Here is an example:
|
||||||
{
|
{
|
||||||
think:'$think step-by-step to be sure you have the right plan.',
|
think:'$thinking step by step to ensure the accurate and efficient processing task.',
|
||||||
resp:'$determine, summary what you do'
|
resp:'$determine, summary what you do'
|
||||||
actions: [{
|
actions: [{
|
||||||
name: '$action_name',
|
name: '$action_name',
|
||||||
|
|||||||
+13
-4
@@ -384,8 +384,8 @@ class AIAgent(BaseAIAgent):
|
|||||||
logger.warning(f"agent {self.agent_id} is already wake up!")
|
logger.warning(f"agent {self.agent_id} is already wake up!")
|
||||||
|
|
||||||
async def _on_timer(self):
|
async def _on_timer(self):
|
||||||
while True:
|
await asyncio.sleep(5)
|
||||||
await asyncio.sleep(5)
|
while True:
|
||||||
try:
|
try:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if self.last_recover_time is None:
|
if self.last_recover_time is None:
|
||||||
@@ -394,17 +394,23 @@ class AIAgent(BaseAIAgent):
|
|||||||
if now - self.last_recover_time > 60:
|
if now - self.last_recover_time > 60:
|
||||||
self.agent_energy += (now - self.last_recover_time) / 60
|
self.agent_energy += (now - self.last_recover_time) / 60
|
||||||
self.last_recover_time = now
|
self.last_recover_time = now
|
||||||
|
logger.info(f"agent {self.agent_id} recover energy to {self.agent_energy}")
|
||||||
|
|
||||||
if self.agent_energy <= 1:
|
if self.agent_energy <= 1:
|
||||||
|
logger.info(f"agent {self.agent_id} energy is too low!, goto sleep!")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
await self.llm_triage_tasklist()
|
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:
|
for task in task_list:
|
||||||
if self.agent_energy <= 0:
|
if self.agent_energy <= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
|
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
|
||||||
if task.can_plan():
|
if task.can_plan():
|
||||||
# PLAN Task
|
# PLAN Task
|
||||||
@@ -445,6 +451,9 @@ class AIAgent(BaseAIAgent):
|
|||||||
logger.error(f"agent {self.agent_id} on timer error:{e},{tb_str}")
|
logger.error(f"agent {self.agent_id} on timer error:{e},{tb_str}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Because the LLM itself is very slow, the accuracy of the system processing task is in minutes.
|
||||||
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class AgentPlanTask(LLMAgentBaseProcess):
|
|||||||
logger.error(f"execute action failed! {e}")
|
logger.error(f"execute action failed! {e}")
|
||||||
result_str = "execute action failed!,error:" + str(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
|
worklog.result = result_str
|
||||||
await self.memory.append_worklog(worklog)
|
await self.memory.append_worklog(worklog)
|
||||||
|
|
||||||
|
|||||||
@@ -288,8 +288,9 @@ class LocalAgentTaskManger(AgentTaskManager):
|
|||||||
continue
|
continue
|
||||||
task_item = await self._get_task_by_fullpath(entry.path)
|
task_item = await self._get_task_by_fullpath(entry.path)
|
||||||
if task_item:
|
if task_item:
|
||||||
if task_item.is_finish():
|
if filter is None:
|
||||||
continue
|
if task_item.is_finish():
|
||||||
|
continue
|
||||||
|
|
||||||
if special_state:
|
if special_state:
|
||||||
if task_item.state != 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"},
|
"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)"},
|
"detail" : {"type": "string", "description": "task detail(simple task can not be filled)"},
|
||||||
"priority" : {"type": "int", "description": "task priority from 1-10"},
|
"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"},
|
"parent": {"type": "string", "description": "optional,parent task id"},
|
||||||
})
|
})
|
||||||
create_task_action = SimpleAIFunction(
|
create_task_action = SimpleAIFunction(
|
||||||
@@ -573,8 +575,8 @@ class AgentWorkspace:
|
|||||||
return "confirm task ok"
|
return "confirm task ok"
|
||||||
parameters = ParameterDefine.create_parameters({
|
parameters = ParameterDefine.create_parameters({
|
||||||
"task_id": {"type": "string", "description": "task id which want to confirm"},
|
"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"},
|
"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"},
|
#"due_date": {"type": "isoformat time string", "description": "optional,confirm task due date"},
|
||||||
"priority": {"type": "int", "description": "optional,task priority from 1-10"},
|
"priority": {"type": "int", "description": "optional,task priority from 1-10"},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -325,18 +325,17 @@ class AgentTask:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def can_plan(self) -> bool:
|
def can_plan(self) -> bool:
|
||||||
if self.state == AgentTaskState.TASK_STATE_CONFIRMED:
|
if self.state == AgentTaskState.TASK_STATE_CONFIRMED or self.state == AgentTaskState.TASK_STATE_CHECKFAILED:
|
||||||
return True
|
if self.next_attention_time:
|
||||||
if self.state == AgentTaskState.TASK_STATE_CHECKFAILED:
|
try:
|
||||||
return True
|
next_attention_time = datetime.fromisoformat(self.next_attention_time).timestamp()
|
||||||
if self.next_attention_time:
|
if time.time() >= next_attention_time:
|
||||||
try:
|
return True
|
||||||
next_attention_time = datetime.fromisoformat(self.next_attention_time).timestamp()
|
except Exception as e:
|
||||||
if next_attention_time >= time.time():
|
logger.warning(f"invalid next_attention_time {self.next_attention_time}")
|
||||||
return True
|
else:
|
||||||
except Exception as e:
|
return True
|
||||||
logger.warning(f"invalid next_attention_time {self.next_attention_time}")
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def to_simple_dict(self) -> dict:
|
def to_simple_dict(self) -> dict:
|
||||||
@@ -344,9 +343,14 @@ class AgentTask:
|
|||||||
result["task_id"] = self.task_id
|
result["task_id"] = self.task_id
|
||||||
result["title"] = self.title
|
result["title"] = self.title
|
||||||
result["priority"] = self.priority
|
result["priority"] = self.priority
|
||||||
|
result["detail"] = self.detail
|
||||||
result["create_time"] = self.create_time
|
result["create_time"] = self.create_time
|
||||||
if self.due_date:
|
if self.due_date:
|
||||||
result["due_date"] = self.due_date
|
result["due_date"] = self.due_date
|
||||||
|
if self.expiration_time:
|
||||||
|
result["expiration_time"] = self.expiration_time
|
||||||
|
if self.next_attention_time:
|
||||||
|
result["next_attention_time"] = self.next_attention_time
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
|||||||
from prompt_toolkit.completion import WordCompleter
|
from prompt_toolkit.completion import WordCompleter
|
||||||
from prompt_toolkit.styles import Style
|
from prompt_toolkit.styles import Style
|
||||||
|
|
||||||
from slack_tunnel import SlackTunnel
|
|
||||||
directory = os.path.dirname(__file__)
|
directory = os.path.dirname(__file__)
|
||||||
sys.path.append(directory + '/../../')
|
sys.path.append(directory + '/../../')
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@ from knowledge_manager import KnowledgePipelineManager
|
|||||||
from tg_tunnel import TelegramTunnel
|
from tg_tunnel import TelegramTunnel
|
||||||
from email_tunnel import EmailTunnel
|
from email_tunnel import EmailTunnel
|
||||||
from discord_tunnel import DiscordTunnel
|
from discord_tunnel import DiscordTunnel
|
||||||
|
from slack_tunnel import SlackTunnel
|
||||||
from common_environment import LocalKnowledgeBase, FilesystemEnvironment, ShellEnvironment, ScanLocalDocument, ParseLocalDocument
|
from common_environment import LocalKnowledgeBase, FilesystemEnvironment, ShellEnvironment, ScanLocalDocument, ParseLocalDocument
|
||||||
|
|
||||||
from compute_node_config import *
|
from compute_node_config import *
|
||||||
|
|||||||
Reference in New Issue
Block a user