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許可證的許可。有關更多詳細信息,請參見許可證文件。