Bromate es un proyecto experimental que explora las capacidades de los flujos de trabajo de los agentes para automatizar las interacciones del navegador web.
Bromate aprovecha el poder de los modelos de idiomas grandes (LLM), específicamente los Géminis de Google, para comprender las solicitudes de los usuarios expresadas en lenguaje natural y traducirlos en una serie de acciones que automatizan tareas de navegación web.
Utiliza selenio para el control y la interacción del navegador, ofreciendo una forma perfecta de automatizar flujos de trabajo complejos dentro de un entorno de navegador web.
Antes de usar Bromate, debe obtener una clave API de Google para la API de Gemini. Puede obtener una clave siguiendo estos pasos:
Establecer la clave API en .env durante el desarrollo:
Puede establecer la clave API en un archivo .env en el repositorio del proyecto:
GOOGLE_API_KEY=YOUR_API_KEY Puede verificar si la clave está configurada escribiendo echo $GOOGLE_API_KEY en su shell.
Bromate está disponible en PYPI y se puede instalar fácilmente utilizando PIP:
pip install bromatePara usar Bromate, puede proporcionar una consulta de lenguaje natural que describe la tarea que desea automatizar. Bromate luego interactuará con el agente (Géminis) para interpretar la consulta y generar una secuencia de acciones que se ejecutará por Selenium WebDriver.
Ejemplo 1: Suscribirse al boletín de MLOPS Community:
Bromate "Abra el sitio web https://mlops.community. Haga clic en el enlace 'unirse'. Escriba la dirección 'Hello@Mlops'"
Ejemplo 2: Encuentre la última versión del idioma Python:
bromate--interacción.stay_open = false --agent.name "Gemini-1.5-pro-Latest" "Vaya a python.org. Haga clic en la página Descargas. Haga clic en el enlace PEP para la versión futura de Python. Resume las fechas del horario de lanzamiento".
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 opera en un bucle, interactuando continuamente con el agente Gemini y el Selenium WebDriver para automatizar las tareas del navegador. Aquí hay un desglose del comportamiento central:
1. Inicialización:
src/bromate/actions.py . Los ejemplos incluyen:get : Abra una URL específica en el navegador.click : haga clic en un elemento identificado por un selector CSS.write : Ingrese el texto en un elemento.back : Navegue de regreso a la página anterior.done : señalar el final de la tarea de automatización.2. Selección y ejecución de la acción:
3. Bucle de retroalimentación:
done , lo que indica que la tarea está completa o se alcanza un número máximo de interacciones.Este proceso iterativo permite que el bromato se adapte dinámicamente a los cambios en el entorno del navegador y realice tareas de automatización complejas basadas en instrucciones del lenguaje natural.
El flujo de trabajo de desarrollo de Bromate se gestiona con Pyinvoke. Las tasks/ carpetas contienen varias tareas para administrar el proyecto:
Bromate tiene licencia bajo la licencia MIT. Consulte el archivo de licencia para obtener más detalles.