diff --git a/.gitignore b/.gitignore
index d41e60e..f9f73a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,11 @@ dist/
.venv
config.yaml
+build/
+cache
**.lock
# Ignore Python cache files
**/__pycache__/
/session
+
+main.spec
\ No newline at end of file
diff --git a/agent/woker_agent.py b/agent/woker_agent.py
index 3e1d878..62e044b 100644
--- a/agent/woker_agent.py
+++ b/agent/woker_agent.py
@@ -33,19 +33,21 @@ class WorkerAgent:
def get_iter(question):
llm = LLM_Util().llm()
tools = ToolsUtil.get_tools()
- instructions = ""
+ example = """例子如下:案例1:```Thought: 我需要使用工具吗? 需要\nAction: 桌面路径\nAction Input: 无\nObservation: c:/path/develop```\n
+案例2:```Thought: 我需要使用工具吗? 需要\nAction: 打开应用\nAction Input: xxx\nObservation: 打开成功```\n
+案例3:```Thought: 我需要使用工具吗? 不需要\nFinal Answer: 您的桌面上有以下文件```\n
+"""
prompt = PromptTemplate(
- template="{instructions}\n\nTOOLS:\n------\n\n你可以使用以下工具:\n\n{tools}\n\n使用工具时,请使用以下格式:\n\n"
+ template="TOOLS:\n------\n\n你可以使用以下工具:\n\n{tools}\n\n使用工具时,请使用以下格式:\n\n"
"```\n'Thought: 我需要使用工具吗? 需要\nAction: {tool_names}'\n"
"'Action Input: Action的输入'\n'Observation: 运行Action的结果'\n```"
"\n\n当输出内容时,或者不需要使用工具,必须使用以下格式: "
- "\n\n```\nThought: 我需要使用工具吗? 不需要\nFinal Answer: [你的回复]\n```\n\n开始!\n\n"
+ "\n\n```\nThought: 我需要使用工具吗? 不需要\nFinal Answer: [你的回复]\n```\n\n{example}\n\n"
"Previous conversation history:\n{chat_history}\n\nNew input: {input}\n{agent_scratchpad}",
input_variables=['agent_scratchpad', 'input', 'tool_names', 'tools'],
partial_variables={'chat_history': '', 'instructions': ""}
)
- base_prompt = hub.pull("langchain-ai/react-agent-template")
- # prompt = base_prompt.partial(instructions=instructions)
+ prompt = prompt.partial(example=example)
agent = create_react_agent(llm=llm, tools=tools, prompt=prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, handle_parsing_errors=True)
return agent_executor.iter({"input": question})
diff --git a/pages/chat_page.py b/pages/chat_page.py
index 694bad7..1342a7a 100644
--- a/pages/chat_page.py
+++ b/pages/chat_page.py
@@ -5,6 +5,7 @@ from PyQt6.QtWidgets import QLabel, QTextEdit, QListWidgetItem, QSpacerItem, QSi
from agent.woker_agent import WorkerAgent
from pages.bse_page import BasePage
+from pages.func_list_page import FuncListPage
from utils.config import Config
from utils.qt_util import QtUtil
@@ -62,7 +63,6 @@ class ChatPage(BasePage):
chat_input.setGeometry(QtCore.QRect(40, 580, 601, 51))
chat_input.setStyleSheet("border-radius: 30px")
chat_input.setObjectName("chat_input")
- self.ui.action_widget.hide()
self.new_conversation(
"你好,欢迎来到智子 🎉\n\n智子是一个让普通人成为超级个体的Agent开发平台,只要你有想法,都可以用智子快速、低门槛搭建专属于你的 Agent!",
"system"
@@ -72,10 +72,24 @@ class ChatPage(BasePage):
# 设置 QListWidget 的选择模式为 NoSelection
self.ui.chat_list.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection)
# 设置 QListWidget 的焦点策略为 NoFocus
+
self.ui.chat_list.setFocusPolicy(Qt.FocusPolicy.NoFocus)
+ # 垂直滚动条滑动时才显示,否则隐藏
+ self.ui.chat_list.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
+ # 隐藏水平滚动条
+ self.ui.chat_list.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
# self.ui.select_action.clicked.connect(self.select_action_clicked)
setting_action = self.ui.setting_action
setting_action.triggered.connect(self.open_setting_page)
+ # 添加按钮点击事件,打开添加对话框
+ self.ui.add_action.clicked.connect(self.open_add_dialog)
+
+ def open_add_dialog(self):
+ self.func_list_page = FuncListPage(parent=self.ui)
+ # self.func_list_page.setParent(self.ui)
+
+ self.func_list_page.show()
+ self.ui.hide()
def open_setting_page(self):
self.setting_page = QtUtil.load_ui("setting_page.ui")
@@ -97,13 +111,6 @@ class ChatPage(BasePage):
def cancel_btn(self):
self.setting_page.close()
- def hide_action(self, event):
- action_widget = self.ui.action_widget
- if not QRect(action_widget.mapToGlobal(QPoint(0, 0)), action_widget.size()).contains(event.globalPos()):
- action_widget.hide()
-
- def select_action_clicked(self):
- self.ui.action_widget.show()
def new_conversation(self, text, role):
text = text.replace("\n", "
")
diff --git a/pages/chat_page.ui b/pages/chat_page.ui
index 8d5658e..8e799a8 100644
--- a/pages/chat_page.ui
+++ b/pages/chat_page.ui
@@ -40,58 +40,18 @@
border-radius: 30px
-
+
40
- 340
- 201
- 201
+ 550
+ 75
+ 23
-
- background: rgb(255, 255, 255)
+
+ 注入魔力
-
-
-
- 120
- 0
- 75
- 23
-
-
-
- 新增插件
-
-
-
-
-
- 0
- 30
- 201
- 171
-
-
-
- background: transparent;
-border: none;
-
-
-
-
-
- 0
- 0
- 101
- 16
-
-
-
- 已选用 0/0 个插件
-
-