Bromate เป็นโครงการทดลองที่สำรวจความสามารถของเวิร์กโฟลว์ตัวแทนสำหรับการโต้ตอบเว็บเบราว์เซอร์อัตโนมัติ
โบรเมตใช้ประโยชน์จากพลังของโมเดลภาษาขนาดใหญ่ (LLMS) โดยเฉพาะราศีเมถุนของ Google เพื่อทำความเข้าใจคำขอของผู้ใช้ที่แสดงเป็นภาษาธรรมชาติและแปลเป็นชุดของการกระทำที่ทำให้งานการท่องเว็บโดยอัตโนมัติ
มันใช้ซีลีเนียมสำหรับการควบคุมและการโต้ตอบของเบราว์เซอร์ซึ่งนำเสนอวิธีที่ไร้รอยต่อในการทำให้เวิร์กโฟลว์ที่ซับซ้อนภายในสภาพแวดล้อมเว็บเบราว์เซอร์โดยอัตโนมัติ
ก่อนที่จะใช้โบรเมตคุณจะต้องได้รับคีย์ API จาก Google สำหรับ Gemini API คุณสามารถรับคีย์ได้โดยทำตามขั้นตอนเหล่านี้:
การตั้งค่าคีย์ API ใน .env ในระหว่างการพัฒนา:
คุณสามารถตั้งค่าคีย์ API ในไฟล์ .env ในที่เก็บโครงการ:
GOOGLE_API_KEY=YOUR_API_KEY คุณสามารถตรวจสอบว่าคีย์ได้รับการกำหนดค่าโดยพิมพ์ echo $GOOGLE_API_KEY ในเชลล์ของคุณหรือไม่
โบรเมตสามารถใช้ได้กับ PYPI และสามารถติดตั้งได้อย่างง่ายดายโดยใช้ PIP:
pip install bromateในการใช้โบรเมตคุณสามารถจัดทำแบบสอบถามภาษาธรรมชาติที่อธิบายงานที่คุณต้องการทำให้เป็นแบบอัตโนมัติ จากนั้นโบรเมตจะโต้ตอบกับตัวแทน (ราศีเมถุน) เพื่อตีความแบบสอบถามและสร้างลำดับของการกระทำที่จะดำเนินการโดย selenium webdriver
ตัวอย่างที่ 1: สมัครรับจดหมายข่าวชุมชน MLOPS:
bromate "เปิดเว็บไซต์ https://mlops.Community คลิกที่ลิงค์ 'เข้าร่วม' เขียนที่อยู่ '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)โบรเมตทำงานในวงวนการโต้ตอบกับตัวแทนราศีเมถุนและ Selenium WebDriver อย่างต่อเนื่องเพื่อทำงานเบราว์เซอร์โดยอัตโนมัติ นี่คือรายละเอียดของพฤติกรรมหลัก:
1. การเริ่มต้น:
src/bromate/actions.py ตัวอย่าง ได้แก่ :get : เปิด URL เฉพาะในเบราว์เซอร์click : คลิกที่องค์ประกอบที่ระบุโดยตัวเลือก CSSwrite : ป้อนข้อความลงในองค์ประกอบback : นำทางกลับไปที่หน้าก่อนหน้าdone : ส่งสัญญาณการสิ้นสุดของงานอัตโนมัติ2. การเลือกการดำเนินการและการดำเนินการ:
3. ข้อเสนอแนะลูป:
done โดยระบุว่างานจะเสร็จสมบูรณ์หรือถึงจำนวนการโต้ตอบสูงสุดกระบวนการวนซ้ำนี้ช่วยให้โบรเมตสามารถปรับให้เข้ากับการเปลี่ยนแปลงในสภาพแวดล้อมของเบราว์เซอร์และดำเนินงานระบบอัตโนมัติที่ซับซ้อนตามคำแนะนำภาษาธรรมชาติ
เวิร์กโฟลว์การพัฒนาของ Bromate ได้รับการจัดการโดยใช้ Pyinvoke tasks/ โฟลเดอร์มีงานต่าง ๆ สำหรับการจัดการโครงการ:
โบรเมตได้รับใบอนุญาตภายใต้ใบอนุญาต MIT ดูไฟล์ใบอนุญาตสำหรับรายละเอียดเพิ่มเติม