# History core


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

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

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

### hydrate_turns

``` python
def hydrate_turns(
    cfg, turns
):
```

*Restore whole results and prompts from confined details files. A
missing or unreadable file leaves clipped text.*

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

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

### request_title

``` python
def request_title(
    prompt, n:int=80
):
```

*A session’s title from its first request: the first sentence of
[`request_body`](https://vedicreader.github.io/ramabana/history_core.html#request_body),
in at most `n` characters.*

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

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

### request_body

``` python
def request_body(
    prompt
):
```

*[`request_text`](https://vedicreader.github.io/ramabana/history_core.html#request_text)
without the harness’s blocks, or a `<user-request>` tag a prompt cut
short kept.*

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

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

### request_text

``` python
def request_text(
    prompt
):
```

*The person’s request, without the notebook or screen context composed
around it.*

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

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

### labeled_rows

``` python
def labeled_rows(
    rows, legacy_n:int=0, legacy_last:NoneType=None, key:function=<lambda>
):
```

*Yield `(session_id, item)` for each item of `rows` whose row is
`key(item)`, with legacy ids inferred and rows with invalid timestamps
skipped.*

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

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

### history_rows

``` python
def history_rows(
    path, offset:int=0
):
```

*Yield `(start, end, row)` for each complete object row from `offset`.*

A history index skips rows whose timestamps are not numeric.

``` python
rows = [
    (0, 10, {'session': 'bad', 'at': 'later', 'prompt': 'skip me'}),
    (10, 20, {'session': 'kept', 'at': 2, 'prompt': 'Keep this turn'}),
]
indexed = _index_rows(rows)
assert list(indexed) == ['kept']
indexed['kept']
```
