Notebook examples

Notebook examples

START HERE: Starter tools tutorial shows how to insert the 19 default tool declarations and use selected tools in one notebook. Its questions practice with disposable files, a saved notebook, live unsaved cells, and insertion. Copy the editable notebook before trying its AI questions. The lesson includes five real worked answers and observed-tool tables. Turn off Keep answer to try the questions with your connection.

Choose a complete application to see how tools fit together, another walkthrough for a focused lesson, or a Tool catalog notebook for a specific function. The notebooks use disposable inputs and put setup before the calls that depend on it. The Tool catalog links each function to its exact demonstration cell.

The application guide explains receipts, real Python values, and staged AI conversations. The dated notebook audit records earlier example runs and their limits.

The catalog accounts for all 31 notebooks. It includes five complete applications, thirteen introductory walkthroughs, twelve tool-catalog notebooks, and one supporting data notebook. The 30 walkthrough, application, and tool pages form the gallery; the supporting fixture has its own readable page below. Each page links to its editable .ipynb source for download.

The rendered notebook pages show any outputs and AI answers saved in their source files; opening a page does not run the notebook. An observed-tool table beside a saved answer records actual calls, including the five starter-tutorial questions. Keep answer protects saved completed answers; turn it off to request a fresh response. The supporting data fixture has no AI questions.

Ordinary nbinlineai answers do not automatically save a separate tool transcript, and an answer merely suggesting a call does not establish that it ran. Python-only setup needs no provider. To compare an AI edit with a manual edit, use a second disposable copy of the notebook. The second copy keeps the first edit from changing the cells used in the other route.

Work through a notebook

  1. Read a rendered notebook from the gallery below, then get its editable .ipynb from that page’s source link or the GitHub examples folder. Open it in JupyterLab and use File → Save Notebook As… to make a working copy, or duplicate the .ipynb file before opening it. Keep data/ beside the copy when the notebook uses a fixture. For the transforms notebook, keep media/owned-notebook-tab-2087303b97be.webm beside it to run offline.
  2. Run setup code and read the next cell’s instructions. For live browser actions, grant permission or use the visible chooser only when you want that action.
  3. Run one AI question at a time. Inspect the answer and any observed-tool table before using an ID or result in the next question. Keep answers on when you want to preserve a completed tool action.
  4. Run cleanup cells after you finish. They remove disposable files, active media sources, or managed bytes as the notebook specifies.

A browser-media Python call returns a mutable receipt immediately. Its first printed value can say running or waiting_for_user; that is an acknowledgement, not an image, recording, or saved file. Let the browser finish, then run the later inspection cell to read the same receipt’s current status, result, and media. One media-producing operation can return several typed media items.

An AI tool response is an initial snapshot; use operation_status in a later question to learn the terminal result. Status lookup itself returns one snapshot and does not wait. Browser-media foundation explains the receipt and ownership rules.

Run All follows the notebook’s ordinary execution order, but a browser receipt does not hold the kernel until permission, recording, or transfer finishes. Run interactive media calls and their dependent inspection cells separately. A generated insert_code cell remains editable and unexecuted; review it before choosing to run it yourself. The optional Codex ACP exercise uses a separate Jupyter AI chat and begins with an intentional failing diagnostic for you to repair.

Ask after declaring a tool

Import a tool into the live kernel, then put its & reference in an ordinary Markdown declaration above the AI question, or in the question itself. For example:

from nbinlineai.tools import show_doc, tools_markdown
print(tools_markdown(["show_doc"]))

Paste the printed reference into an ordinary Markdown cell with Tools enabled. A later question can ask, “Use show_doc to explain the encoding parameter of Path.read_text and give one short example.” The declaration offers the callable; the question tells the model when to use it. An imported name alone is not offered. Keep the question’s total offered tool and variable names within 20. Variables and tools covers inheritance and live values.

insert_tools(["show_doc"]) can insert an editable declaration below its Python call. It returns an asynchronous receipt and does not call a model; inspect the receipt later and save the notebook to keep the new note. The live variables notebook demonstrates this optional helper.

