Skip to main content

An opinionated way to augment Jupyter Lab for iterative work

Project description

shidoshi

PyPI CI License

An opinionated way to augment Jupyter Lab for iterative work.

shidoshi adds %ask / %%ask magics to Jupyter that let you talk to an LLM from inside a notebook — using the notebook itself, in order, as the conversation history. No separate chat pane, no copy-pasting context: your code cells, their outputs, and your notes are the context.

Install

Requires Python ≥3.13 and JupyterLab. Set an API key before use:

export OPENAI_API_KEY=sk-...       # for the openai provider (default)
export OPENAI_BASE_URL=...         # optional, e.g. to point at a proxy
export OPENROUTER_API_KEY=...      # for the openrouter provider

Installing across Jupyter environments

%load_ext shidoshi runs import shidoshi inside the running kernel process. That means shidoshi has to be installed into whichever Python environment the kernel you're using actually runs in — it is not a standalone CLI, so uvx / uv tool install (which run a tool in an isolated subprocess, separate from any kernel) don't apply here.

  • Per-project venv with its own JupyterLab (e.g. a uv-managed project): add shidoshi as a normal dependency of that project.

    uv add shidoshi
    # or: pip install shidoshi
    
  • One shared JupyterLab, many kernels (each notebook's kernel points at a different project venv registered via ipykernel install): install shidoshi into each kernel's venv. Installing it only where JupyterLab itself lives will not make it importable from other kernels.

    # inside the venv backing a given kernel
    uv add shidoshi
    # or: pip install shidoshi
    
  • Auto-load without typing %load_ext every time: add to ~/.ipython/profile_default/ipython_config.py (create it first with ipython profile create if it doesn't exist):

    c.InteractiveShellApp.extensions = ["shidoshi"]
    

    ~/.ipython is a single directory shared by every Python environment under your $HOME — it is not per-venv. So this line will make every kernel try to load shidoshi at startup, regardless of which venv it's running in. Two ways to keep that safe:

    1. Only add it once shidoshi is installed in every environment you use for Jupyter on that machine, or
    2. Scope it to specific projects: create a named profile (ipython profile create shidoshi), put the extensions line in that profile's config instead of profile_default, and point only the relevant kernel(s) at it (add "--profile=shidoshi" to that kernel's argv in its kernel.json, or install with ipython kernel install --profile=shidoshi ...).

Quickstart

%load_ext shidoshi
%%ask
What does the `history.build_history` function in this file do?

The response streams into the cell's output as Markdown.

Magics reference

  • %ask <prompt> — line magic for a one-line prompt.
    • Prefix with model| or provider:model| to override the configured default model for just this call, e.g. %ask openrouter:openai/gpt-4o|summarize this.
    • Add --debug anywhere on the line to also show the full request/response payload.
  • %%ask [model] — cell magic; the whole cell body is the prompt (multi-line is fine, and it can reference images via Markdown ![]()/<img> syntax or bare local file paths — they're inlined as base64). An optional model name on the magic line overrides the default for this call. Also supports --debug.
  • %%skip — runs the cell normally, but the cell is left out of the context sent to the model entirely. Use it for scratch or exploratory cells you don't want the model to see.
  • %%pin — runs the cell normally; its content and output are always included in context and are exempt from the auto-trim behavior below. Use it to protect a fact, constant, or definition you don't want dropped over a long session.

How context is built

Every prior cell in the notebook — up to the one you're currently running, and accounting for kernel restarts — is turned into conversation history automatically:

  • Markdown cells become background text/image context (treated as notes or reference material, not instructions).
  • Regular code cells appear as fenced code plus their text/image outputs.
  • Prior %ask / %%ask cells become real user/assistant turns. Their responses are reused from a per-cell cache rather than re-sent, so replaying history doesn't resend answers the model already produced.
  • %%skip cells are dropped entirely.
  • %%pin cells are always kept.

Automatic context-length handling

If a request is rejected for exceeding the model's context window, shidoshi automatically retries, dropping the oldest trimmable history units first (markdown cells, then plain code cells, then whole ask+response pairs — %%pin cells are never dropped), up to 20 times. A banner reports how many cells were dropped so you know context shrank.

Providers & tools

  • openai (default) — uses the OpenAI Responses API.
  • openrouter — uses OpenRouter's chat-completions API; select it with the provider:model prefix, e.g. openrouter:anthropic/claude-3.5-sonnet.

Every request currently has the built-in web_search tool attached, so the model can search the web when it needs current information. (A web_fetch tool also exists in the codebase but isn't wired into the magics yet — not available today.)

Debug mode

Add --debug to %ask/%%ask to render a collapsible, syntax-highlighted panel showing exactly what was sent (system prompt, full message history, tools) and every raw event streamed back — useful when the model's behavior is surprising and you want to see the actual payload.

Configuration

shidoshi reads TOML config, layered as defaults → ~/.shidoshi/config.toml./.shidoshi/config.toml (project config overrides user config):

default_model = "gpt-5.5"   # model used when none is specified
reasoning_effort = "low"    # OpenAI only
ask_color = "#eafbea"       # highlight color for %ask/%%ask cells
skip_color = "#ececec"      # highlight color for %%skip cells

Development

uv sync
uv run pytest tests/unit tests/btp -v

Integration tests under tests/integration/ require a live OPENAI_API_KEY (or a proxy via OPENAI_BASE_URL) and are run with:

uv run pytest tests/integration/ -v -m integration

License

Apache License 2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shidoshi-0.0.1.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shidoshi-0.0.1-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file shidoshi-0.0.1.tar.gz.

File metadata

  • Download URL: shidoshi-0.0.1.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shidoshi-0.0.1.tar.gz
Algorithm Hash digest
SHA256 da9c410d80a8856fa00b63ccbba6f227b1f8b39318a7070d7db3d978875531be
MD5 9b113e69c61f9fee38082fc782b1090b
BLAKE2b-256 ae10959f4c4ee9451b91e3b7adc2ce0aca1208d031f29cd1791de423ff92a6ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for shidoshi-0.0.1.tar.gz:

Publisher: publish.yml on tdchaitanya/shidoshi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shidoshi-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: shidoshi-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shidoshi-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f2a8162697389d11152dde272d12b69ceabf3ce1b83b32b64a7521f422c4637
MD5 4d17cf5900594b2bc62c368674bbb8ba
BLAKE2b-256 f4be27575a84e975d64b945a004668ae09003fc4c081abc6c529edd5886ba407

See more details on using hashes here.

Provenance

The following attestation bundles were made for shidoshi-0.0.1-py3-none-any.whl:

Publisher: publish.yml on tdchaitanya/shidoshi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page