mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 04:57:18 +08:00
增加编辑操作
This commit is contained in:
76
main.py
76
main.py
@@ -7,7 +7,8 @@ from langchain.agents import create_openai_functions_agent, AgentExecutor, Agent
|
||||
from langchain_core.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, MessagesPlaceholder, PromptTemplate, \
|
||||
HumanMessagePromptTemplate
|
||||
|
||||
from ui.login_page import LoginPage
|
||||
from pages.edit_page import EditPage
|
||||
from pages.login_page import LoginPage
|
||||
from agent.manager_agent import ManagerAgent
|
||||
from agent.plan_agent import PlanAgent
|
||||
from tools.search_engine_tool import SearchEngineTool
|
||||
@@ -20,39 +21,27 @@ import logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def run():
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
SystemMessagePromptTemplate(
|
||||
prompt=PromptTemplate(input_variables=[], template='你是一个工作助手')),
|
||||
MessagesPlaceholder(variable_name='chat_history', optional=True),
|
||||
HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['input'], template='{input}')),
|
||||
MessagesPlaceholder(variable_name='agent_scratchpad')
|
||||
]
|
||||
)
|
||||
model = LLMUtil().llm()
|
||||
tools = [SearchEngineTool()]
|
||||
agent = create_openai_functions_agent(model, tools, prompt)
|
||||
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, return_intermediate_steps=True)
|
||||
r = input("请输入你的问题:\n")
|
||||
agent_executor.invoke({"input": r})
|
||||
|
||||
|
||||
class AutoMate:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
# def rule_define(self):
|
||||
# # 与用户对齐任务
|
||||
# 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\n")
|
||||
# if r == "y":
|
||||
# break
|
||||
#
|
||||
# # 让计划拆解者拆解任务
|
||||
# PlanAgent().aligning(o_kr)
|
||||
|
||||
def run(self):
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
SystemMessagePromptTemplate(
|
||||
prompt=PromptTemplate(input_variables=[], template='你是一个工作助手')),
|
||||
MessagesPlaceholder(variable_name='chat_history', optional=True),
|
||||
HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['input'], template='{input}')),
|
||||
MessagesPlaceholder(variable_name='agent_scratchpad')
|
||||
]
|
||||
)
|
||||
model = LLMUtil().llm()
|
||||
tools = [SearchEngineTool()]
|
||||
agent = create_openai_functions_agent(model, tools, prompt)
|
||||
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, return_intermediate_steps=True)
|
||||
r = input("请输入你的问题:\n")
|
||||
agent_executor.invoke({"input": r})
|
||||
self.page = None
|
||||
|
||||
def run_ui(self):
|
||||
config = Config()
|
||||
@@ -60,25 +49,22 @@ class AutoMate:
|
||||
# 从文件中判断是否有session
|
||||
tmp_file = "./session"
|
||||
if os.path.exists(tmp_file):
|
||||
with open(tmp_file, 'rb') as file:
|
||||
with (open(tmp_file, 'rb') as file):
|
||||
session_token = file.read()
|
||||
leancloud.User.become(session_token)
|
||||
authenticated = leancloud.User.get_current().is_authenticated()
|
||||
if not authenticated:
|
||||
self.goto_login_page()
|
||||
self.page = LoginPage()
|
||||
self.page.show()
|
||||
else:
|
||||
print("登陆成功")
|
||||
self.page = EditPage()
|
||||
else:
|
||||
self.goto_login_page()
|
||||
|
||||
def goto_login_page(self):
|
||||
app = QApplication(sys.argv)
|
||||
w = LoginPage()
|
||||
w.show()
|
||||
sys.exit(app.exec())
|
||||
self.page = LoginPage()
|
||||
self.page.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
automator = AutoMate()
|
||||
automator.run_ui()
|
||||
# print(automator.call_chatgpt_api("Hello"))
|
||||
app = QApplication(sys.argv)
|
||||
page = AutoMate()
|
||||
page.run_ui()
|
||||
sys.exit(app.exec())
|
||||
|
||||
6
pages/bse_page.py
Normal file
6
pages/bse_page.py
Normal file
@@ -0,0 +1,6 @@
|
||||
class BasePage:
|
||||
def __init__(self):
|
||||
self.ui = None
|
||||
|
||||
def show(self):
|
||||
self.ui.show()
|
||||
70
pages/edit_page.ui
Normal file
70
pages/edit_page.ui
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>autoMate</class>
|
||||
<widget class="QMainWindow" name="autoMate">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>799</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>801</width>
|
||||
<height>461</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,2,10">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QScrollBar" name="verticalScrollBar">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="functionSearch"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="functionModules"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="serial"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>799</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
12
utils/qt_util.py
Normal file
12
utils/qt_util.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import os
|
||||
|
||||
from PyQt6 import uic
|
||||
|
||||
|
||||
class QtUtil:
|
||||
@staticmethod
|
||||
def load_ui(ui_name):
|
||||
# 项目根目录
|
||||
project_root_path = os.path.abspath(os.path.dirname(__file__))
|
||||
path = os.path.join(project_root_path, "..", "pages", ui_name)
|
||||
return uic.loadUi(path)
|
||||
Reference in New Issue
Block a user