Skip to content

LLM plugin to run an IPython interpreter or notebook in the LLM virtual environment and use the LLM from within the interpreter or notebook as a magic function.

License

Notifications You must be signed in to change notification settings

lucasrcezimbra/llm-jupyter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llm-jupyter

PyPI Changelog Tests License

Run a IPython interpreter in the LLM virtual environment

Installation

Install this plugin in the same environment as LLM.

pipx install llm
llm install llm-jupyter

Usage

IPython

This plugin adds a new ipython command to LLM. This executes IPython in the same virtual environment as LLM itself.

You can use this to check the Python version

llm ipython --version
# Should output '8.20.0' or similar

Or to start a IPython shell. In that shell you can import llm and use it to interact with models:

llm ipython
In [1]: %llm 'Who are you?'

# LLM output will be set as the next input
In [2]: print("I am a Python programmer using Jupyter Notebook.")
I am a Python programmer using Jupyter Notebook.

In [3]: %llm --help
usage: __main__.py [-h] [--print] [--model MODEL] [--system SYSTEM] [prompt ...]

positional arguments:
  prompt                Prompt to use

optional arguments:
  -h, --help            show this help message and exit
  --print, -p           Only print the output
  --model MODEL, -m MODEL
                        Model to use
  --system SYSTEM, -s SYSTEM
                        System prompt to use
demo-ipython2x.mp4

Notebook

This plugin also adds a new notebook command to LLM. This executes a Jupyter Notebook in the same virtual environment as LLM itself.

llm notebook
%load_ext llm_jupyter.magic

%llm 'Who are you?'

# LLM output will be set as the next input
print("I am a Python programmer using Jupyter Notebook.")
demo-notebook2x.mp4

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

git clone [email protected]:lucasrcezimbra/llm-jupyter.git
cd llm-jupyter
python -m venv .venv
source .venv/bin/activate
pip install -e .[test]

Now install the dependencies and test dependencies:

llm install -e '.[test]'

To run the tests:

pytest

About

LLM plugin to run an IPython interpreter or notebook in the LLM virtual environment and use the LLM from within the interpreter or notebook as a magic function.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages