nbinlineai.notebook_tools
Live notebook tools dispatched through the authenticated JupyterLab bridge.
find_cells
find_cells(query: str, cell_type: str = '', limit: int = 20) -> strFind live notebook cells containing text, including unsaved edits.
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
str | required | Case-insensitive text to find in live cell sources. |
cell_type |
str | '' |
Optional code, markdown, or raw filter. |
limit |
int | 20 |
Maximum returned matches. |
| returns | str | Bounded matching cell IDs and source previews. |
replace_cell
replace_cell(cell_id: str, expected_source: str, new_source: str) -> strReplace an ordinary cell only when its source still matches.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
expected_source |
str | required | Exact current source required before editing. |
new_source |
str | required | Replacement source, at most 8000 characters. |
| returns | str | Live-model edit acknowledgement. |
cell_str_replace
cell_str_replace(cell_id: str, old_str: str, new_str: str, expected_matches: int = 1) -> strReplace an exact string when its occurrence count matches.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
old_str |
str | required | Exact literal to replace. |
new_str |
str | required | Replacement literal. |
expected_matches |
int | 1 |
Required occurrence count. |
| returns | str | Live-model edit acknowledgement. |
cell_insert_line
cell_insert_line(cell_id: str, line: int, content: str, expected_source: str) -> strInsert content before a line in an unchanged ordinary cell.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
line |
int | required | One-based line before which content is inserted. |
content |
str | required | Text to insert. |
expected_source |
str | required | Exact current source required before editing. |
| returns | str | Live-model edit acknowledgement. |
cell_replace_lines
cell_replace_lines(cell_id: str, start_line: int, end_line: int, content: str, expected_source: str) -> strReplace inclusive source lines in an unchanged ordinary cell.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
start_line |
int | required | First one-based source line, inclusive. |
end_line |
int | required | Last one-based source line, inclusive. |
content |
str | required | Replacement source text. |
expected_source |
str | required | Exact current source required before editing. |
| returns | str | Live-model edit acknowledgement. |
delete_cell
delete_cell(cell_id: str, expected_source: str) -> strDelete an ordinary cell only when its source still matches.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
expected_source |
str | required | Exact current source required before deletion. |
| returns | str | Live-model deletion acknowledgement. |
move_cell
move_cell(cell_id: str, after_cell_id: str) -> strMove an ordinary cell after another cell without executing it.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
after_cell_id |
str | required | Stable anchor ID. |
| returns | str | Live-model move acknowledgement. |
copy_cell
copy_cell(cell_id: str, after_cell_id: str) -> strCopy an ordinary cell after another cell without execution results.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
after_cell_id |
str | required | Stable anchor ID. |
| returns | str | Live-model copy acknowledgement with a new ID. |
split_cell
split_cell(cell_id: str, line: int, expected_source: str) -> strSplit an unchanged ordinary cell before a source line.
| Parameter | Type | Default | Description |
|---|---|---|---|
cell_id |
str | required | Stable ID of an ordinary notebook cell. |
line |
int | required | One-based line beginning the new cell. |
expected_source |
str | required | Exact current source required before splitting. |
| returns | str | Live-model split acknowledgement with a new ID. |
merge_cells
merge_cells(first_cell_id: str, second_cell_id: str, expected_first: str, expected_second: str) -> strMerge adjacent same-type cells when both sources match.
| Parameter | Type | Default | Description |
|---|---|---|---|
first_cell_id |
str | required | Stable ID of the first ordinary cell. |
second_cell_id |
str | required | Stable ID of the adjacent second ordinary cell. |
expected_first |
str | required | Exact current source of the first cell. |
expected_second |
str | required | Exact current source of the second cell. |
| returns | str | Live-model merge acknowledgement. |