Minimal IPython backtick-to-AI extension
Project description
ipyai
ipyai is an IPython extension that turns any input starting with ` into an AI prompt.
It is aimed at terminal IPython, not notebook frontends. Prompts stream through lisette, final output is rendered with rich, and prompt history is stored alongside normal IPython history in the same SQLite database.
Install
pip install ipyai
Load
%load_ext ipyai
If you change the package in a running shell:
%reload_ext ipyai
How To Auto-Load ipyai
ipyai is designed for terminal IPython. To auto-load it, add this to an ipython_config.py file used by terminal ipython:
c.TerminalIPythonApp.extensions = ["ipyai"]
Good places for that file include:
- env-local:
{sys.prefix}/etc/ipython/ipython_config.py - user-local:
~/.ipython/profile_default/ipython_config.py - system-wide IPython config directories
In a virtualenv, the env-local path is usually:
.venv/etc/ipython/ipython_config.py
To see which config paths your current ipython is searching, run:
ipython --debug -c 'exit()' 2>&1 | grep Searching
Usage
Only the leading backtick is special. There is no closing delimiter.
Single line:
`write a haiku about sqlite
Multiline paste:
`summarize this module:
focus on state management
and persistence behavior
Backslash-Enter continuation in the terminal:
`draft a migration plan \
with risks and rollback steps
ipyai also provides a line and cell magic named %ipyai / %%ipyai.
%ipyai commands
%ipyai
%ipyai model claude-sonnet-4-6
%ipyai think m
%ipyai search h
%ipyai code_theme monokai
%ipyai reset
Behavior:
%ipyaiprints the active model, think level, search level, code theme, config path, and system prompt path%ipyai model ...,%ipyai think ...,%ipyai search ...,%ipyai code_theme ...change the current session only%ipyai resetdeletes AI prompt history for the current IPython session and resets the code-context baseline
Tools
To expose a function from the active IPython namespace as a tool for the current conversation, reference it as &\name`` in the prompt:
def weather(city): return f"Sunny in {city}"
`use &`weather` to answer the question about Brisbane
Output Rendering
Responses are streamed directly to the terminal during generation. After streaming completes:
- the stored response remains the original full
lisetteoutput - the visible terminal output is re-rendered with
rich.Markdown - tool call detail blocks are compacted to a short single-line form such as
🔧 f(x=1) => 2
Configuration
On first load, ipyai creates two files under the XDG config directory:
~/.config/ipyai/config.json~/.config/ipyai/sysp.txt
config.json currently supports:
{
"model": "claude-sonnet-4-6",
"think": "l",
"search": "l",
"code_theme": "monokai"
}
Notes:
modeldefaults fromIPYAI_MODELif that environment variable is set when the config file is first createdthinkandsearchmust be one ofl,m, orhcode_themeis passed to Rich for fenced and inline code styling
sysp.txt is used as the system prompt passed to lisette.Chat.
Development
See DEV.md for project layout, architecture, persistence details, and development workflow.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipyai-0.0.1.tar.gz.
File metadata
- Download URL: ipyai-0.0.1.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
816308d629976dd1e91b4e905e76e1d33f7f1322bfa5b4d71ee6bcda8d2ba701
|
|
| MD5 |
e610fa72e6499960e1c7b0dafb3cafe0
|
|
| BLAKE2b-256 |
8dc7c12bba6a85afcf72ac87c58ea58aa8bf7c5bda85a41c9eed2e024dcff175
|
File details
Details for the file ipyai-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ipyai-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
090deaae5c5655eaecebad94153b85a9afb3cd9f7503b52a2bc7a9c35ab96c69
|
|
| MD5 |
83ab97dda0b9c7528cc815595e52ebff
|
|
| BLAKE2b-256 |
7fad4850f558dde71b39d407078bd2190ac313c2bdb97e9a89170f37552ca11e
|