For the full starter group, run insert_tool_catalog() in a code cell and inspect its receipt in a later cell. The inserted Markdown note offers 19 tools to questions below it while Tools stays on. In the starter lesson, a later AI question calls insert_markdown to create a summary note and insert_code to add a draft. Review the note and code, run the draft yourself if it is sound, and save the notebook. In your own notebook, you can add a following AI question about an inserted note; the new question takes a fresh snapshot when it runs.

Complete applications

These five notebooks include saved AI conversations and Python results from an isolated JupyterLab run. The media applications used a generated canvas and silent audio in that run. Their model answers are real, but the saved media do not show a person, physical screen session, or product defect. Each notebook explains its saved run and any interactive steps you can try. Run browser stages individually when collecting your own media. Rerun the Python report and presentation exporters to create your own local files.

Notebook What you do What you keep
Receipts to real Python values Compare ordinary tool values with browser receipts; turn a completed capture into a usable Pillow image or encoded clip; check AI operation snapshots A reusable pattern for ordinary Python processing
Presenter kit Capture a portrait, talking-head video with sound, screen still/video, and microphone narration; add written notes and assemble slides A local HTML presentation with the captured media
Screen bug report Record a chosen screen/window, capture and mark a still, explicitly attach it for AI review, and add reproduction steps A local evidence report with image/video assets
Data investigation Investigate a small fabricated dataset with live values and tools, check an anomaly, and write the findings An analysis report with visual evidence
Project handoff Trace a method across files and a saved notebook, repair a discrepancy with checked edits, and verify the result A repaired disposable project and handoff report

The presenter kit embeds separate camera and screen assets; it does not mix them into one video. Recorded speech is available for human playback, while authored notes provide the presentation text. Bundled tools do not transcribe recordings. To have a model inspect a still, confirm attach_media for that specific question and then run it. See the application guide for these boundaries.

Walkthroughs

These notebooks develop a task across several cells. The tools column names the functions actually called or offered in each notebook; custom functions and setup helpers are labeled. The application ideas are ways to adapt the demonstrated steps, not extra actions the notebook performs for you.

Start with the starter tools tutorial if you want one route through the default catalog before choosing a specialized notebook.

Notebook Tools shown What you can make/do
Starter tools tutorial insert_tool_catalog() setup helper; selected tools from the 19 default starter declarations. Run the AI exercises on disposable files, a saved notebook, and live unsaved cells. Ask for a Markdown summary and code draft, then review both. Five saved answers and tool tables show the worked run; follow the fresh-run instructions to repeat it.
Quick start Custom add_bonus; live $ value reference. The sample reads a live score and applies a bonus once. Adapt that pattern to a grading what-if, a loyalty-points estimate, or a household budget adjustment whose starting value is still changing in Python.
Context selection Custom average_score; Context preview and Tools checkbox are JupyterLab controls. The sample calculates practice scores while you choose which notes the tutor sees. Reuse the controls for a focused lab-result explanation, a private feedback draft that excludes unrelated notes, or a lesson question grounded in only the relevant cells.
Live variables and tools Custom record_bonus, average_score; insert_tools setup helper. The notebook saves a real bonus call, a mean calculation, and checks of the resulting kernel state. Recreate the setup before rerunning the questions, then adapt the pattern to attendance credits, an experiment tally, or a sales forecast, checking the changed kernel value before the next question.
Socratic learning dialogue No bundled tools; inline AI questions and notebook context. The sample walks a learner through a faulty even-number count. Use the same question-and-revision rhythm for a statistics misconception, a code review exercise, or an exam-practice notebook that preserves each attempt beside the feedback.
Bundled tools search_kernel_names, list_notebooks, find_notebook_cells, read_notebook_cell, insert_code; tools_markdown setup helper. The sample finds a live name and a saved lesson cell, then inserts an unexecuted code draft. Adapt it to recover last week’s data-cleaning method, prepare a missing-values check for a report, or draft a follow-up exercise after reading its earlier notebook.
Live notebook tools list_cells, read_cell, insert_markdown; tools_markdown setup helper. The notebook guides you to make an unsaved edit, run questions that read it, and insert a reviewable field note. Use that flow to annotate a fresh lab observation, add an interpretation beside a chart before a team review, or leave a caveat near an unpublished analysis.
Python and web tools inspect_python, read_url, url_to_note, custom average_alias; tools_markdown setup helper. The sample explains a live averaging function and keeps a public Python reference beside it. Adapt this to write a reproducible method note, check a local calculation against library documentation, or prepare a source-linked teaching handout.
Fastcore tools show_doc, path_info, list_files, view_file, create_file, file_str_replace, file_insert_line, file_replace_lines. The sample documents a small function and edits disposable text files. Adapt it to produce a readable methods note, correct a field-log entry after reviewing its lines, or maintain a short analysis checklist alongside the notebook.
Project tools search_files, search_notebooks, source_doc, document_outline, read_document_section, notebook_outline, file_strs_replace, view_file_hashes, file_replace_checked; tool_catalog setup helper. The sample traces a result across code, a saved notebook, and Markdown, then makes checked edits. Adapt it to audit a reproducibility package, correct a parameter in a shared analysis after review, or assemble evidence for a methods report.
Image from output to question list_outputs, export_output, open_media, close_media, crop_image, save_media, attach_media, operation_status, release_media. The saved run exports, crops, and saves a tiny red output image. It also records an attachment preflight and the final visual answer identifying red. Confirm a fresh attachment before asking about your own image.
Jupyter AI and nbinlineai together insert_code; Jupyter AI chat is a separate UI. The notebook supplies a flower-visit analysis, inline learning questions, and optional prompts for a separate Jupyter AI chat; it does not include a saved chat result. Adapt the division to review a data-cleaning plan in chat, explain a nearby graph inline, or request an unexecuted validation draft for inspection.
Codex ACP worked example No bundled tools; optional Codex ACP persona in Jupyter AI chat. The saved exercise retains a revenue-summary bug and includes inline explanation and learning answers about zero versus missing values. The optional agent-chat repair remains an exercise; rerun setup before trying fresh inline questions. Adapt the pattern to a finance training exercise, a parser bug lesson, or a documented code-review discussion after making the repair yourself.

