mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 13:07:17 +08:00
new
This commit is contained in:
Binary file not shown.
@@ -19,7 +19,7 @@ class ManagerAgent(AgentBase):
|
||||
call_openai_res = json.loads(self.call_gpt(prompt))
|
||||
if call_openai_res["isOk"] == "no":
|
||||
okr_object.raw_user_task = okr_object.raw_user_task + f",{i['target']}:" + input(
|
||||
f"【警告】{call_openai_res['content']}\n请您补充信息:")
|
||||
f"【任务】{okr_object.raw_user_task}\n\n【警告】{call_openai_res['content']}\n请您补充信息:")
|
||||
i['content'] = call_openai_res["content"]
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ 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格式的内容,比如["使用工具a进行xx操作", "使用工具b进行xx操作"]')
|
||||
super().__init__('你是一名计划拆解者,利用工具将object拆解成key_result,请你返回json格式的内容,比如[{"tools_name":"web_browser","param":"工具a"}]')
|
||||
|
||||
# 根据object和已有的工具能力拆解成key result,key
|
||||
def aligning(self, okr_object: OKR_Object):
|
||||
|
||||
@@ -6,7 +6,9 @@ from tools.tools_base import ToolsBase
|
||||
class LLMTools(ToolsBase):
|
||||
def __init__(self):
|
||||
self.name = "llm_tools"
|
||||
self.description = "利用大模型进行回答,入参格式为字典:{role:大模型的角色, content:问题}"
|
||||
self.description = "利用大模型进行回答"
|
||||
self.request_param='字典,如{"content": "天气怎么样"}'
|
||||
self.return_content = "大模型结果"
|
||||
|
||||
def run(self, param=None):
|
||||
"""
|
||||
|
||||
@@ -2,9 +2,11 @@ class ToolsBase:
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
self.description = ""
|
||||
self.request_param = ""
|
||||
self.return_content = ""
|
||||
|
||||
def get_info(self):
|
||||
return {"name": self.name, "description": self.description}
|
||||
return {"name": self.name, "description": self.description, "param": self.request_param, "return_content": self.return_content}
|
||||
|
||||
def run(self, param=None):
|
||||
pass
|
||||
|
||||
31
tools/web_browser_element_tools.py
Normal file
31
tools/web_browser_element_tools.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
import yaml
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from webdriver_manager.chrome import ChromeDriverManager
|
||||
from webdriver_manager.firefox import GeckoDriverManager
|
||||
from webdriver_manager.microsoft import EdgeChromiumDriverManager
|
||||
from webdriver_manager.opera import OperaDriverManager
|
||||
from selenium.webdriver.edge.service import Service as EdgeService
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
from tools.tools_base import ToolsBase
|
||||
|
||||
class WebBrowserElement(ToolsBase):
|
||||
def __init__(self):
|
||||
self.name = "web_element"
|
||||
self.description = "利用selenium对指定xpath进行点击或者输入内容"
|
||||
self.request_param = '字典,如{"driver": "driver", "xpath": "", "action":"click或send_text"}'
|
||||
self.return_content = "True"
|
||||
|
||||
def run(self, param=None):
|
||||
driver = param["driver"]
|
||||
xpath = param["xpath"]
|
||||
action = param["action"]
|
||||
if action == "click":
|
||||
driver.find_element(By.XPATH, xpath).click()
|
||||
elif action == "send_text":
|
||||
driver.find_element(By.XPATH, xpath).send_keys(param["text"])
|
||||
return True
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@ from selenium.webdriver.common.by import By
|
||||
|
||||
from tools.tools_base import ToolsBase
|
||||
|
||||
class WebBrowser(ToolsBase):
|
||||
class WebBrowserUrl(ToolsBase):
|
||||
def __init__(self):
|
||||
self.name = "web_browser"
|
||||
self.description = "利用浏览器进行搜索,入参格式为字符串"
|
||||
self.description = "利用selenium对指定URL进行访问"
|
||||
self.request_param = '字典,如{"usrl": ""}'
|
||||
self.return_content = '{"driver": "selenium的webdriver,driver用于继续在此见面上进行操作,可作为web_element工具的入参", "content": "网页xml结构"'
|
||||
|
||||
def run(self, param=None):
|
||||
# Load browser configuration from YAML file
|
||||
@@ -47,9 +49,8 @@ class WebBrowser(ToolsBase):
|
||||
webdriver_manager = OperaDriverManager()
|
||||
driver = webdriver.Opera(webdriver_manager.install(), options=options)
|
||||
driver.implicitly_wait(10)
|
||||
browser_url = config.get("browser_url")
|
||||
driver.get(browser_url)
|
||||
driver.find_element(by=By.XPATH, value='//*[@id="kw"]').send_keys("陈")
|
||||
driver.find_element(by=By.XPATH, value='//*[@id="su"]').click()
|
||||
print(driver.page_source)
|
||||
# browser_url = config.get("browser_url")
|
||||
# driver.get(browser_url)
|
||||
driver.get(param["url"])
|
||||
driver.quit()
|
||||
return driver.page_source
|
||||
Reference in New Issue
Block a user