# Convert CAI-logs to  walkthroughs to be loaded on Pentest-R1


## Overview

This tool converts CAI logs with "history from jsonl format" into pentestR1 "walkthroughs" files. Then is possible to load the CAI walkthroughs  on pentest-R1 and convert the files to the final text string for embeddings. The "history from jsonl format" of CAI were generated using the function in dataset.py

```python
messages = cai.sdk.agents.run_to_json.load_history_from_jsonl(jsonl_path, system_prompt=True)
```
---

## Quick Start

These commands use the paths in dev container where the main repository of cai is in /workspace folder

1. Find the path logs of caiextensions-memory. A logs.txt file will be generated in the  current folder.

    ```sh
    bash findjsonl.sh --path /path/to/caiextensions/caiextensions-memory
    ```

2. Convert CAI-messages to walkthroughs with datasets.py. a folder called data with a subfolder called walkthroughs will be created.
    ```sh
    python3 /workspace/datasets/dataset.py --logs-path logs.txt --num-logs 5 --walkthroughs
    ```
    *Note:  --num-logs optional parameter


4.  Run the load function of pentest r1 to visualize the CAI walkthrough in pentest-r1 step format:

    ```sh
    python load_to_pentestr1.py
    ```

