# history


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/vedicreader/ramabana/blob/main/ramabana/history.py#L20"
target="_blank" style="float:right; font-size:smaller">source</a>

### History

``` python
def History(
    cfg:NoneType=None, # config folder; None uses the folder containing `config_path()`
    history_name:str='agent', # history file prefix
):
```

*Read turn logs and memory without changing them.*

`sessions` lists each conversation in a log, newest first. The example
writes a log of two conversations into a temporary config folder and
reads it back with
[`History`](https://vedicreader.github.io/ramabana/history.html#history).

``` python
import tempfile
```

``` python
cfg = Path(tempfile.mkdtemp())
rows = [{'at': 1, 'session': 'a', 'prompt': 'Fix the parser. Then test it.', 'model': 'gpt-mini'},
        {'at': 2, 'session': 'a', 'prompt': 'Run the tests.', 'model': 'gpt-mini'},
        {'at': 3, 'session': 'b', 'prompt': 'Explain the index', 'model': 'gpt-mini'}]
(cfg/'agent-history.jsonl').write_text(''.join(json.dumps(r) + '\n' for r in rows))
before = sorted(p.name for p in cfg.iterdir())
History(cfg).sessions()
```

Reading creates no file in the config folder, not even the session
index.

``` python
assert sorted(p.name for p in cfg.iterdir()) == before
before
```
