Javirs control calender~

This commit is contained in:
Liu Zhicong
2023-09-20 01:33:00 -07:00
parent e6d7b2b009
commit a75857a631
9 changed files with 218 additions and 12 deletions
+11 -5
View File
@@ -198,8 +198,6 @@ class AIAgent:
if self.owner_env is None:
return None
return None
all_inner_function = self.owner_env.get_all_ai_functions()
if all_inner_function is None:
return None
@@ -219,15 +217,20 @@ class AIAgent:
func_name = inenr_func_call_node.get("name")
arguments = json.loads(inenr_func_call_node.get("arguments"))
logger.info(f"llm execute inner func:{func_name} ({json.dumps(arguments)})")
func_node : AIFunction = self.owner_env.get_ai_function(func_name)
if func_node is None:
return "execute failed,function not found"
ineternal_call_record = AgentMsg.create_internal_call_msg(func_name,arguments,org_msg.get_msg_id(),org_msg.target)
try:
result_str:str = await func_node.execute(**arguments)
except Exception as e:
result_str = "call error:" + str(e)
logger.error(f"llm execute inner func:{func_name} error:{e}")
result_str:str = await func_node.execute(**arguments)
inner_functions = self._get_inner_functions()
prompt.messages.append({"role":"function","content":result_str,"name":func_name})
task_result:ComputeTaskResult = await ComputeKernel.get_instance().do_llm_completion(prompt,self.llm_model_name,self.max_token_size,inner_functions)
@@ -242,6 +245,9 @@ class AIAgent:
else:
return task_result.result_str
async def _get_agent_prompt(self) -> AgentPrompt:
return self.prompt
async def _process_msg(self,msg:AgentMsg) -> AgentMsg:
from .compute_kernel import ComputeKernel
from .bus import AIBus
@@ -255,7 +261,7 @@ class AIAgent:
return None
prompt = AgentPrompt()
prompt.append(self.prompt)
prompt.append(await self._get_agent_prompt())
# prompt.append(self._get_knowlege_prompt(the_role.get_name()))
prompt.append(await self._get_prompt_from_session(chatsession)) # chat context