This commit is contained in:
yuruo 2024-01-21 21:06:27 +08:00
parent b352a14172
commit f99ab9ed43
6 changed files with 30 additions and 3 deletions

View File

@ -6,15 +6,16 @@ from work_principle.okr_principle import OKR_Object
class PlanAgent(AgentBase):
def __init__(self):
self.logger = logging.getLogger(__name__)
super().__init__('你是一名计划拆解者利用工具将object拆解成key_result请你返回json格式的内容比如[{"tools_name":"web_browser","param":"工具a"}]')
super().__init__('你是一名计划拆解者挑选工具列表中合适的工具将object拆解成key_result然后自动填充参数建议拆解成多个key_result' +
'多个key_result完成这一个目标返回格式如下[{"tools_name":"web_browser","request_param":"请求参数"}]')
# 根据object和已有的工具能力拆解成key resultkey
def aligning(self, okr_object: OKR_Object):
raw = okr_object.raw_user_task
tools_list = [i().get_info() for i in self.get_subclasses(ToolsBase)]
r = self.call_gpt(f"object为'{raw}' 工具列表为{tools_list}")
print(r)
self.logger.info(f"Alignment result: {r}")
# return r
def get_subclasses(self, cls):
subclasses = []

View File

@ -16,7 +16,7 @@ class AutoMate:
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")
r = input(f"最终对齐的任务是:{o_kr.raw_user_task}一切都OK对吧y/n\n")
if r == "y":
break

5
pytest.ini Normal file
View File

@ -0,0 +1,5 @@
[pytest]
log_cli = True
log_cli_level = info
log_cli_format = %(asctime)s [%(levelname)s] | %(filename)s:%(lineno)s | %(message)s
log_cli_date_format = %Y-%m-%d %H:%M:%S

3
tests/pytest.in Normal file
View File

@ -0,0 +1,3 @@
[pytest]
log_cli = True
log_cli_level = info

15
tests/test_plan_agent.py Normal file
View File

@ -0,0 +1,15 @@
import unittest
from agent.plan_agent import PlanAgent
from work_principle.okr_principle import OKR_Object
class TestPlanAgent(unittest.TestCase):
def test_aligning(self):
# Create an instance of the PlanAgent class
plan_agent = PlanAgent()
# Create a mock OKR_Object with a raw_user_task
okr_object = OKR_Object("因为想要增加编程效率对比一下copilot和curson谁更好用比较提示词数量、安装易用性给出不少于100字的文")
# Call the aligning method
plan_agent.aligning(okr_object)
if __name__ == '__main__':
unittest.main()

3
tools/init.py Normal file
View File

@ -0,0 +1,3 @@
from llm_tools import LLMTools
from web_browser_element_tools import WebBrowserElement
from web_browser_url_tools import WebBrowserUrl