diff --git a/README.md b/README.md index 4b26f1c..42a6441 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,10 @@ autoMate定义了三种角色: - 计划者:负责制定任务的具体计划和策略。 - 工人:负责执行具体的任务。 +# 工作原则 +人们在工作中总结了很多原则,运用这些工作原则可以大幅度提高效率、评估风险、资源管理、目标对齐。是否可以把这些原则运用在大模型中呢?让大模型像员工一样工作。 -# OKR工作体系 +## OKR工作原则 大模型的回答内容缺少精准度,本质上是对任务理解不透彻,如何解决这个问题呢?我想到了OKR工作体系,把上层的O向下拆解成KR,并且中间不断对焦!我认为这是一个非常高效的工作体系,AutoMate 引入OKR就像是给整个团队配上了高级导航系统,各agent都能清清楚楚知道自己要完成的任务,同时不断与上级对焦能够避免任务失真。 diff --git a/agent/manager_agent.py b/agent/manager_agent.py index dcd9b67..9ad776c 100644 --- a/agent/manager_agent.py +++ b/agent/manager_agent.py @@ -1,26 +1,30 @@ 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__("你是一名总经理,负责对任务进行可量化的评估") + super().__init__("你是一名总经理,负责与客户对齐目标,与计划拆解者对齐关键结果") self.logger = logging.getLogger(__name__) - def optimization_Object(self, object:OKR_Object): + # 与用户对齐目标,填充缺失的信息 + def optimization_Object(self, okr_object:OKR_Object): # todo 待加入 PDCA循环规则 - # 利用 smart 原则对目标进行评估 - - for i in object.five_w_two_h.content: - content = object.content + for i in okr_object.task.content: call_openai_res = {'isOk': 'no', 'content': ''} while call_openai_res["isOk"]=="no" : - prompt = f"这是一个任务描述:'{content}'。你觉得这个任务描述具备{i['descriptions']}吗?如果具备返回格式如下:{{\"isOk\":\"yes\", \"content\":\"提炼出任务的{i['descriptions']}\"}},如果不具备返回格式如下:{{\"isOk\":\"no\",\"content\":\"返回不具备的原因并给出完善建议\"}}" + 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": - content = content + f",{i['target']}:" +input(f"【警告】{call_openai_res['content']}\n请您补充信息:") + 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"] - self.logger.info(str(object.five_w_two_h.content)) + + + # 与计划拆解者对齐关键结果,填充缺失的信息 + def assign_task_to_plan_agent(self, okr_object:OKR_Object): + okr_object.task.raw_user_task + PlanAgent() diff --git a/agent/plan_agent.py b/agent/plan_agent.py index bd41575..f9a6de3 100644 --- a/agent/plan_agent.py +++ b/agent/plan_agent.py @@ -1,5 +1,15 @@ from agent.agent_base import AgentBase +from work_principle.okr_principle import OKR_Object -class WokerAgent(AgentBase): +class PlanAgent(AgentBase): def __init__(self): super().__init__("你是一名计划拆解者,负责对OKR中的O进行拆解并制定KR,向总经理汇报") + + + # 与用户对齐目标,填充缺失的信息 + def aligning(self, okr_object:OKR_Object): + pass + + + + \ No newline at end of file diff --git a/main.py b/main.py index 7fc986f..a4e1f4f 100644 --- a/main.py +++ b/main.py @@ -8,9 +8,13 @@ class AutoMate: def rule_define(self): - # o_kr = OKR_Object(input("请输入任务: ")) - o_kr = OKR_Object("对比一下copilot和curson谁更好用,比较提示词数量、安装易用性,给出不少于100字的文章") - ManagerAgent().optimization_Object(o_kr) + # 与用户对齐任务 + while True: + o_kr = OKR_Object("对比一下copilot和curson谁更好用,比较提示词数量、安装易用性,给出不少于100字的文章") + ManagerAgent().optimization_Object(o_kr) + r = input(f"最终对齐的任务是:{o_kr.raw_user_task},一切都OK对吧?y/n") + if r == "y": + break diff --git a/tools/llm_tools.py b/tools/llm_tools.py new file mode 100644 index 0000000..e06d820 --- /dev/null +++ b/tools/llm_tools.py @@ -0,0 +1,7 @@ + +from tools.tools_base import ToolsBase + + +class LLMTools(ToolsBase): + def get_describe(self): + return "利用大模型进行回答" \ No newline at end of file diff --git a/tools/tools_base.py b/tools/tools_base.py index ba594a8..b31c803 100644 --- a/tools/tools_base.py +++ b/tools/tools_base.py @@ -1,3 +1,8 @@ class ToolsBase: + def get_describe(self): + return ["内容总结", "感性信息"] + + def run(self): pass + \ No newline at end of file diff --git a/tools/web_browser_tools.py b/tools/web_browser_tools.py index cf7da4c..41b14fa 100644 --- a/tools/web_browser_tools.py +++ b/tools/web_browser_tools.py @@ -12,6 +12,8 @@ from selenium.webdriver.common.by import By from tools.tools_base import ToolsBase class WebBrowser(ToolsBase): + def get_describe(self): + return ["最新信息", "链接", "具体针对性信息", "专业信息"] def run(self): # Load browser configuration from YAML file diff --git a/work_principle/five_w_two_h.py b/work_principle/object_components.py similarity index 96% rename from work_principle/five_w_two_h.py rename to work_principle/object_components.py index bacc840..381b775 100644 --- a/work_principle/five_w_two_h.py +++ b/work_principle/object_components.py @@ -1,4 +1,4 @@ -class FiveWTwoH: +class ObjectComponents: def __init__(self) -> None: self.content = [ {"target": "任务主体", "content": "", "descriptions": "任务主体"}, diff --git a/work_principle/okr_principle.py b/work_principle/okr_principle.py index 07a498c..d917a72 100644 --- a/work_principle/okr_principle.py +++ b/work_principle/okr_principle.py @@ -1,12 +1,12 @@ -from work_principle.five_w_two_h import FiveWTwoH +from work_principle.object_components import ObjectComponents class OKR_Object: - def __init__(self, content): - self.content = content + def __init__(self, raw_user_task): + self.raw_user_task = raw_user_task self.key_results = [] self.progress = 0 - self.five_w_two_h = FiveWTwoH() + self.task = ObjectComponents() def add_key_result(self, key_result): self.key_results.append(key_result)