Bromate是一个实验项目,探讨了代理工作流程自动化Web浏览器交互的功能。
Bromate利用大型语言模型(LLMS)的功能,特别是Google的双子座,以了解用自然语言表达的用户请求,并将其转化为一系列自动化Web浏览任务的操作。
它利用硒进行浏览器控制和交互,提供了一种无缝的方式,可以在Web浏览器环境中自动化复杂的工作流程。
在使用Bromate之前,您需要从Google获得Gemini API的API密钥。您可以按照以下步骤获取钥匙:
在开发过程中设置.env中的API键:
您可以在项目存储库中的.env文件中设置API键:
GOOGLE_API_KEY=YOUR_API_KEY您可以通过将echo $GOOGLE_API_KEY在外壳中键入echo $ google_api_key进行检查。
Bromate在PYPI上可用,可以使用PIP轻松安装:
pip install bromate要使用Bromate,您可以提供一个自然语言查询,描述要自动化的任务。然后,Bromate将与代理(Gemini)进行交互以解释查询并生成一系列由Selenium Webdriver执行的操作。
示例1:订阅MLOPS社区通讯:
bromate“打开https://mlops.community网站。单击'join''链接。写地址'hello@mlops'”
示例2:查找最新版本的Python语言:
bromate -interaction.stay_open = false -agent.name“ gemini-1.5-pro-latest”“转到python.org。单击下载页面。单击PEP链接以获取未来的Python版本。总结发布时间表日期。”
bromate -h
usage: bromate [-h] [--agent JSON] [--agent.api_key {SecretStr,null}] [--agent.name str] [--agent.temperature float] [--agent.candidate_count int]
[--agent.max_output_tokens int] [--agent.system_instructions str] [--action JSON] [--action.sleep_time float] [--driver JSON]
[--driver.name {Chrome,Firefox}] [--driver.keep_alive bool] [--driver.maximize_window bool] [--execution JSON] [--execution.stop_actions list[str]]
[--execution.default_message str] [--interaction JSON] [--interaction.stay_open bool] [--interaction.interactive bool] [--interaction.max_interactions int]
QUERY
Execute actions on web browser from a user query in natural language.
positional arguments:
QUERY User query in natural language
options:
-h , --help show this help message and exit
agent options:
Configuration of the agent
--agent JSON set agent from JSON string
--agent.api_key {SecretStr,null}
API key of the agent platform (Google) (default: ********** )
--agent.name str Name of the agent to use (default: gemini-1.5-flash-latest)
--agent.temperature float
Temperature of the agent (default: 0.0)
--agent.candidate_count int
Number of candidates to generate (default: 1)
--agent.max_output_tokens int
Maximum output tokens to generate (default: 1000)
--agent.system_instructions str
System instructions for the agent (default: You are a browser automation system. Your goal is to understand the user request and execute actions
on its browser using the tools at your disposal. After each step, you will receive a screenshot and the page source of the current browser
window.)
action options:
Configuration for all actions
--action JSON set action from JSON string
--action.sleep_time float
Time to sleep after loading a page (default: 0.5)
driver options:
Configuration of the web driver
--driver JSON set driver from JSON string
--driver.name {Chrome,Firefox}
Name of the driver to use (default: Chrome)
--driver.keep_alive bool
Keep the browser open at the end of the execution (default: True)
--driver.maximize_window bool
Maximize the browser window at the start of the execution (default: True)
execution options:
Configuration of the execution
--execution JSON set execution from JSON string
--execution.stop_actions list[str]
Name of actions that can stop the execution (default: [ ' done ' ])
--execution.default_message str
Default message to send to the agent when no input is provided by the user (default: Continue the execution if necessary or call the done tool if
you are done)
interaction options:
Configuration of the interaction
--interaction JSON set interaction from JSON string
--interaction.stay_open bool
Keep the browser open before exiting (default: True)
--interaction.interactive bool
Ask for user input after every action (default: False)
--interaction.max_interactions int
Maximum number of interactions for the agent (default: 5)Bromate在循环中运行,与Gemini代理和Selenium Webdriver连续交互以自动化浏览器任务。这是核心行为的细分:
1。初始化:
src/bromate/actions.py文件中定义的。示例包括:get :在浏览器中打开特定的URL。click :单击CSS选择器标识的元素。write :将文本输入到元素中。back :导航回上一页。done :向自动化任务结束发出信号。2。行动选择和执行:
3。反馈循环:
done操作,表明任务已完成,或者达到最大数量的交互作用。这种迭代过程允许Bromate动态适应浏览器环境的变化,并根据自然语言指令执行复杂的自动化任务。
Bromate的开发工作流程使用Pyinvoke进行管理。 tasks/文件夹包含用于管理项目的各种任务:
Bromate已获得MIT许可证的许可。有关更多详细信息,请参见许可证文件。