nbinlineai.notebook_tools

Live notebook tools dispatched through the authenticated JupyterLab bridge.

find_cells

source

find_cells(query: str, cell_type: str = '', limit: int = 20) -> str

Find 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

source

replace_cell(cell_id: str, expected_source: str, new_source: str) -> str

Replace 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

source

cell_str_replace(cell_id: str, old_str: str, new_str: str, expected_matches: int = 1) -> str

Replace 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

source

cell_insert_line(cell_id: str, line: int, content: str, expected_source: str) -> str

Insert 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

source

cell_replace_lines(cell_id: str, start_line: int, end_line: int, content: str, expected_source: str) -> str

Replace 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

source

delete_cell(cell_id: str, expected_source: str) -> str

Delete 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

source

move_cell(cell_id: str, after_cell_id: str) -> str

Move 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

source

copy_cell(cell_id: str, after_cell_id: str) -> str

Copy 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

source

split_cell(cell_id: str, line: int, expected_source: str) -> str

Split 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

source

merge_cells(first_cell_id: str, second_cell_id: str, expected_first: str, expected_second: str) -> str

Merge 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.