LLM#
A CLI utility and Python library for interacting with Large Language Models, both via remote APIs and models that can be installed and run on your own machine.
Run prompts from the command-line, store the results in SQLite, generate embeddings and more.
Background on this project:
llm, ttok and strip-tags—CLI tools for working with ChatGPT and other LLMs
The LLM CLI tool now supports self-hosted language models via plugins
Accessing Llama 2 from the command-line with the llm-replicate plugin
Build an image search engine with llm-clip, chat with models with llm chat
For more check out the llm tag on my blog.
Quick start#
First, install LLM using pip
:
pip install llm
Or with pipx (recommended, as then it won’t clash with any other installed packages):
pipx install llm
If you have an OpenAI API key key you can run this:
# Paste your OpenAI API key into this
llm keys set openai
# Run a prompt
llm "Ten fun names for a pet pelican"
# Run a system prompt against a file
cat myfile.py | llm -s "Explain this code"
Or you can install a plugin and use models that can run on your local device:
# Install the plugin
llm install llm-gpt4all
# Download and run a prompt against the Orca Mini 7B model
llm -m orca-mini-3b-gguf2-q4_0 'What is the capital of France?'
To start an interactive chat with a model, use llm chat
:
llm chat -m chatgpt
Chatting with gpt-3.5-turbo
Type 'exit' or 'quit' to exit
Type '!multi' to enter multiple lines, then '!end' to finish
> Tell me a joke about a pelican
Why don't pelicans like to tip waiters?
Because they always have a big bill!
>
Contents#
- Setup
- Usage
- Other models
- Embeddings
- Plugins
- Installing plugins
- Plugin directory
- Plugin hooks
- Writing a plugin to support a new model
- The initial structure of the plugin
- Installing your plugin to try it out
- Building the Markov chain
- Executing the Markov chain
- Adding that to the plugin
- Understanding execute()
- Prompts and responses are logged to the database
- Adding options
- Distributing your plugin
- GitHub repositories
- Publishing plugins to PyPI
- Adding metadata
- What to do if it breaks
- Utility functions for plugins
- Model aliases
- Python API
- Prompt templates
- Logging to SQLite
- Related tools
- CLI reference
- Contributing
- Changelog
- 0.12 (2023-11-06)
- 0.11.2 (2023-11-06)
- 0.11.1 (2023-10-31)
- 0.11 (2023-09-18)
- 0.10 (2023-09-12)
- 0.10a1 (2023-09-11)
- 0.10a0 (2023-09-04)
- 0.9 (2023-09-03)
- 0.8.1 (2023-08-31)
- 0.8 (2023-08-20)
- 0.7.1 (2023-08-19)
- 0.7 (2023-08-12)
- 0.6.1 (2023-07-24)
- 0.6 (2023-07-18)
- 0.5 (2023-07-12)
- 0.4.1 (2023-06-17)
- 0.4 (2023-06-17)
- 0.3 (2023-05-17)
- 0.2 (2023-04-01)
- 0.1 (2023-04-01)