Files
autoMate/agent/manager_agent.py
2024-01-21 00:10:02 +08:00

31 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
from agent.agent_base import AgentBase
from agent.plan_agent import PlanAgent
from work_principle.okr_principle import OKR_Object
import logging
logging.basicConfig(level=logging.INFO)
class ManagerAgent(AgentBase):
def __init__(self):
super().__init__("你是一名总经理,负责与客户对齐目标,与计划拆解者对齐关键结果")
self.logger = logging.getLogger(__name__)
# 与用户对齐目标,填充缺失的信息
def optimization_Object(self, okr_object:OKR_Object):
# todo 待加入 PDCA循环规则
for i in okr_object.task.content:
call_openai_res = {'isOk': 'no', 'content': ''}
while call_openai_res["isOk"]=="no" :
prompt = f"这是一个任务描述:'{okr_object.raw_user_task}'。你觉得这个任务描述具备{i['descriptions']}吗?如果具备返回格式如下:{{\"isOk\":\"yes\", \"content\":\"提炼出任务的{i['descriptions']}\"}},如果不具备返回格式如下:{{\"isOk\":\"no\",\"content\":\"返回不具备的原因并给出完善建议\"}}"
self.logger.info(prompt)
call_openai_res = json.loads(self.call_gpt(prompt))
self.logger.info(call_openai_res)
if call_openai_res["isOk"]=="no":
okr_object.raw_user_task = okr_object.raw_user_task + f"{i['target']}" +input(f"【警告】{call_openai_res['content']}\n请您补充信息:")
i['content'] = call_openai_res["content"]
# 与计划拆解者对齐关键结果,填充缺失的信息
def assign_task_to_plan_agent(self, okr_object:OKR_Object):
okr_object.task.raw_user_task
PlanAgent()