What is ipyllm? Link to heading
ipyllm is an IPython extension that lets you talk to any model supported by the llm Python package from inside the running shell. The model doesn’t get a paste — it gets a set of tools that can see your variable names and types, inspect a specific object, read your recent input history, and — with your permission — run code in the live namespace, so it can act on the exact DataFrame, plot, or half-built object you’re looking at.
Please refer to earlier blog posts for a detailed description and uses cases.
What’s new in 0.6 and 0.5 Link to heading
We bring features that bring the ipyllm experience closer to modern coding agents. Namely,
New fuzzy file search, semantic output color, a config file that remembers your preferences, and live token accounting.
Fuzzy file search: type @@, hit TAB, get the file
Link to heading
You can already reference local files in a prompt with @path — code, Markdown, CSV, images, PDFs, even a whole directory — and @ autocompletes names one folder at a time. The friction was: what’s the exact path?
Now you don’t need it. Type @@ at the start of a word, follow it with a loose query — a few letters, a typo, or several words — and press TAB:
%llm @@cust data<TAB> What columns does the customer data have?
# -> %llm @data/customer_data.csv What columns does the customer data have?
@@ triggers a fuzzy search across the entire current directory tree, and the best match replaces your loose query with a clean @ reference that %llm resolves as a file. It’s powered by rapidfuzz (WRatio scoring), skips directories you never want to see like .git, __pycache__, and node_modules, and an empty @@ just lists the first entries of the tree so you can browse.
When you’ll feel it: on big repos, after git checkout, or when the file you’re about to ask about is three levels deep and you only remember a fragment of its name. One tab replaces four ls calls.
Semantic color: the working dimmed, the answer bright Link to heading
A long model response used to be one wall of text: the model’s internal reasoning, the raw output of each tool call it ran, and its actual answer all in the same style, hard to tell apart when it scrolled by.
ipyllm now uses color to separate the semantics of what you’re reading:
- The model’s reasoning/thought is shown in dim text.
- Intermediate tool results (e.g.
· execute_code: ...) are shown in dim text, truncated so they don’t drown the answer. - The final answer is in the normal, full-contrast foreground.
Styling is emitted only when the output is a real terminal. If you pipe the session, set NO_COLOR, or run in an environment without a TTY, everything degrades to clean plain text automatically. FORCE_COLOR overrides if you want it on anyway.
When you’ll feel it: the moment a prompt triggers several tool rounds. You can now glance at a response and instantly see where the answer starts and how much of what you’re looking at is just the model thinking out loud.
A config file that remembers: .ipyllmrc
Link to heading
Previously you set a model and an approval preference with flags, and you did it again next session. 0.6 adds a small INI-style config file that loads automatically at startup.
ipyllm looks for .ipyllmrc in your current directory first, then in your home directory, and uses whichever it finds first (a project-level file wins over a global one). Missing entries keep their defaults, so the file only needs the settings you actually care about:
[ipyllm]
model = ollama/llama3
require_approval = on
debug = off
save_session = off
chain_limit = 10
Recognized keys (all optional): model, require_approval (on/off), debug (on/off), save_session (a file path or off), and chain_limit (a positive integer). The [ipyllm] header is optional — a flat key = value file works too — and keys/booleans are case-insensitive.
In addition:
- An invalid or unrecognized entry is reported to
stderrand skipped. A typo in the file will never prevent IPython from starting. - Tweak a setting live with
%llm --model …,%llm --approval …, etc., then persist it:
%llm --save-config # writes ./.ipyllmrc
%llm --save-config ~/.ipyllmrc
and %llm --config will tell you which file the settings were loaded from (or defaults).
Live token accounting: --tokens
Link to heading
Cost and context-window pressure are the two things people most often miss until the provider bills them. ipyllm now tracks usage, read directly from the provider via the llm API.
After every prompt, a dim line reports the tokens that prompt used and the running session total:
tokens · last prompt: 351 (327 in, 24 out) · session: 702 (654 in, 48 out) · model: gpt-4o
A few details that matter:
-
“last prompt” sums every model round it triggered — a prompt that makes tool calls counts all of its rounds, not just the final one.
-
Per-model totals are kept separately. Switch with
%llm --modeland each model keeps its own running total. -
Review them anytime with:
%llm --tokensToken usage for this session: gpt-4o: 702 tokens (654 in, 48 out) over 2 prompt(s) claude: 120 tokens (110 in, 10 out) over 1 prompt(s)
Providers that don’t report usage show 0, and totals survive %llm --reset (they’re a session meter, not part of the conversation).
A note on safety Link to heading
ipyllm is transparent about the two things that matter here:
- Execution is not sandboxed. Model-requested code runs in your IPython process with your permissions — files, network, session objects. Approval is a review step, not a security boundary.
- What you reference is what’s sent. File contents, command output, and error tracebacks included in a prompt are sent to the model provider. Review sensitive files and your provider’s data handling before you point them at anything private.
Further details in the online documentation and the blog.