An open API service indexing awesome lists of open source software.

https://github.com/ascotai/ppwdump

ppwdump turns an ollama prompt into runnable python playwright code and pytest playwright code.
https://github.com/ascotai/ppwdump

browser-automation browser-use ollama playwright pytest python

Last synced: about 1 month ago
JSON representation

ppwdump turns an ollama prompt into runnable python playwright code and pytest playwright code.

Awesome Lists containing this project

README

        

# ppwdump

## Description

`ppwdump` is a Python-based tool designed to automate browser tasks using Playwright, Langchain-ollama, and Browser-use. This project leverages the power of these libraries to interact with web browsers and generate code for various purposes.

## Installation Using Virtual Environment

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](Python_Venv_Install.md) file to create and activate a virtual environment using `uv` and then install the dependencies.

## Requirements

To run this project, you need to have the following dependencies installed:

```plaintext
playwright
langchain-ollama==0.3.0
browser-use
```

You can install these dependencies using pip:

```bash
pip install -r requirements.txt
```

**Note:** Currently, in order for `browser-use` to work with `ollama`, version 0.3.0 of `langchain-ollama` must be installed. To do this, first uninstall `langchain-ollama` with pip:

```bash
pip uninstall langchain-ollama
```

Then, install the specific version:

```bash
pip install langchain-ollama==0.3.0
```

Additionally, you need to install Playwright's browser binaries by running:

```bash
playwright install
```

## Usage

1. **Run the Main Script**

The main entry point of the project is `__main__.py`. You can run it directly using Python:

```bash
python -m ppwdump
```

2. **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.
- `LLM_MODEL`: The language model to use.
- `LLM_BASE_URL`: The base URL for the language model.
- `LLM_NUM_CTX`: The number of context tokens.

3. **Browser Configuration**

The browser configuration is handled in `browser_utils.py`. You can customize the browser settings, such as the path to the Chrome instance, by modifying the `BrowserConfig` object.

## Code Generation

The project includes functions for code generation:

- `generate_playwright_code(history_list)`: Generates Playwright code based on a history list.
- `generate_pytest_playwright_code(playwright_code)`: Generates PyTest code for Playwright scripts.

These functions are located in `code_generation.py`.

## Disable Telemetry

To disable browser-use telemetry, export the `ANONYMIZED_TELEMETRY` environment variable to `"false"` in your shell:
- On Windows, run:
```cmd
set ANONYMIZED_TELEMETRY=false
```
- On macOS and Linux, run:
```bash
export ANONYMIZED_TELEMETRY="false"
```

## Contributing

Contributions to this project are welcome. Please fork the repository and submit pull requests with your changes.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.