mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 04:57:18 +08:00
new
This commit is contained in:
18
README.md
18
README.md
@@ -1,3 +1,17 @@
|
||||
让大模型为你打工!
|
||||
# autoMate
|
||||
|
||||
输入任务后就能上网找资料,然后参考优秀案例执行,最后给一个结果!你只需要像一个老板一样反馈结果好还是坏,autoMate会自动优化方案。
|
||||
autoMate是一个让大模型为你打工的工具。它能够根据你输入的任务,在网上找资料并参考优秀案例来执行任务,并最终给出一个结果。你只需要像一个老板一样反馈结果好还是坏,autoMate会自动优化方案。
|
||||
|
||||
|
||||
# 角色
|
||||
|
||||
autoMate定义了三种角色:
|
||||
|
||||
- 总经理:负责整体的任务管理和决策。
|
||||
- 计划者:负责制定任务的具体计划和策略。
|
||||
- 工人:负责执行具体的任务。
|
||||
|
||||
|
||||
# OKR工作体系
|
||||
|
||||
市面上的大模型是对任务理解不透彻,如何解决这个问题呢?我想到了OKR工作体系,把上层的O向下拆解成KR,并且中间不断对焦!我认为这是一个非常高效的工作体系,AutoMate 引入OKR就像是给整个团队配上了高级导航系统,各agent都能清清楚楚知道自己要完成的任务,同时不断与上级对焦能够避免任务失真。
|
||||
BIN
__pycache__/okr_define.cpython-39.pyc
Normal file
BIN
__pycache__/okr_define.cpython-39.pyc
Normal file
Binary file not shown.
47
agent/agent.py
Normal file
47
agent/agent.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import openai
|
||||
import yaml
|
||||
|
||||
|
||||
class Agent:
|
||||
def __init__(self, role):
|
||||
"""
|
||||
Initialize an Agent object.
|
||||
|
||||
Args:
|
||||
role (str): The role of the agent.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
self.role = role
|
||||
|
||||
|
||||
|
||||
def call(self, input_text):
|
||||
"""
|
||||
Make a call to the OpenAI chat API.
|
||||
|
||||
Args:
|
||||
input_text (str): The input text for the chat API.
|
||||
|
||||
Returns:
|
||||
str: The generated text from the chat API.
|
||||
"""
|
||||
# Load API configuration from YAML file
|
||||
with open("config.yaml", "r") as file:
|
||||
config = yaml.safe_load(file).get("openai")
|
||||
|
||||
openai.api_key = config.get("api_key")
|
||||
openai.base_url = config.get("api_url")
|
||||
|
||||
response = openai.chat.completions.create(
|
||||
model="gpt-3.5-turbo", # GPT-3.5 model
|
||||
messages=[
|
||||
{"role": "user", "content": self.role +","+ input_text}
|
||||
],
|
||||
temperature=0.2
|
||||
)
|
||||
|
||||
generated_text = response.choices[0].message.content
|
||||
|
||||
return generated_text
|
||||
5
agent/manager_agent.py
Normal file
5
agent/manager_agent.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from agent.agent import Agent
|
||||
|
||||
class ManagerAgent(Agent):
|
||||
def __init__(self):
|
||||
super().__init__("你是一名总经理,负责与用户沟通需求,制定OKR中的O,并对下属的工作成果进行评估")
|
||||
5
agent/plan_agent.py
Normal file
5
agent/plan_agent.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from agent.agent import Agent
|
||||
|
||||
class WokerAgent(Agent):
|
||||
def __init__(self):
|
||||
super().__init__("你是一名计划拆解者,负责对OKR中的O进行拆解并制定KR,向总经理汇报")
|
||||
5
agent/woker_agent.py
Normal file
5
agent/woker_agent.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from agent.agent import Agent
|
||||
|
||||
class WokerAgent(Agent):
|
||||
def __init__(self):
|
||||
super().__init__("你是一名工作者,负责执行OKR中的KR,向总计划制定者汇报")
|
||||
77
main.py
77
main.py
@@ -1,79 +1,12 @@
|
||||
import os
|
||||
import requests
|
||||
import yaml
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
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
|
||||
import openai
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
|
||||
class AutoMate:
|
||||
def __init__(self):
|
||||
pass
|
||||
def main(self):
|
||||
# Load browser configuration from YAML file
|
||||
with open("config.yaml", "r") as file:
|
||||
config = yaml.safe_load(file)
|
||||
|
||||
# Check if webdriver is available
|
||||
if not os.path.exists("webdriver.exe"):
|
||||
# Download webdriver based on browser type
|
||||
browser_type = config.get("browser_type")
|
||||
driver = None
|
||||
if browser_type == "chrome":
|
||||
options = webdriver.ChromeOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
webdriver_manager = ChromeDriverManager()
|
||||
driver = webdriver.Chrome(webdriver_manager.install(), options=options)
|
||||
elif browser_type == "firefox":
|
||||
options = webdriver.FirefoxOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
webdriver_manager = GeckoDriverManager()
|
||||
driver = webdriver.Firefox(webdriver_manager.install(), options=options)
|
||||
elif browser_type == "edge":
|
||||
options = webdriver.EdgeOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
webdriver_manager = EdgeChromiumDriverManager()
|
||||
driver = webdriver.Edge(service=EdgeService(webdriver_manager.install()), options=options)
|
||||
elif browser_type == "opera":
|
||||
options = webdriver.ChromeOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
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)
|
||||
driver.quit()
|
||||
|
||||
def call_chatgpt_api(self, input_text):
|
||||
# Load API configuration from YAML file
|
||||
with open("config.yaml", "r") as file:
|
||||
config = yaml.safe_load(file).get("openai")
|
||||
|
||||
openai.api_key = config.get("api_key")
|
||||
openai.base_url = config.get("api_url")
|
||||
|
||||
response = openai.chat.completions.create(
|
||||
model="gpt-3.5-turbo", # GPT-3.5 model
|
||||
messages=[
|
||||
{"role": "user", "content": input_text}
|
||||
],
|
||||
temperature=0.7
|
||||
)
|
||||
|
||||
generated_text = response.choices[0].message.content
|
||||
|
||||
return generated_text
|
||||
|
||||
|
||||
def rule_define(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
35
okr_define.py
Normal file
35
okr_define.py
Normal file
@@ -0,0 +1,35 @@
|
||||
class OKR:
|
||||
"""
|
||||
Represents an Objectives and Key Results (OKR) tracker.
|
||||
|
||||
Attributes:
|
||||
objectives (dict): A dictionary to store the objectives and their progress.
|
||||
key_results (dict): A dictionary to store the key results for each objective.
|
||||
|
||||
Methods:
|
||||
set_objective(objective): Sets a new objective with initial progress of 0.
|
||||
set_key_result(objective, key_result): Sets a new key result for the given objective.
|
||||
set_objective_progress(objective, progress): Updates the progress of the given objective.
|
||||
set_key_result_progress(objective, key_result, progress): Updates the progress of the given key result.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.objectives = {}
|
||||
self.key_results = {}
|
||||
|
||||
def set_objective(self, objective):
|
||||
self.objectives[objective] = 0
|
||||
|
||||
def set_key_result(self, objective, key_result):
|
||||
if objective in self.objectives:
|
||||
if objective not in self.key_results:
|
||||
self.key_results[objective] = []
|
||||
self.key_results[objective].append(key_result)
|
||||
|
||||
def set_objective_progress(self, objective, progress):
|
||||
if objective in self.objectives:
|
||||
self.objectives[objective] = progress
|
||||
|
||||
def set_key_result_progress(self, objective, key_result, progress):
|
||||
if objective in self.key_results and key_result in self.key_results[objective]:
|
||||
self.key_results[objective][key_result] = progress
|
||||
3
tools/tools_base.py
Normal file
3
tools/tools_base.py
Normal file
@@ -0,0 +1,3 @@
|
||||
class ToolsBase:
|
||||
def run(self):
|
||||
pass
|
||||
52
tools/web_browser_tools.py
Normal file
52
tools/web_browser_tools.py
Normal file
@@ -0,0 +1,52 @@
|
||||
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 WebBrowser(ToolsBase):
|
||||
|
||||
def run(self):
|
||||
# Load browser configuration from YAML file
|
||||
with open("config.yaml", "r") as file:
|
||||
config = yaml.safe_load(file)
|
||||
|
||||
# Check if webdriver is available
|
||||
if not os.path.exists("webdriver.exe"):
|
||||
# Download webdriver based on browser type
|
||||
browser_type = config.get("browser_type")
|
||||
driver = None
|
||||
if browser_type == "chrome":
|
||||
options = webdriver.ChromeOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
webdriver_manager = ChromeDriverManager()
|
||||
driver = webdriver.Chrome(webdriver_manager.install(), options=options)
|
||||
elif browser_type == "firefox":
|
||||
options = webdriver.FirefoxOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
webdriver_manager = GeckoDriverManager()
|
||||
driver = webdriver.Firefox(webdriver_manager.install(), options=options)
|
||||
elif browser_type == "edge":
|
||||
options = webdriver.EdgeOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
webdriver_manager = EdgeChromiumDriverManager()
|
||||
driver = webdriver.Edge(service=EdgeService(webdriver_manager.install()), options=options)
|
||||
elif browser_type == "opera":
|
||||
options = webdriver.ChromeOptions()
|
||||
options.add_argument("--headless") # Enable headless mode
|
||||
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)
|
||||
driver.quit()
|
||||
Reference in New Issue
Block a user