Jupyter AI’s Codex sign-in is separate from nbinlineai’s model connection. The combined-extension notebooks do not transfer chat history into an inline question automatically.

Tool catalog notebooks

Every public tool has a demonstration in at least one notebook below. Related calls share a notebook when they form one workflow. The tools column also includes demonstrated status and cleanup calls. Direct Python examples and AI questions use the same disposable inputs where both routes exist.

For tools that edit the open notebook, make a second copy with File → Save Notebook As… before the comparison. Use one copy for the AI edit and the other for the manual JupyterLab edit. The Tool catalog links to individual cells.

Python, files, notebooks, and web

Notebook Tools shown What you can make/do
Live Python inspection search_kernel_names, inspect_python, show_doc, api_names, search_docs, inspect_value, search_value, source_files, list_skills, read_skill, trace_function. The sample inspects live values, documentation, source locations, registered skill instructions, and a disposable function trace. Adapt it to explain an unexpected score, choose an API for a data pipeline, or pinpoint a branch in a small parser before documenting a fix.
Saved files and source path_info, list_files, view_file, create_file, file_str_replace, file_insert_line, file_replace_lines, search_files, source_doc, document_outline, read_document_section, file_strs_replace, view_file_hashes, file_replace_checked; tool_catalog setup helper. The sample searches a disposable project and demonstrates checked text edits. Adapt it to prepare a research-code audit, repair a stale configuration in a shared project, or write a concise assumptions file after reading the current source.
Saved notebooks list_notebooks, search_notebooks, notebook_outline, find_notebook_cells, read_notebook_cell. The sample finds and reads source in a saved lesson notebook. Adapt it to build a course reading index, recover an earlier instrument setting from archived field notebooks, or compare a published calculation with an open working copy.
Live notebook cells list_cells, read_cell, find_cells, insert_markdown, insert_code, replace_cell, cell_str_replace, cell_insert_line, cell_replace_lines, delete_cell, move_cell, copy_cell, split_cell, merge_cells; tools_markdown setup helper. The sample finds and edits ordinary cells in the open notebook, including unsaved source. Adapt it to turn rough lab notes into a reviewable report, reorganize a teaching notebook, or draft a checked validation cell that you inspect before running.
Public web pages read_url, read_url_section, url_to_note. The sample reads the public Python tutorial and inserts a bounded, source-linked note. Adapt it to document why an analysis uses a particular method, prepare a coding lesson with cited reference material, or compare a public API description with local behavior.
Local processes run_python, run_shell, tmux_sessions, tmux_read. The sample runs small commands and reads an owned tmux pane. Adapt it to check a saved parser on a fixture, capture a project status for a handoff note, or summarize recent output from an existing training job without changing the job.

