From 5cfcc354b8a86a70f90a218761f74d7d4e30bd47 Mon Sep 17 00:00:00 2001 From: ruotongyu Date: Wed, 29 May 2024 18:46:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D(server.ts)?= =?UTF-8?q?=EF=BC=9A=E5=B0=86=E7=AB=AF=E5=8F=A3=E5=8F=98=E9=87=8F=E4=BB=8E?= =?UTF-8?q?=E5=B0=8F=E5=86=99port=E6=94=B9=E4=B8=BA=E5=A4=A7=E5=86=99PORT?= =?UTF-8?q?=20=20=20=E2=9C=A8=20=E5=8A=9F=E8=83=BD(server.ts)=EF=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9process.env.PORT=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actions/word_actions/table_action.py | 19 +++++++++++++++++++ pages/chat_page.py | 2 ++ pyproject.toml | 1 + tests/test_baidu_api.py | 22 +++++++++------------- utils/global_keyboard_listen.py | 2 -- 5 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 actions/word_actions/table_action.py diff --git a/actions/word_actions/table_action.py b/actions/word_actions/table_action.py new file mode 100644 index 0000000..ba712f2 --- /dev/null +++ b/actions/word_actions/table_action.py @@ -0,0 +1,19 @@ +import subprocess + +from pydantic import BaseModel, Field + +from actions.action_base import ActionBase + + +class OpenApplicationInput(BaseModel): + path: str = Field(description="要查询的关键词", title="应用路径", default="") + + +class TableAction(ActionBase): + name: str = "打开应用" + description: str = "打开指定目录的应用" + args: OpenApplicationInput + + def run(self, path): + print("运行了这里", path) + subprocess.Popen(path) diff --git a/pages/chat_page.py b/pages/chat_page.py index c5c3315..f514bae 100644 --- a/pages/chat_page.py +++ b/pages/chat_page.py @@ -9,6 +9,7 @@ from pages.config_page import ConfigPage from pages.plugin_page import PluginPage from utils.global_keyboard_listen import GlobalKeyboardListen from utils.qt_util import QtUtil +from utils.window_util import WindowUtil class ActionItems(QListWidgetItem): def __init__(self, action, chat_page): @@ -220,6 +221,7 @@ class ChatPage(QMainWindow, interface_ui): self.global_keyboard_listen.start() def show_window(self): + print(WindowUtil.get_window_title()) self.showNormal() diff --git a/pyproject.toml b/pyproject.toml index 431abb8..03cf1f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ pygments = "^2.17.2" python-docx = "^1.1.2" global-hotkeys = "^0.1.7" pynput = "^1.7.7" +open-interpreter = "^0.2.5" [build-system] diff --git a/tests/test_baidu_api.py b/tests/test_baidu_api.py index 201a79b..a17cc11 100644 --- a/tests/test_baidu_api.py +++ b/tests/test_baidu_api.py @@ -1,16 +1,12 @@ -from selenium.webdriver.common.by import By +from interpreter import interpreter -from utils.selenium_util import SeleniumUtil - - -class TestBaiduApi: +class OpenInterpreter: def test_api(self): - selenium = SeleniumUtil() - selenium.get_url("https://www.baidu.com/s?wd=搜索引擎 api 汇总") - result_elements = selenium.get_xpath_elements("//*[@class='result c-container xpath-log new-pmd']") - for result_element in result_elements: - title = result_element.find_element(By.XPATH, ".//h3").text - url = result_element.find_element(By.XPATH, ".//h3/a").get_attribute("href") - short_description = result_element.find_element(By.XPATH, ".//*/span[@class='content-right_8Zs40']").text - print(result_element) + interpreter.chat("最新的新闻") + +if __name__ == "__main__": + interpreter.llm.api_key = "sk-i6ClcJAogigoWxI9271b80E978374e8dAbC1167d3b6d8eA3" # LiteLLM, which we use to talk to LM Studio, requires this + interpreter.llm.api_base = "https://api.fast-tunnel.one/v1" # Point this at any OpenAI compatible server + OpenInterpreter().test_api() + diff --git a/utils/global_keyboard_listen.py b/utils/global_keyboard_listen.py index 4a2ba43..6664f8e 100644 --- a/utils/global_keyboard_listen.py +++ b/utils/global_keyboard_listen.py @@ -1,8 +1,6 @@ from pynput import mouse from PyQt6.QtCore import pyqtSignal, QThread -from utils.window_util import WindowUtil - class GlobalKeyboardListen(QThread): mouse_middle_signal = pyqtSignal() def __init__(self):