Skip to content

clemeth/lm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lm

Command line interface for conversing with language models.

lm [-c context... --] [-i] [-n] [-t] [-f file | instruction | -]

lm command [options] [arguments]

Installation

Install with Cargo:

cargo install --path .

To install the man page:

gzip -c man/lm.1.troff > /usr/local/share/man/man1/lm.1.gz

Examples

# Enter interactive mode
lm

# Quick question in terminal
lm "What is a language model?"

# Read from stdin
echo "Write a hello world program" | lm

# Read instructions from file
lm -f instructions.txt

# Use files as context
lm -c README.md
lm -c src/*.rs -- "Explain this code"

# Start new conversation
lm -n

# Don't save conversation
lm -t "Quick question"

# List conversations
lm ls

# Remove conversation
lm rm 2

# Switch conversation
lm sw 1

# Print conversation messages
lm ll          # last message
lm ll -a       # all messages
lm ll -n 3     # last 3 messages
lm ll -t -n 2  # first 2 messages
lm ll 2        # last message from conversation index 2

# Store API key
lm auth                         # prompts interactively
echo "$MY_API_KEY" | lm auth -  # read from stdin

Configuration

Config file ($XDG_CONFIG_HOME/lm/config.toml):

model = "claude-3-7-sonnet-latest"  # default model
max_tokens = 4096                   # maximum tokens in response

[thinking]
type = "enabled"                    # "disabled" (default) or "enabled"
budget_tokens = 1024                # token limit for thinking (when enabled)

Environment

Environment variables (overrides configuration):

  • LM_ACTIVE: Active conversation file location
  • LM_API_KEY: API key
  • LM_CONFIG: Configuration file location
  • LM_CONVERSATIONS: Conversation directory location
  • LM_CREDENTIALS: Credentials file location
  • LM_HISTORY: Readline history file location

Documentation

See man lm for complete documentation.

About

Language model CLI

Topics

Resources

Stars

Watchers

Forks

Languages