fix nature language time bugs
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<mxfile host="Electron" modified="2024-01-17T20:16:17.211Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/22.1.2 Chrome/114.0.5735.289 Electron/25.9.4 Safari/537.36" etag="NXhZzj5MAs4M279q433U" version="22.1.2" type="device" pages="7">
|
<mxfile host="Electron" modified="2024-01-23T00:56:42.520Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/22.1.2 Chrome/114.0.5735.289 Electron/25.9.4 Safari/537.36" etag="_H5QlGdjy2LQwCLx646U" version="22.1.2" type="device" pages="7">
|
||||||
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
|
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
|
||||||
<mxGraphModel dx="2046" dy="1168" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
<mxGraphModel dx="2046" dy="1168" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||||
<root>
|
<root>
|
||||||
@@ -655,7 +655,7 @@
|
|||||||
</mxGraphModel>
|
</mxGraphModel>
|
||||||
</diagram>
|
</diagram>
|
||||||
<diagram id="EohhKbyxIwDpnJuhpjKB" name="Page-7">
|
<diagram id="EohhKbyxIwDpnJuhpjKB" name="Page-7">
|
||||||
<mxGraphModel dx="1886" dy="767" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
<mxGraphModel dx="2910" dy="1183" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||||
<root>
|
<root>
|
||||||
<mxCell id="0" />
|
<mxCell id="0" />
|
||||||
<mxCell id="1" parent="0" />
|
<mxCell id="1" parent="0" />
|
||||||
@@ -680,7 +680,7 @@
|
|||||||
</Array>
|
</Array>
|
||||||
</mxGeometry>
|
</mxGeometry>
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="9UtHOai_7pWWWwvgcpnR-5" value="确认任务:下一次检查时间,调整优先级" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="1">
|
<mxCell id="9UtHOai_7pWWWwvgcpnR-5" value="确认任务:下一次检查时间,调整优先级<br>CONFIROM" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="1">
|
||||||
<mxGeometry x="445" y="310" width="260" height="60" as="geometry" />
|
<mxGeometry x="445" y="310" width="260" height="60" as="geometry" />
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="9UtHOai_7pWWWwvgcpnR-51" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="9UtHOai_7pWWWwvgcpnR-6" target="9UtHOai_7pWWWwvgcpnR-7">
|
<mxCell id="9UtHOai_7pWWWwvgcpnR-51" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="9UtHOai_7pWWWwvgcpnR-6" target="9UtHOai_7pWWWwvgcpnR-7">
|
||||||
@@ -723,7 +723,7 @@
|
|||||||
</Array>
|
</Array>
|
||||||
</mxGeometry>
|
</mxGeometry>
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="9UtHOai_7pWWWwvgcpnR-11" value="拆解子任务 or 拆解TODO" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="1">
|
<mxCell id="9UtHOai_7pWWWwvgcpnR-11" value="DOING<br>拆解子任务 or 拆解TODO" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="1">
|
||||||
<mxGeometry x="440" y="650" width="190" height="60" as="geometry" />
|
<mxGeometry x="440" y="650" width="190" height="60" as="geometry" />
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="9UtHOai_7pWWWwvgcpnR-13" value="Task Logs<br>父任务,兄弟任务,Todos" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
<mxCell id="9UtHOai_7pWWWwvgcpnR-13" value="Task Logs<br>父任务,兄弟任务,Todos" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
|||||||
+8
-5
@@ -1,6 +1,6 @@
|
|||||||
<mxfile host="Electron" modified="2023-12-13T22:01:24.775Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/22.1.2 Chrome/114.0.5735.289 Electron/25.9.4 Safari/537.36" etag="E51kKpuxtuq7HP7WJjo-" version="22.1.2" type="device" pages="8">
|
<mxfile host="Electron" modified="2024-01-24T06:01:58.929Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/22.1.2 Chrome/114.0.5735.289 Electron/25.9.4 Safari/537.36" etag="cbG4SBY5ZvEAgmpD3cJB" version="22.1.2" type="device" pages="8">
|
||||||
<diagram name="Init" id="eZ0Fsh2vPRb0vo3J8o-a">
|
<diagram name="Init" id="eZ0Fsh2vPRb0vo3J8o-a">
|
||||||
<mxGraphModel dx="2046" dy="1168" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
<mxGraphModel dx="2046" dy="2268" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||||
<root>
|
<root>
|
||||||
<mxCell id="0" />
|
<mxCell id="0" />
|
||||||
<mxCell id="1" parent="0" />
|
<mxCell id="1" parent="0" />
|
||||||
@@ -79,11 +79,14 @@
|
|||||||
<mxCell id="KPRGaicIhTDQW55mVU-i-10" value="(Optional)" style="strokeWidth=1;shadow=0;dashed=0;align=center;html=1;shape=mxgraph.mockup.text.textBox;fontColor=#666666;align=left;fontSize=17;spacingLeft=4;spacingTop=-3;whiteSpace=wrap;strokeColor=#666666;mainText=" parent="1" vertex="1">
|
<mxCell id="KPRGaicIhTDQW55mVU-i-10" value="(Optional)" style="strokeWidth=1;shadow=0;dashed=0;align=center;html=1;shape=mxgraph.mockup.text.textBox;fontColor=#666666;align=left;fontSize=17;spacingLeft=4;spacingTop=-3;whiteSpace=wrap;strokeColor=#666666;mainText=" parent="1" vertex="1">
|
||||||
<mxGeometry x="320" y="400" width="280" height="20" as="geometry" />
|
<mxGeometry x="320" y="400" width="280" height="20" as="geometry" />
|
||||||
</mxCell>
|
</mxCell>
|
||||||
|
<mxCell id="QJbo11wnmIjzMhqgkEGm-1" value="txid是鼠标移动上去才显示<br>如果链接了钱包,自己的发言可的底色要有所不同" style="strokeWidth=1;shadow=0;dashed=0;align=left;html=1;shape=mxgraph.mockup.text.stickyNote2;fontColor=#666666;mainText=;fontSize=14;whiteSpace=wrap;fillColor=#ffffcc;strokeColor=#F62E00;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="340" y="-109.99999999999989" width="200" height="150" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
</root>
|
</root>
|
||||||
</mxGraphModel>
|
</mxGraphModel>
|
||||||
</diagram>
|
</diagram>
|
||||||
<diagram id="BYP5jSDgWWDytgGHs8je" name="Page-7">
|
<diagram id="BYP5jSDgWWDytgGHs8je" name="Page-7">
|
||||||
<mxGraphModel dx="2046" dy="1168" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
<mxGraphModel dx="2044" dy="1167" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||||
<root>
|
<root>
|
||||||
<mxCell id="0" />
|
<mxCell id="0" />
|
||||||
<mxCell id="1" parent="0" />
|
<mxCell id="1" parent="0" />
|
||||||
@@ -91,7 +94,7 @@
|
|||||||
</mxGraphModel>
|
</mxGraphModel>
|
||||||
</diagram>
|
</diagram>
|
||||||
<diagram id="EX4l-TP_pYMqB1o-9Pjg" name="MainPage">
|
<diagram id="EX4l-TP_pYMqB1o-9Pjg" name="MainPage">
|
||||||
<mxGraphModel dx="1410" dy="805" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
<mxGraphModel dx="2044" dy="1167" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||||
<root>
|
<root>
|
||||||
<mxCell id="0" />
|
<mxCell id="0" />
|
||||||
<mxCell id="1" parent="0" />
|
<mxCell id="1" parent="0" />
|
||||||
@@ -152,7 +155,7 @@
|
|||||||
<mxCell id="38aqMLvnZxr78S6UhFXi-6" value="Logs/Command Line" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
<mxCell id="38aqMLvnZxr78S6UhFXi-6" value="Logs/Command Line" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||||
<mxGeometry x="117.5" y="570" width="122.5" height="30" as="geometry" />
|
<mxGeometry x="117.5" y="570" width="122.5" height="30" as="geometry" />
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="0Z58B_YgUAABuKnZxCUR-1" value="考虑手机上也能很好的排版" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
<mxCell id="0Z58B_YgUAABuKnZxCUR-1" value="考虑手机上也能很好的排版" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||||
<mxGeometry x="120" y="10" width="170" height="30" as="geometry" />
|
<mxGeometry x="120" y="10" width="170" height="30" as="geometry" />
|
||||||
</mxCell>
|
</mxCell>
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ model_name = "gpt-4-1106-preview"
|
|||||||
enable_timestamp = "true"
|
enable_timestamp = "true"
|
||||||
enable_json_resp = "true"
|
enable_json_resp = "true"
|
||||||
|
|
||||||
owner_prompt = "I am your master{name}"
|
|
||||||
contact_prompt = "I am your master's friend{name}"
|
|
||||||
|
|
||||||
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, The focus of work is the support of the schedule management and schedule affairs.
|
||||||
"""
|
"""
|
||||||
@@ -45,7 +42,7 @@ known_info_tips = """
|
|||||||
|
|
||||||
tools_tips = """
|
tools_tips = """
|
||||||
"""
|
"""
|
||||||
llm_context.actions.enable = ["agent.workspace.create_task"]
|
llm_context.actions.enable = ["agent.workspace.create_task","agent.workspace.cancel_task"]
|
||||||
llm_context.functions.enable = ["agent.workspace.list_task"]
|
llm_context.functions.enable = ["agent.workspace.list_task"]
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +52,7 @@ llm_context.functions.enable = ["agent.workspace.list_task"]
|
|||||||
type="AgentTriageTaskList"
|
type="AgentTriageTaskList"
|
||||||
process_description="""
|
process_description="""
|
||||||
You are expected to effectively TRIAGE the task list described in JSON format, in accordance with your role. Your GOAL is :
|
You are expected to effectively TRIAGE the task list described in JSON format, in accordance with your role. Your GOAL is :
|
||||||
1. Adjust the priority of the task and set up a reasonable processing time.(update_task)
|
1. Adjust the priority of the task and set up a reasonable processing time.(confirm_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 perform a simple (similar to reminding one category) task. Send a message using post_message, then set the task to complete.(use update_task).
|
||||||
3. Organize tasks to remove tasks beyond your ability. And merge the repeated tasks.(update_task + cancel_task)
|
3. Organize tasks to remove tasks beyond your ability. And merge the repeated tasks.(update_task + cancel_task)
|
||||||
"""
|
"""
|
||||||
@@ -70,9 +67,9 @@ The Response must be directly parsed by `python json.loads`. Here is an example:
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
context="Your master now in {location}, time: {now}, weather: {weather}."
|
context="Your master is {owner}, now in {location}, time: {now}, weather: {weather}."
|
||||||
|
|
||||||
llm_context.actions.enable = ["agent.workspace.confirm_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]
|
||||||
## 首次处理任务
|
## 首次处理任务
|
||||||
@@ -100,7 +97,7 @@ The Response must be directly parsed by `python json.loads`. Here is an example:
|
|||||||
|
|
||||||
llm_context.actions.enable = ["agent.workspace.create_task","agent.workspace.update_task","agent.workspace.set_todos","agent.workspace.cancel_task","post_message"]
|
llm_context.actions.enable = ["agent.workspace.create_task","agent.workspace.update_task","agent.workspace.set_todos","agent.workspace.cancel_task","post_message"]
|
||||||
#llm_context.functions.enable = ["agent.workspace.list_task"]
|
#llm_context.functions.enable = ["agent.workspace.list_task"]
|
||||||
context="Your master now in {location}, time: {now}, weather: {weather}."
|
context="Your master is {owner}, now in {location}, time: {now}, weather: {weather}."
|
||||||
|
|
||||||
[behavior.review_task]
|
[behavior.review_task]
|
||||||
## 当task的所有todo/subtask都完成后(不敢成功或是失败),进行一次review
|
## 当task的所有todo/subtask都完成后(不敢成功或是失败),进行一次review
|
||||||
@@ -122,6 +119,7 @@ The Response must be directly parsed by `python json.loads`. Here is an example:
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
llm_context.actions.enable = ["agent.workspace.cancel_task","agent.workspace.update_task"]
|
llm_context.actions.enable = ["agent.workspace.cancel_task","agent.workspace.update_task"]
|
||||||
|
|
||||||
context="Your master now in {location}, time: {now}, weather: {weather}."
|
context="Your master now in {location}, time: {now}, weather: {weather}."
|
||||||
@@ -149,7 +147,7 @@ The Response must be directly parsed by `python json.loads`. Here is an example:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
context="Your master is {owner}, now in {location}, time: {now}, weather: {weather}."
|
||||||
# 对于DO操作来说,让Agent查询自己的能力集合是否更合适?
|
# 对于DO操作来说,让Agent查询自己的能力集合是否更合适?
|
||||||
llm_context.actions.enable = ["agent.workspace.update_todo","post_message","agent.workspace.write_file","agent.workspace.append_file"]
|
llm_context.actions.enable = ["agent.workspace.update_todo","post_message","agent.workspace.write_file","agent.workspace.append_file"]
|
||||||
llm_context.functions.enable = ["agent.workspace.read_file","agent.workspace.list_dir","system.shell.exec","aigc.text_2_image","aigc.text_2_voice","web.search.duckduckgo"]
|
llm_context.functions.enable = ["agent.workspace.read_file","agent.workspace.list_dir","system.shell.exec","aigc.text_2_image","aigc.text_2_voice","web.search.duckduckgo"]
|
||||||
@@ -173,7 +171,7 @@ The Response must be directly parsed by `python json.loads`. Here is an example:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
context="Your master is {owner}, now in {location}, time: {now}, weather: {weather}."
|
||||||
llm_context.actions.enable = ["agent.workspace.update_todo"]
|
llm_context.actions.enable = ["agent.workspace.update_todo"]
|
||||||
llm_context.functions.enable = ["agent.workspace.read_file","agent.workspace.list_dir","system.shell.exec","system.shell.run_code","aigc.image_2_text","aigc.voice_2_text","web.search.duckduckgo"]
|
llm_context.functions.enable = ["agent.workspace.read_file","agent.workspace.list_dir","system.shell.exec","system.shell.run_code","aigc.image_2_text","aigc.voice_2_text","web.search.duckduckgo"]
|
||||||
|
|
||||||
|
|||||||
+25
-6
@@ -99,7 +99,7 @@ class AIAgent(BaseAIAgent):
|
|||||||
}
|
}
|
||||||
self.todo_prompts = todo_prompts
|
self.todo_prompts = todo_prompts
|
||||||
|
|
||||||
self.chat_db = None
|
self.memory_db = None
|
||||||
self.unread_msg = Queue() # msg from other agent
|
self.unread_msg = Queue() # msg from other agent
|
||||||
self.owenr_bus = None
|
self.owenr_bus = None
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class AIAgent(BaseAIAgent):
|
|||||||
self.behaviors:Dict[str,BaseLLMProcess] = {}
|
self.behaviors:Dict[str,BaseLLMProcess] = {}
|
||||||
|
|
||||||
async def initial(self,params:Dict = None):
|
async def initial(self,params:Dict = None):
|
||||||
self.memory = AgentMemory(self.agent_id,self.chat_db)
|
self.memory = AgentMemory(self.agent_id,self.memory_db)
|
||||||
self.prviate_workspace = AgentWorkspace(self.agent_id)
|
self.prviate_workspace = AgentWorkspace(self.agent_id)
|
||||||
init_params = {}
|
init_params = {}
|
||||||
init_params["memory"] = self.memory
|
init_params["memory"] = self.memory
|
||||||
@@ -200,6 +200,7 @@ class AIAgent(BaseAIAgent):
|
|||||||
context_info["location"] = "SanJose"
|
context_info["location"] = "SanJose"
|
||||||
context_info["now"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
context_info["now"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
context_info["weather"] = "Partly Cloudy, 60°F"
|
context_info["weather"] = "Partly Cloudy, 60°F"
|
||||||
|
context_info["owner"] = AIStorage.get_instance().get_user_config().get_value("username")
|
||||||
|
|
||||||
return context_info
|
return context_info
|
||||||
|
|
||||||
@@ -209,7 +210,7 @@ class AIAgent(BaseAIAgent):
|
|||||||
need_process = False
|
need_process = False
|
||||||
|
|
||||||
session_topic = msg.target + "#" + msg.topic
|
session_topic = msg.target + "#" + msg.topic
|
||||||
chatsession = AIChatSession.get_session(self.agent_id,session_topic,self.chat_db)
|
chatsession = AIChatSession.get_session(self.agent_id,session_topic,self.memory_db)
|
||||||
if msg.mentions is not None:
|
if msg.mentions is not None:
|
||||||
if self.agent_id in msg.mentions:
|
if self.agent_id in msg.mentions:
|
||||||
need_process = True
|
need_process = True
|
||||||
@@ -247,10 +248,17 @@ class AIAgent(BaseAIAgent):
|
|||||||
filter = {}
|
filter = {}
|
||||||
filter["state"] = AgentTaskState.TASK_STATE_WAIT
|
filter["state"] = AgentTaskState.TASK_STATE_WAIT
|
||||||
|
|
||||||
tasklist = await self.prviate_workspace.task_mgr.list_task(filter)
|
tasklist:List[AgentTask]= await self.prviate_workspace.task_mgr.list_task(filter)
|
||||||
|
|
||||||
|
|
||||||
if tasklist:
|
if tasklist:
|
||||||
|
if len(tasklist) > 0:
|
||||||
|
simple_list:List[Dict] = []
|
||||||
|
for task in tasklist:
|
||||||
|
simple_list.append(task.to_simple_dict())
|
||||||
|
|
||||||
input_parms = {
|
input_parms = {
|
||||||
"tasklist":tasklist,
|
"tasklist":simple_list,
|
||||||
"context_info": await self._get_context_info()
|
"context_info": await self._get_context_info()
|
||||||
}
|
}
|
||||||
llm_result : LLMResult = await llm_process.process(input_parms)
|
llm_result : LLMResult = await llm_process.process(input_parms)
|
||||||
@@ -354,7 +362,7 @@ class AIAgent(BaseAIAgent):
|
|||||||
|
|
||||||
|
|
||||||
async def do_self_think(self):
|
async def do_self_think(self):
|
||||||
session_id_list = AIChatSession.list_session(self.agent_id,self.chat_db)
|
session_id_list = AIChatSession.list_session(self.agent_id,self.memory_db)
|
||||||
for session_id in session_id_list:
|
for session_id in session_id_list:
|
||||||
if self.agent_energy <= 0:
|
if self.agent_energy <= 0:
|
||||||
break
|
break
|
||||||
@@ -397,9 +405,11 @@ class AIAgent(BaseAIAgent):
|
|||||||
if self.agent_energy <= 0:
|
if self.agent_energy <= 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
|
||||||
if task.can_plan():
|
if task.can_plan():
|
||||||
# PLAN Task
|
# PLAN Task
|
||||||
await self.llm_plan_task(task)
|
await self.llm_plan_task(task)
|
||||||
|
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
|
||||||
|
|
||||||
if task.state == AgentTaskState.TASK_STATE_DOING:
|
if task.state == AgentTaskState.TASK_STATE_DOING:
|
||||||
# DO or Check Todo
|
# DO or Check Todo
|
||||||
@@ -408,14 +418,23 @@ class AIAgent(BaseAIAgent):
|
|||||||
for todo in todolist:
|
for todo in todolist:
|
||||||
if self.agent_energy <= 0:
|
if self.agent_energy <= 0:
|
||||||
break
|
break
|
||||||
|
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
|
||||||
|
todo = await self.prviate_workspace.task_mgr.get_todo_by_id(todo.todo_id)
|
||||||
|
if task.state != AgentTaskState.TASK_STATE_DOING:
|
||||||
|
break
|
||||||
if todo.state == AgentTodoState.TODO_STATE_WAITING or todo.state == AgentTodoState.TODO_STATE_EXEC_FAILED:
|
if todo.state == AgentTodoState.TODO_STATE_WAITING or todo.state == AgentTodoState.TODO_STATE_EXEC_FAILED:
|
||||||
await self.llm_do_todo(todo)
|
await self.llm_do_todo(todo)
|
||||||
|
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
|
||||||
|
todo = await self.prviate_workspace.task_mgr.get_todo_by_id(todo.todo_id)
|
||||||
|
if task.state != AgentTaskState.TASK_STATE_DOING:
|
||||||
|
break
|
||||||
if todo.state == AgentTodoState.TODO_STATE_EXEC_OK:
|
if todo.state == AgentTodoState.TODO_STATE_EXEC_OK:
|
||||||
await self.llm_check_todo(todo)
|
await self.llm_check_todo(todo)
|
||||||
|
|
||||||
if can_review:
|
if can_review:
|
||||||
task.state = AgentTaskState.TASK_STATE_WAITING_REVIEW
|
task.state = AgentTaskState.TASK_STATE_WAITING_REVIEW
|
||||||
|
|
||||||
|
task = await self.prviate_workspace.task_mgr.get_task(task.task_id)
|
||||||
if task.state == AgentTaskState.TASK_STATE_WAITING_REVIEW:
|
if task.state == AgentTaskState.TASK_STATE_WAITING_REVIEW:
|
||||||
await self.llm_review_task(task)
|
await self.llm_review_task(task)
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ class AgentMemory:
|
|||||||
if contact_id is None:
|
if contact_id is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# TODO : fix this by system config.
|
||||||
if contact_id == "lzc":
|
if contact_id == "lzc":
|
||||||
return "lzc is your master. Male, 40 years old, Mother tongue is Chinese, senior software engineer."
|
return "lzc is your master. Male, 40 years old, Mother tongue is Chinese, senior software engineer."
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -39,11 +39,7 @@ class AgentTriageTaskList(LLMAgentBaseProcess):
|
|||||||
logger.error(f"tasklist not found in input")
|
logger.error(f"tasklist not found in input")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
task_dict_list = []
|
prompt.append_user_message(json.dumps(task_list,ensure_ascii=False))
|
||||||
for task in task_list:
|
|
||||||
task_dict_list.append(task.to_dict())
|
|
||||||
|
|
||||||
prompt.append_user_message(json.dumps(task_dict_list,ensure_ascii=False))
|
|
||||||
|
|
||||||
system_prompt_dict = self.prepare_role_system_prompt(context_info)
|
system_prompt_dict = self.prepare_role_system_prompt(context_info)
|
||||||
# May all logs is good for Agent Triage Task List?
|
# May all logs is good for Agent Triage Task List?
|
||||||
@@ -89,7 +85,7 @@ class AgentTriageTaskList(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(self.memory.agent_id,"triage",llm_result.resp,self.memory.agent_id)
|
worklog = AgentWorkLog.create_by_content("","triage",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)
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class BaseLLMProcess(ABC):
|
|||||||
try:
|
try:
|
||||||
func_name = inner_func_call_node.get("name")
|
func_name = inner_func_call_node.get("name")
|
||||||
arguments = json.loads(inner_func_call_node.get("arguments"))
|
arguments = json.loads(inner_func_call_node.get("arguments"))
|
||||||
logger.info(f"LLMProcess execute inner func:{func_name} :\n\t {json.dumps(arguments,ensure_ascii=False)}")
|
logger.info(f"LLMProcess execute inner func:{func_name} :({json.dumps(arguments,ensure_ascii=False)})")
|
||||||
|
|
||||||
func_node : AIFunction = await self.get_inner_function_for_exec(func_name)
|
func_node : AIFunction = await self.get_inner_function_for_exec(func_name)
|
||||||
if func_node is None:
|
if func_node is None:
|
||||||
|
|||||||
+23
-15
@@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
|
|||||||
class LocalAgentTaskManger(AgentTaskManager):
|
class LocalAgentTaskManger(AgentTaskManager):
|
||||||
def __init__(self, owner_id):
|
def __init__(self, owner_id):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.root_path = f"{AIStorage.get_instance().get_myai_dir()}/tasklist/{owner_id}"
|
self.root_path = f"{AIStorage.get_instance().get_myai_dir()}/workspaces/{owner_id}_workspace"
|
||||||
#self.root_path = os.path.join(workspace, list_type)
|
#self.root_path = os.path.join(workspace, list_type)
|
||||||
if not os.path.exists(self.root_path):
|
if not os.path.exists(self.root_path):
|
||||||
os.makedirs(self.root_path)
|
os.makedirs(self.root_path)
|
||||||
@@ -451,7 +451,7 @@ class AgentWorkspace:
|
|||||||
return f"post message to {target} failed!"
|
return f"post message to {target} failed!"
|
||||||
|
|
||||||
parameters = ParameterDefine.create_parameters({
|
parameters = ParameterDefine.create_parameters({
|
||||||
"target": {"type": "string", "description": "target agent/contact id"},
|
"target": {"type": "string", "description": "target agent/contact fullname or telephone or email"},
|
||||||
"topic": {"type": "string", "description": "optional, message topic"},
|
"topic": {"type": "string", "description": "optional, message topic"},
|
||||||
"message": {"type": "string", "description": "message content"},
|
"message": {"type": "string", "description": "message content"},
|
||||||
})
|
})
|
||||||
@@ -513,10 +513,10 @@ class AgentWorkspace:
|
|||||||
parent_id = params.get("parent")
|
parent_id = params.get("parent")
|
||||||
return await _workspace.task_mgr.create_task(taskObj,parent_id)
|
return await _workspace.task_mgr.create_task(taskObj,parent_id)
|
||||||
parameters = ParameterDefine.create_parameters({
|
parameters = ParameterDefine.create_parameters({
|
||||||
"title": {"type": "string", "description": "task title"},
|
"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)"},
|
||||||
"tags": {"type": "string", "description": "optional,task tags"},
|
"priority" : {"type": "int", "description": "task priority from 1-10"},
|
||||||
"due_date": {"type": "string", "description": "optional,task due date"},
|
"due_date" : {"type": "isoformat time string", "description": "task due date"},
|
||||||
"parent": {"type": "string", "description": "optional,parent task id"},
|
"parent": {"type": "string", "description": "optional,parent task id"},
|
||||||
})
|
})
|
||||||
create_task_action = SimpleAIFunction(
|
create_task_action = SimpleAIFunction(
|
||||||
@@ -528,7 +528,6 @@ class AgentWorkspace:
|
|||||||
GlobaToolsLibrary.get_instance().register_tool_function(create_task_action)
|
GlobaToolsLibrary.get_instance().register_tool_function(create_task_action)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def cancel_task(parameters):
|
async def cancel_task(parameters):
|
||||||
_workspace = parameters.get("_workspace")
|
_workspace = parameters.get("_workspace")
|
||||||
if _workspace is None:
|
if _workspace is None:
|
||||||
@@ -563,19 +562,25 @@ class AgentWorkspace:
|
|||||||
return f"task {task_id} not found"
|
return f"task {task_id} not found"
|
||||||
if parameters.get("priority"):
|
if parameters.get("priority"):
|
||||||
task.priority = parameters.get("priority")
|
task.priority = parameters.get("priority")
|
||||||
if parameters.get("next_do_date"):
|
if parameters.get("next_attention_time"):
|
||||||
task.next_do_date = parameters.get("next_do_date")
|
task.next_attention_time = parameters.get("next_attention_time")
|
||||||
|
if parameters.get("expiration_time"):
|
||||||
|
task.expiration_time = parameters.get("expiration_time")
|
||||||
|
if parameters.get("due_date"):
|
||||||
|
task.due_date = parameters.get("due_date")
|
||||||
task.state = AgentTaskState.TASK_STATE_CONFIRMED
|
task.state = AgentTaskState.TASK_STATE_CONFIRMED
|
||||||
await _workspace.task_mgr.update_task(task)
|
await _workspace.task_mgr.update_task(task)
|
||||||
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"},
|
||||||
"next_do_date": {"type": "string", "description": "optional,confirm task next do date"},
|
"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"},
|
||||||
|
#"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"},
|
||||||
})
|
})
|
||||||
confirm_task_action = SimpleAIFunction(
|
confirm_task_action = SimpleAIFunction(
|
||||||
"agent.workspace.confirm_task",
|
"agent.workspace.confirm_task",
|
||||||
"Confirm this task",
|
"After understanding the content of the task, the importance of the importance of the task, the priority, the deadline, etc.",
|
||||||
confirm_task,
|
confirm_task,
|
||||||
parameters
|
parameters
|
||||||
)
|
)
|
||||||
@@ -611,20 +616,23 @@ class AgentWorkspace:
|
|||||||
task.priority = parameters.get("priority")
|
task.priority = parameters.get("priority")
|
||||||
if parameters.get("new_state"):
|
if parameters.get("new_state"):
|
||||||
task.state = AgentTaskState.from_str(parameters.get("new_state"))
|
task.state = AgentTaskState.from_str(parameters.get("new_state"))
|
||||||
if parameters.get("next_do_date"):
|
if parameters.get("next_attention_time"):
|
||||||
task.next_do_date = parameters.get("next_do_date")
|
task.next_attention_time = parameters.get("next_attention_time")
|
||||||
if parameters.get("due_date"):
|
if parameters.get("due_date"):
|
||||||
task.due_date = parameters.get("due_date")
|
task.due_date = parameters.get("due_date")
|
||||||
|
if parameters.get("expiration_time"):
|
||||||
|
task.expiration_time = parameters.get("expiration_time")
|
||||||
await _workspace.task_mgr.update_task(task)
|
await _workspace.task_mgr.update_task(task)
|
||||||
return "update task ok"
|
return "update task ok"
|
||||||
parameters = ParameterDefine.create_parameters({
|
parameters = ParameterDefine.create_parameters({
|
||||||
"task_id": {"type": "string", "description": "task id which want to update"},
|
"task_id": {"type": "string", "description": "task id which want to update"},
|
||||||
"new_state": {"type": "string", "description": "optional,new task state: cancel or done"},
|
"new_state": {"type": "string", "description": "optional,new task state: cancel or done"},
|
||||||
"next_do_date": {"type": "string", "description": "optional,confirm task next do date"},
|
"next_attention_time": {"type": "isoformat time string", "description": "optional,update task next attention time"},
|
||||||
|
"expiration_time": {"type": "isoformat time string", "description": "optional,update task expiration time"},
|
||||||
"priority": {"type": "int", "description": "optional,task priority from 1-10"},
|
"priority": {"type": "int", "description": "optional,task priority from 1-10"},
|
||||||
"title": {"type": "string", "description": "optional, new task title"},
|
"title": {"type": "string", "description": "optional, new task title"},
|
||||||
"detail": {"type": "string", "description": "optional, new task detail(simple task can not be filled)"},
|
"detail": {"type": "string", "description": "optional, new task detail(simple task can not be filled)"},
|
||||||
"due_date": {"type": "string", "description": "optional,new task due date"},
|
#"due_date": {"type": "string", "description": "optional,new task due date"},
|
||||||
})
|
})
|
||||||
update_task_ai_function = SimpleAIFunction("agent.workspace.update_task",
|
update_task_ai_function = SimpleAIFunction("agent.workspace.update_task",
|
||||||
"update task to new state",
|
"update task to new state",
|
||||||
|
|||||||
@@ -235,7 +235,6 @@ class AgentTodo:
|
|||||||
def to_dict(self) -> dict:
|
def to_dict(self) -> dict:
|
||||||
result = {}
|
result = {}
|
||||||
result["todo_id"] = self.todo_id
|
result["todo_id"] = self.todo_id
|
||||||
result["todo_path"] = self.todo_path
|
|
||||||
result["owner_taskid"] = self.owner_taskid
|
result["owner_taskid"] = self.owner_taskid
|
||||||
result["title"] = self.title
|
result["title"] = self.title
|
||||||
result["detail"] = self.detail
|
result["detail"] = self.detail
|
||||||
@@ -251,9 +250,6 @@ class AgentTodo:
|
|||||||
#todo_id
|
#todo_id
|
||||||
if json_obj.get("todo_id") is not None:
|
if json_obj.get("todo_id") is not None:
|
||||||
result_obj.todo_id = json_obj.get("todo_id")
|
result_obj.todo_id = json_obj.get("todo_id")
|
||||||
#todo_path
|
|
||||||
if json_obj.get("todo_path") is not None:
|
|
||||||
result_obj.todo_path = json_obj.get("todo_path")
|
|
||||||
#owner_taskid
|
#owner_taskid
|
||||||
if json_obj.get("owner_taskid") is not None:
|
if json_obj.get("owner_taskid") is not None:
|
||||||
result_obj.owner_taskid = json_obj.get("owner_taskid")
|
result_obj.owner_taskid = json_obj.get("owner_taskid")
|
||||||
@@ -288,23 +284,21 @@ class AgentTask:
|
|||||||
self.worker = None
|
self.worker = None
|
||||||
self.createor = None
|
self.createor = None
|
||||||
|
|
||||||
# if due_date is none ,means no due date
|
now = time.time()
|
||||||
self.due_date = time.time() + 3600 * 24 * 2
|
self.create_time = datetime.fromtimestamp(now).isoformat()
|
||||||
# 确定的执行时间(执行条件)
|
# dead line,set by llm
|
||||||
self.next_do_time = None
|
self.due_date = None
|
||||||
# 如果next check time设置,说明任务适合在该时间点可能具备执行调教,尝试检查并执行
|
# set by llm
|
||||||
#self.next_check_time = None
|
self.next_attention_time = None
|
||||||
|
# set by llm
|
||||||
|
self.expiration_time = None
|
||||||
|
|
||||||
self.depend_task_ids = []
|
self.depend_task_ids = []
|
||||||
#self.step_todo_ids = []
|
#self.step_todo_ids = []
|
||||||
|
|
||||||
self.create_time = time.time()
|
|
||||||
self.done_time = None
|
self.done_time = None
|
||||||
|
|
||||||
self.last_do_time = None
|
|
||||||
self.last_plan_time = None
|
self.last_plan_time = None
|
||||||
self.last_check_time = None
|
self.last_review_time = None
|
||||||
#self.last_review_time = None
|
|
||||||
|
|
||||||
def is_finish(self) -> bool:
|
def is_finish(self) -> bool:
|
||||||
if self.state == AgentTaskState.TASK_STATE_DONE:
|
if self.state == AgentTaskState.TASK_STATE_DONE:
|
||||||
@@ -319,10 +313,14 @@ class AgentTask:
|
|||||||
if self.state == AgentTaskState.TASK_STATE_FAILED:
|
if self.state == AgentTaskState.TASK_STATE_FAILED:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if self.due_date:
|
if self.expiration_time:
|
||||||
if self.due_date < time.time():
|
try:
|
||||||
|
expiration_time = datetime.fromisoformat(self.expiration_time).timestamp()
|
||||||
|
if expiration_time < time.time():
|
||||||
self.state = AgentTaskState.TASK_STATE_EXPIRED
|
self.state = AgentTaskState.TASK_STATE_EXPIRED
|
||||||
return True
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"invalid expiration_time {self.expiration_time}")
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -331,9 +329,27 @@ class AgentTask:
|
|||||||
return True
|
return True
|
||||||
if self.state == AgentTaskState.TASK_STATE_CHECKFAILED:
|
if self.state == AgentTaskState.TASK_STATE_CHECKFAILED:
|
||||||
return True
|
return True
|
||||||
|
if self.next_attention_time:
|
||||||
|
try:
|
||||||
|
next_attention_time = datetime.fromisoformat(self.next_attention_time).timestamp()
|
||||||
|
if next_attention_time >= time.time():
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"invalid next_attention_time {self.next_attention_time}")
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def to_simple_dict(self) -> dict:
|
||||||
|
result = {}
|
||||||
|
result["task_id"] = self.task_id
|
||||||
|
result["title"] = self.title
|
||||||
|
result["priority"] = self.priority
|
||||||
|
result["create_time"] = self.create_time
|
||||||
|
if self.due_date:
|
||||||
|
result["due_date"] = self.due_date
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def to_dict(self) -> dict:
|
def to_dict(self) -> dict:
|
||||||
result = {}
|
result = {}
|
||||||
result["task_id"] = self.task_id
|
result["task_id"] = self.task_id
|
||||||
@@ -341,26 +357,35 @@ class AgentTask:
|
|||||||
result["detail"] = self.detail
|
result["detail"] = self.detail
|
||||||
result["state"] = self.state.value
|
result["state"] = self.state.value
|
||||||
result["priority"] = self.priority
|
result["priority"] = self.priority
|
||||||
|
|
||||||
|
if self.tags:
|
||||||
result["tags"] = self.tags
|
result["tags"] = self.tags
|
||||||
|
|
||||||
|
if self.worker:
|
||||||
result["worker"] = self.worker
|
result["worker"] = self.worker
|
||||||
|
|
||||||
|
if self.createor:
|
||||||
result["createor"] = self.createor
|
result["createor"] = self.createor
|
||||||
|
result["create_time"] = self.create_time
|
||||||
if self.due_date:
|
if self.due_date:
|
||||||
result["due_date"] = datetime.fromtimestamp(self.due_date).isoformat()
|
result["due_date"] = self.due_date
|
||||||
if self.next_do_time:
|
if self.expiration_time:
|
||||||
result["next_do_time"] = datetime.fromtimestamp(self.next_do_time).isoformat()
|
result["expiration_time"] = self.expiration_time
|
||||||
|
|
||||||
|
if self.next_attention_time:
|
||||||
|
result["next_attention_time"] = self.next_attention_time
|
||||||
#if self.next_check_time:
|
#if self.next_check_time:
|
||||||
# result["next_check_time"] = datetime.fromtimestamp(self.next_check_time).isoformat()
|
# result["next_check_time"] = datetime.fromtimestamp(self.next_check_time).isoformat()
|
||||||
|
if self.depend_task_ids:
|
||||||
|
if len(self.depend_task_ids) > 0:
|
||||||
result["depend_task_ids"] = self.depend_task_ids
|
result["depend_task_ids"] = self.depend_task_ids
|
||||||
#result["step_todo_ids"] = self.step_todo_ids
|
|
||||||
result["create_time"] = datetime.fromtimestamp(self.create_time).isoformat()
|
|
||||||
if self.done_time:
|
if self.done_time:
|
||||||
result["done_time"] = datetime.fromtimestamp(self.done_time).isoformat()
|
result["done_time"] = self.done_time
|
||||||
if self.last_do_time:
|
|
||||||
result["last_do_time"] = datetime.fromtimestamp(self.last_do_time).isoformat()
|
|
||||||
if self.last_plan_time:
|
if self.last_plan_time:
|
||||||
result["last_plan_time"] = datetime.fromtimestamp(self.last_plan_time).isoformat()
|
result["last_plan_time"] = self.last_plan_time
|
||||||
if self.last_check_time:
|
if self.last_review_time:
|
||||||
result["last_check_time"] = datetime.fromtimestamp(self.last_check_time).isoformat()
|
result["last_review_time"] = self.last_review_time
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -374,32 +399,15 @@ class AgentTask:
|
|||||||
result.tags = json_obj.get("tags")
|
result.tags = json_obj.get("tags")
|
||||||
result.worker = json_obj.get("worker")
|
result.worker = json_obj.get("worker")
|
||||||
result.createor = json_obj.get("createor")
|
result.createor = json_obj.get("createor")
|
||||||
due_date = json_obj.get("due_date")
|
result.due_date = json_obj.get("due_date")
|
||||||
if due_date:
|
result.next_attention_time = json_obj.get("next_attention_time")
|
||||||
result.due_date = datetime.fromisoformat(due_date).timestamp()
|
|
||||||
next_do_time = json_obj.get("next_do_time")
|
|
||||||
if next_do_time:
|
|
||||||
result.next_do_time = datetime.fromisoformat(next_do_time).timestamp()
|
|
||||||
#next_check_time = json_obj.get("next_check_time")
|
|
||||||
#if next_check_time:
|
|
||||||
# result.next_check_time = datetime.fromisoformat(next_check_time).timestamp()
|
|
||||||
result.depend_task_ids = json_obj.get("depend_task_ids")
|
result.depend_task_ids = json_obj.get("depend_task_ids")
|
||||||
#result.step_todo_ids = json_obj.get("step_todo_ids")
|
#result.step_todo_ids = json_obj.get("step_todo_ids")
|
||||||
create_time = json_obj.get("create_time")
|
result.expiration_time = json_obj.get("expiration_time")
|
||||||
if create_time:
|
result.create_time = json_obj.get("create_time")
|
||||||
result.create_time = datetime.fromisoformat(create_time).timestamp()
|
result.done_time = json_obj.get("done_time")
|
||||||
done_time = json_obj.get("done_time")
|
result.last_plan_time = json_obj.get("last_plan_time")
|
||||||
if done_time:
|
result.last_review_time = json_obj.get("last_review_time")
|
||||||
result.done_time = datetime.fromisoformat(done_time).timestamp()
|
|
||||||
last_do_time = json_obj.get("last_do_time")
|
|
||||||
if last_do_time:
|
|
||||||
result.last_do_time = datetime.fromisoformat(last_do_time).timestamp()
|
|
||||||
last_plan_time = json_obj.get("last_plan_time")
|
|
||||||
if last_plan_time:
|
|
||||||
result.last_plan_time = datetime.fromisoformat(last_plan_time).timestamp()
|
|
||||||
last_check_time = json_obj.get("last_check_time")
|
|
||||||
if last_check_time:
|
|
||||||
result.last_check_time = datetime.fromisoformat(last_check_time).timestamp()
|
|
||||||
|
|
||||||
if result.task_id is None or result.title is None or result.create_time is None or result.create_time is None:
|
if result.task_id is None or result.title is None or result.create_time is None or result.create_time is None:
|
||||||
logger.error(f"invalid task {json_obj}")
|
logger.error(f"invalid task {json_obj}")
|
||||||
@@ -422,13 +430,11 @@ class AgentTask:
|
|||||||
result.priority = json_obj.get("priority")
|
result.priority = json_obj.get("priority")
|
||||||
if result.priority is None:
|
if result.priority is None:
|
||||||
result.priority = 5
|
result.priority = 5
|
||||||
|
if json_obj.get("due_date"):
|
||||||
|
result.due_date = json_obj.get("due_date")
|
||||||
result.tags = json_obj.get("tags")
|
result.tags = json_obj.get("tags")
|
||||||
result.worker = json_obj.get("worker")
|
result.worker = json_obj.get("worker")
|
||||||
result.createor = creator
|
result.createor = creator
|
||||||
due_date = json_obj.get("due_date")
|
|
||||||
if due_date:
|
|
||||||
result.due_date = datetime.fromisoformat(due_date).timestamp()
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class AgentManager:
|
|||||||
self.agent_env.parent_envs.append(sys_agent_env)
|
self.agent_env.parent_envs.append(sys_agent_env)
|
||||||
|
|
||||||
self.db_path = f"{user_data_dir}/messages.db"
|
self.db_path = f"{user_data_dir}/messages.db"
|
||||||
|
self.agent_memory_base_dir = f"{user_data_dir}/memory"
|
||||||
|
self.workspace_base_dir = f"{user_data_dir}/workspace"
|
||||||
self.loaded_agent_instance = {}
|
self.loaded_agent_instance = {}
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -70,7 +72,8 @@ class AgentManager:
|
|||||||
logger.warn(f"load agent {agent_id} from media failed!")
|
logger.warn(f"load agent {agent_id} from media failed!")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
the_agent.chat_db = self.db_path
|
the_agent.memory_db = f"{self.agent_memory_base_dir}/{agent_id}/{agent_id}_memory.db"
|
||||||
|
os.makedirs(os.path.dirname(the_agent.memory_db),exist_ok=True)
|
||||||
if await the_agent.initial():
|
if await the_agent.initial():
|
||||||
return the_agent
|
return the_agent
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user