Run these cells in order in a disposable JupyterLab project. The setup asks for the absolute Jupyter server root and checks that it exists and contains this kernel’s working folder before making server-root-relative file references. Enter the folder JupyterLab serves, even when this notebook and its kernel are in a nested folder. Use a live kernel.
Tool catalog: file, playback, and clipboard
Run these cells in order in a disposable JupyterLab project. The setup asks for the absolute Jupyter server root and checks that it exists and contains this kernel’s working folder before making server-root-relative file references. Enter the folder JupyterLab serves, even when this notebook and its kernel are in a nested folder. Use a live kernel.
The blue PNG and quiet 60-second WAV are generated inputs. The longer clip gives you time to try the playback controls.
Click the file picker, Play, Copy, or paste control when it appears; no browser can perform those user actions silently. Each call returns an immediate receipt, so inspect it on a later turn after the media row completes. The AI questions ask the selected ChatGPT connection to make real, scoped tool calls. Do not run all cells at once.
The saved AI answers below show real browser tool calls and later receipts. Their operation and preview IDs belong to those recorded runs; run the fixture setup to create fresh references in your own session.
Disposable exact media references
from pathlib import Path, PurePosixPath
from uuid import uuid4
import hashlib, math, struct, wave
from PIL import Image
from nbinlineai.tools import (choose_file, open_media, play_media, pause_media, seek_media, set_media_volume, close_media, copy_text, paste_content, operation_status, release_media)
from IPython.display import display, Audio
root_text =input('Absolute Jupyter server root (the folder served by JupyterLab): ').strip()
root_choice = Path(root_text).expanduser()
ifnot root_choice.is_absolute():
raiseValueError('Enter an absolute Jupyter server-root folder; do not use the kernel working directory as a guess.')
server_root = root_choice.resolve(strict=True)
ifnot server_root.is_dir() ornot Path.cwd().resolve().is_relative_to(server_root):
raiseValueError('The server root must be an existing folder containing this kernel working directory.')
defserver_ref(path):
"""Make a server-root-relative path for an owned file or save destination."""
target = Path(path).resolve()
return target.relative_to(server_root).as_posix()
defserver_file(reference):
"""Map a server-returned relative path to the configured local root."""ifnotisinstance(reference, str) ornot reference or'\\'in reference:
raiseValueError('Expected a server-root-relative media path.')
relative = PurePosixPath(reference)
if relative.is_absolute() or relative.as_posix() != reference or reference =='.'or'..'in relative.parts:
raiseValueError('Media path must be a clean server-root-relative path.')
candidate = server_root / reference
ifnot candidate.resolve().is_relative_to(server_root):
raiseValueError('Media path escapes the configured server root.')
return candidate
nonce = uuid4().hex
image_path = Path.cwd() /f'playback-{nonce}.png'
tone_path = Path.cwd() /f'playback-{nonce}.wav'
Image.new('RGB', (2, 2), (36, 112, 195)).save(image_path)
with wave.open(str(tone_path), 'wb') as output:
output.setnchannels(1); output.setsampwidth(2); output.setframerate(16000)
output.writeframes(b''.join(struct.pack('<h', int(1200* math.sin(2* math.pi *440* i /16000))) for i inrange(60*16000)))
image_ref = {'path': server_ref(image_path), 'sha256': hashlib.sha256(image_path.read_bytes()).hexdigest()}
tone_ref = {'path': server_ref(tone_path), 'sha256': hashlib.sha256(tone_path.read_bytes()).hexdigest()}
print('Generated quiet 60-second 440 Hz WAV:', tone_path.name)
print('Generated blue PNG:', image_path.name)
display(Image.open(image_path).resize((80, 80)))
display(Audio(filename=str(tone_path), normalize=False))
from nbinlineai.tools import choose_file
selected = choose_file(accept='image/png')
selected # In the visible chooser select only the generated playback-*.png sample.
Use &choose_file with accept='image/png' so I can select this notebook’s generated blue PNG in the visible picker. Report the immediate operation ID/state only; do not choose a personal file or claim a hash before selection completes.
After I select the generated PNG, use &operation_status on the choose_file operation ID. Report actual MIME type, SHA-256, and managed media ID only if completed; otherwise retry later.
Completed. MIME type: image/png; SHA-256: 15718af7fc5d8f1378cbbaf994dbb1a135c5e28ed8ff9550efacd6f3d89cd251; managed media ID: eFXuClHYeeCAfxqUKeRbOp5uW7lAI-HK.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Completed. MIME type: image/png; SHA-256: 15718af7fc5d8f1378cbbaf994dbb1a135c5e28ed8ff9550efacd6f3d89cd251; managed media ID: eFXuClHYeeCAfxqUKeRbOp5uW7lAI-HK.
Use &release_media only on the managed media ID from the completed AI file-choice status. Report the immediate release operation ID/state; the displayed Python image remains available.
Open preview: completed None
Preview ID: f4580ddc708d7c6804c1d03990d961b8
Use &open_media with the exact quiet 60-second WAV reference $tone_ref. Report its immediate operation ID/state; do not claim a preview ID until the later status question confirms it.
Use &operation_status on the AI open_media operation ID after completion. Report its actual preview ID and media type; if still running, stop and retry later.
Completed. Preview ID: 44ef42ce41fe6b14e9b5604875f41f64; media type: audio.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Completed. Preview ID: 44ef42ce41fe6b14e9b5604875f41f64; media type: audio.
Use &close_media only on the new preview ID from the preceding completed AI open status. Report the close operation ID/state; leave the direct Python preview open for later controls.
Close operation ID: TWwFSCAgAt46VSDSQ85JgoquXAKuWtza; state: running. The direct Python preview was not targeted.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
The close operation completed (closed: true). Only the extra AI preview was targeted; the direct Python preview was not.
play_media
from nbinlineai.tools import play_media
assert opened.status =='completed', 'Wait for the preview, then rerun this cell.'
playing = play_media(opened.result['preview_id'])
playing # Click Play in the visible panel if the browser requires activation.
Use &play_media on the direct preview ID $preview_id. Report its immediate operation ID/state. I will click the visible Play control if the browser waits for activation.
Operation ID: kA9hy4CPboxoQQ6Rz2axfW-W_0ens9zx; state: waiting_for_user. Click the visible Play control to activate playback.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Operation ID: kA9hy4CPboxoQQ6Rz2axfW-W_0ens9zx; state: waiting_for_user. Click the visible Play control to activate playback.
After any visible Play click, use &operation_status on that play_media operation ID. Report actual playback state only if completed; otherwise retry later.
Completed: playback is active (playing: true, at 0.11235 seconds).
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Use &seek_media on preview ID $preview_id at 2.5 seconds of the generated 60-second tone. Report its immediate operation ID/state, not the final actual position.
Use &operation_status on that seek_media operation ID after completion. Report actual position, which can differ slightly from the requested 2.5 seconds.
Seek completed. Actual position: 2.5 seconds.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Use &operation_status on that set_media_volume operation ID. Report the actual result or browser restriction without claiming the volume changed if it did not.
Completed: the volume was set to 0.25.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Close preview: completed {'closed': True} None
Release selected PNG: completed None
Original 60-second WAV remains: True
copy_text
from nbinlineai.tools import copy_text
copied = copy_text('nbinlineai disposable playback sample')
copied # Click the visible Copy button or use the browser copy shortcut.
After I click Copy, use &operation_status on that copy_text operation ID. Report the actual terminal state; do not claim success from an initial waiting snapshot.
Completed: text copied via the browser (copied: true).
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Completed: text copied via the browser (copied: true).
paste_content
In the saved AI Paste run, the operator seeded the CUA test clipboard with the exact disposable sample, then pasted into the visible browser field. The preceding Copy result was verified separately; the Paste example does not claim those bytes were transferred from Copy.
from nbinlineai.tools import paste_content
pasted = paste_content(accept='text')
pasted # Click the visible paste box and paste the sample text.
Use &paste_content with accept='text'. Report its immediate operation ID/state. Ask me to paste the disposable sample into the visible paste box; do not read the clipboard silently.
Operation ID: 7j7_4gFEIJDXZeIbz3svsFIx2A5h7UYS; state: waiting_for_user. Please paste the disposable sample into the visible paste box.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).
Operation ID: 7j7_4gFEIJDXZeIbz3svsFIx2A5h7UYS; state: waiting_for_user. Please paste the disposable sample into the visible paste box.
After I paste the disposable text, use &operation_status on that paste_content operation ID. Quote only its actual bounded returned text and truncation flag if completed; otherwise retry later.
Completed. Returned text: nbinlineai disposable playback sample; truncated: false.
Observed live tool call for the answer above (isolated JupyterLab and ChatGPT subscription).