Fix bugs.
This commit is contained in:
@@ -58,7 +58,8 @@ process_description="""
|
|||||||
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 answer.'
|
think:'$think step-by-step to be sure you have the right answer.',
|
||||||
|
determine : '$determine, summary what you will do',
|
||||||
plans:[ #Optional
|
plans:[ #Optional
|
||||||
{"todo":"$todo_name","detail":"$todo_detail,"category":"$todo_category"}
|
{"todo":"$todo_name","detail":"$todo_detail,"category":"$todo_category"}
|
||||||
...
|
...
|
||||||
|
|||||||
+33
-4
@@ -14,7 +14,7 @@ import sys
|
|||||||
|
|
||||||
from ..proto.agent_msg import AgentMsg
|
from ..proto.agent_msg import AgentMsg
|
||||||
from ..proto.ai_function import *
|
from ..proto.ai_function import *
|
||||||
from ..proto.agent_task import *
|
from ..proto.agent_task import AgentTaskState,AgentTask,AgentTodo,AgentTodoResult
|
||||||
from ..proto.compute_task import *
|
from ..proto.compute_task import *
|
||||||
|
|
||||||
from .agent_base import *
|
from .agent_base import *
|
||||||
@@ -31,7 +31,7 @@ from ..storage.storage import AIStorage
|
|||||||
|
|
||||||
from ..knowledge import *
|
from ..knowledge import *
|
||||||
from ..utils import video_utils, image_utils
|
from ..utils import video_utils, image_utils
|
||||||
from ..proto.compute_task import ComputeTaskResult,ComputeTaskResultCode
|
from ..proto.compute_task import ComputeTaskResult,ComputeTaskResultCode,LLMPrompt,LLMResult
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -240,6 +240,33 @@ class AIAgent(BaseAIAgent):
|
|||||||
return await self.llm_process_msg(msg)
|
return await self.llm_process_msg(msg)
|
||||||
|
|
||||||
|
|
||||||
|
async def llm_review_tasklist(self):
|
||||||
|
llm_process : BaseLLMProcess = self.behaviors.get("review_task")
|
||||||
|
if llm_process:
|
||||||
|
if self.prviate_workspace:
|
||||||
|
tasklist = await self.prviate_workspace.task_mgr.list_task()
|
||||||
|
if tasklist:
|
||||||
|
for agent_task in tasklist:
|
||||||
|
if self.agent_energy <= 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
if agent_task.state == AgentTaskState.TASK_STATE_WAIT:
|
||||||
|
input_parms = {
|
||||||
|
"task":agent_task
|
||||||
|
}
|
||||||
|
llm_result : LLMResult = await llm_process.process(input_parms)
|
||||||
|
if llm_result.state == LLMResultStates.ERROR:
|
||||||
|
logger.error(f"llm process review_task error:{llm_result.error_str}")
|
||||||
|
continue
|
||||||
|
elif llm_result.state == LLMResultStates.IGNORE:
|
||||||
|
logger.info(f"llm process review_task ignore!")
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
determine = llm_result.raw_result.get("determine")
|
||||||
|
logger.info(f"llm process review_task ok!,think is:{determine}")
|
||||||
|
self.agent_energy -= 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def _llm_run_todo_list(self, todo_list_type: TodoListType):
|
async def _llm_run_todo_list(self, todo_list_type: TodoListType):
|
||||||
workspace : WorkspaceEnvironment = self.get_workspace_by_msg(None)
|
workspace : WorkspaceEnvironment = self.get_workspace_by_msg(None)
|
||||||
@@ -486,8 +513,8 @@ class AIAgent(BaseAIAgent):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
async def think_todo_log(self,todo_log:AgentWorkLog):
|
#async def think_todo_log(self,todo_log:AgentWorkLog):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -516,6 +543,8 @@ class AIAgent(BaseAIAgent):
|
|||||||
if self.agent_energy <= 1:
|
if self.agent_energy <= 1:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
await self.llm_review_tasklist()
|
||||||
|
|
||||||
# complete & check todo
|
# complete & check todo
|
||||||
#await self._llm_run_todo_list(TodoListType.TO_WORK)
|
#await self._llm_run_todo_list(TodoListType.TO_WORK)
|
||||||
|
|
||||||
|
|||||||
@@ -522,7 +522,8 @@ class ReviewTaskProcess(BaseLLMProcess):
|
|||||||
if await super().load_from_config(config) is False:
|
if await super().load_from_config(config) is False:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def prepare_prompt(self) -> LLMPrompt:
|
async def prepare_prompt(self,input:Dict) -> LLMPrompt:
|
||||||
|
agent_task = input.get("task")
|
||||||
prompt = LLMPrompt()
|
prompt = LLMPrompt()
|
||||||
system_prompt_dict = {}
|
system_prompt_dict = {}
|
||||||
system_prompt_dict["role_description"] = self.role_description
|
system_prompt_dict["role_description"] = self.role_description
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import json
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List, Optional
|
||||||
|
|
||||||
import aiofiles
|
import aiofiles
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ class LocalAgentTaskManger(AgentTaskManager):
|
|||||||
# pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
async def list_task(self,filter:dict) -> List[AgentTask]:
|
async def list_task(self,filter:Optional[dict] = None ) -> List[AgentTask]:
|
||||||
|
|
||||||
directory_path = self.root_path
|
directory_path = self.root_path
|
||||||
result_list:List[AgentTask] = []
|
result_list:List[AgentTask] = []
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ class AgentTaskManager(ABC):
|
|||||||
# pass
|
# pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def list_task(self,filter:Optional[dict]) -> List[AgentTask]:
|
async def list_task(self,filter:Optional[dict] = None) -> List[AgentTask]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user