How simonw/llm works
LLM is a command-line tool and Python library for running prompts and chats against hosted or local language models. The main workflow starts at the CLI, which resolves a model through the plugin-backed registry, sends a structured prompt to a provider adapter, and presents the response; tool execution and response logging are additional stages. Separate capabilities cover embeddings, templates, schemas, and prompt fragments. The graph preserves major modules named in the source index; unsampled feature wiring is shown only where the README documents it.
Main entry points: cli.py CLI commands · models.py Prompt and chat · openai_models.py OpenAI adapter · plugins.py Plugin loader
Components 19
User interface
- CLI commands
llm/cli.py
Model runtime
- Model registry
llm/__init__.py - Prompt and chat
llm/models.py - Messages and parts
llm/parts.py - OpenAI adapter
llm/default_plugins/openai_models.py - Wire serialization
llm/serialization.py
Plugins and tools
- Plugin loader
llm/plugins.py - Plugin hooks
llm/hookspecs.py - Tool execution
llm/tools.py - Built-in tools
llm/default_plugins/default_tools.py
Persistence
- Conversation logs
llm/logs.py - Log migrations
llm/migrations.py - Embedding collections
llm/embeddings.py - Embedding migrations
llm/embeddings_migrations.py - SQLite database
Content features
- Prompt templates
llm/templates.py - Schema and fragments
llm/utils.py
Other components
- CLI user
- Model provider
Connections 25
- CLI user → CLI commands: runs commands
README.md - CLI commands → Model registry: resolves models
llm/cli.py - Model registry → Plugin loader: loads plugins
llm/__init__.py - Plugin loader → Plugin hooks: registers hooks
llm/plugins.py - Plugin loader → OpenAI adapter: registers adapter
llm/plugins.py - Plugin loader → Built-in tools: registers tools
llm/plugins.py - CLI commands → Prompt and chat: runs prompts
llm/cli.py - Prompt and chat → Messages and parts: uses messages
llm/models.py - OpenAI adapter → Prompt and chat: implements models
llm/default_plugins/openai_models.py - OpenAI adapter → Messages and parts: handles parts
llm/default_plugins/openai_models.py - Prompt and chat → Wire serialization: uses wire types
llm/models.py - Prompt and chat → Tool execution: executes calls
llm/models.py - Built-in tools → Tool execution: uses tool API
llm/default_plugins/default_tools.py - OpenAI adapter → Model provider: sends requests
README.md - CLI commands → Conversation logs: reads and logs
llm/cli.py - Conversation logs → Messages and parts: stores messages
llm/logs.py - Conversation logs → SQLite database: reads and writes
llm/logs.py - CLI commands → Log migrations: runs migrations
llm/cli.py - Log migrations → SQLite database: updates schema
llm/migrations.py - CLI commands → Embedding collections: manages embeddings
README.md - Embedding collections → Embedding migrations: uses migrations
llm/embeddings.py - Embedding collections → SQLite database: stores vectors
llm/embeddings.py - CLI commands → Prompt templates: uses templates
README.md - CLI commands → Schema and fragments: extracts structured data
README.md - CLI commands → Schema and fragments: uses fragments
README.md