Try out the new uq3c5 Ollama Modelfile!
ppwdump turns a prompt into runnable python playwright code and pytest playwright code. It uses Playwright, and Browser-use. This project leverages the power of these libraries to interact with web browsers and generate code for various purposes. ppwdump should now work with Google Gemini, OpenAI compatible providers and Ollama.
ppwdump_demo.mp4
For a more isolated environment, we recommend using a Python virtual environment. If you are on macOS, follow the instructions in the Python_Venv_Install.md file to create and activate a virtual environment using uv and then install the dependencies.
To run this project, you need to have the following dependencies installed:
browser-use
You can install these dependencies using pip:
pip install -r requirements.txtAdditionally, you need to install Playwright's browser binaries by running:
playwright install-
Run the Main Script
The main entry point of the project is
__main__.py. You can run it directly using Python:cd ../ python -m ppwdump -
Customize Configuration
The configuration for the project is located in
config.py. You can modify the following settings:ANONYMIZED_TELEMETRY: Whether to enable anonymized telemetry.BROWSER_MODEL_PROVIDER: Model provider for browser interactions (can be ollama, google, or openai)BROWSER_MODEL: The language model to use for browser interactions.CODE_MODEL_PROVIDER: Model provider for code generation (can be ollama, google, or openai)CODE_MODEL: The language model to use for code generation.OLLAMA_HOST: Host address and port for the Ollama service.GOOGLE_API_KEY: API key for Google's Gemini API.OPENAI_API_KEY: API key for OpenAI compatible providers.OPENAI_BASE_URL: Base URL for the OpenAI compatible provider.USE_VISION: Enable or disable vision feature.HEADLESS: Run the browser in headless mode.
-
Command Line Options
python -m ppwdump [-h] [--no-out] [--pytest] [--history] [--all] [--headless]
Run the main task with optional outputs. Default behavior: output python code
options:
-h, --help: show this help message and exit--no-out: Output nothing--pytest: Output only pytest code--history: Output only history list--all: Output history list, python code and pytest code--headless: Run the browser in headless mode
You can use the ppwdump library directly in your own projects. Here's an example of how to do this:
# example_use.py
import asyncio
from ppwdump import generate_history_list, generate_playwright_code, generate_pytest_playwright_code
async def main():
model_provider = "ollama"
my_browser_model = "msmnew"
my_code_model = "msmnew"
ollama_host = "127.0.0.1:11434"
headless = False
use_vision = True
task = "Goto https://www.ecosia.org. Put Giant Panda in the search box. Click on the search button. Click on the link for the Giant Panda Wikipedia page. Finish."
history_list = await generate_history_list(task, model_provider=model_provider, model=my_browser_model, ollama_host=ollama_host, headless=headless,use_vision=use_vision)
playwright_code_content = await generate_playwright_code(history_list, model_provider=model_provider, model=my_code_model, ollama_host=ollama_host)
print("Playwright Code:\n")
print(playwright_code_content)
pytest_playwright_code = await generate_pytest_playwright_code(playwright_code_content, model_provider=model_provider, model=my_code_model, ollama_host=ollama_host)
print("\nPytest Playwright Code:\n")
print(pytest_playwright_code)
if __name__ == "__main__":
asyncio.run(main())To disable browser-use telemetry, export the ANONYMIZED_TELEMETRY environment variable to "false" in your shell:
- On Windows, run:
set ANONYMIZED_TELEMETRY=false
- On macOS and Linux, run:
export ANONYMIZED_TELEMETRY="false"
Contributions to this project are welcome. Please fork the repository and submit pull requests with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.