Browser media

Browser actions can need a permission choice or a visible control. Their direct calls return receipts to inspect later, and their AI questions use operation_status to check a completed action where shown. The application ideas below require you to perform those visible steps and run dependent cells separately.

The foundation, playback, attachment, transforms, integration, and outputs notebooks ask for the absolute Jupyter server root in setup. Find that folder in Jupyter’s startup log after Serving notebooks from local directory:. If someone else runs the server, ask them for the folder. Enter it even if the notebook’s Python kernel works in a nested folder.

Setup checks the folder and builds media references relative to it. When a tool returns a media reference with a SHA-256 hash, pass that reference unchanged to the next tool; the hash identifies the exact bytes. A local absolute path cannot replace that reference. The receipt example shows a save and later inspection. If you move a notebook or change the server root, rerun setup before using its generated references.

Notebook Tools shown What you can make/do
Browser-media foundation browser_capabilities, save_media, operation_status, cancel_operation, release_media. The tiny PNG is a stand-in for a field or lab still: this notebook saves and verifies its exact copy. In your own workflow, open the saved image with Pillow to crop or measure it, or combine it with attach_media and explicit confirmation to ask a visual AI question.
Camera, microphone, and display list_media_sources, start_camera, capture_camera, start_microphone, read_audio_levels, start_recording, pause_recording, resume_recording, stop_recording, stop_source, record_camera, record_microphone, setup_share, start_share, capture_screen, capture_tool, stop_share, list_outputs, list_canvases, start_canvas, operation_status, release_media. With permission, build a field record from a camera still and spoken observation, capture a chart shown in a chosen window for a class handout, or record a short physical demonstration for later review. Transcription or AI image interpretation would require separate steps; setup_share only displays the local Share control.
Notebook outputs and canvas read_notebook_view, read_selection, list_outputs, read_output, export_output, list_canvases, capture_canvas, export_canvas, start_canvas, stop_source, capture_notebook_region, operation_status, release_media. The sample reads selected text and existing outputs, then captures supported output and canvas views. Adapt it to export a figure for a lab report, quote exact metrics in a results note, or record a changing visualization for a teaching demo.
Import, playback, and clipboard choose_file, open_media, play_media, pause_media, seek_media, set_media_volume, close_media, copy_text, paste_content, operation_status, release_media. The sample imports a chosen image, plays disposable audio, and uses visible clipboard controls. Adapt it to review a recorded pronunciation before a lesson, inspect a local specimen photo, or bring a copied error message into a debugging notebook. Transcribe audio separately if you need searchable words.
Media transformations extract_frames, crop_image, annotate_image, operation_status, release_media. The sample extracts frames and makes cropped and annotated derivatives. Adapt it to compare two moments of a pendulum trial, mark a feature in a microscopy image for a report, or redact a name on a field photo while keeping the original untouched.
Attach an image attach_media, operation_status. The sample confirms one generated still for one identified AI question. Prepare your own chart, diagram, specimen photo, or extracted video frame first; after explicit Attach image confirmation, ask about a trend or visible feature and use the answer in a reviewed report or lesson.

The media guides describe formats, limits, and cleanup for capture, outputs, playback, transforms, and attachment. attach_media confirmation alone does not run a question or call the provider; run the question when you are ready. Real device steps use the media you explicitly choose to share.

Supporting data notebook

Notebook Used by Purpose
Supporting ecosystem fixture (editable source) Bundled tools and other saved-notebook search exercises Four source-only cells with fabricated lichen observations. Keep data/ beside the examples that read it. This is a search fixture with its own readable page, not an executed ecological analysis or a walkthrough.

User guide | Tool catalog | FAQ