Use Mods in your command line
mainmods to 'question' it.repository·main·Indexed 26 days ago
https://github.com/charmbracelet/modsAn AI tool for the command line designed for pipelines. Mods allows users to ingest command output and use LLMs to format, summarize, or transform data into Markdown, JSON, and other formats. It supports multiple providers including OpenAI, Azure OpenAI, Cohere, Groq, Gemini, and LocalAI, and includes features for conversation management, custom roles, and Model Context Protocol (MCP) server integration.
mods to 'question' it.--continue with the title of an existing conversation and provide a new --title. This allows you to create multiple different paths from the same starting point.You can pipe data into mods via STDIN. When doing this, mods will read the piped content and append it to your prompt.
echo 'as json' | mods 'first 2 primes'Mods supports multiple LLM providers. To use them, set the corresponding environment variable:
OPENAI_API_KEY (Defaults to GPT-4, falls back to GPT-3.5 Turbo)AZURE_OPENAI_KEYCOHERE_API_KEYGROQ_API_KEYGOOGLE_API_KEYMods also supports LocalAI running on port 8080 by default. You can configure additional endpoints by running mods --settings to open the settings file.
Manage your conversation history using the following commands:
--list or -l to see previous conversations.--show='title' (exact match required) or --show='id' (the first 4 characters of the ID are sufficient to identify a unique conversation).--delete='title' or --delete='id'. These operations are irreversible. You can use the flag multiple times to delete several conversations at once.# List conversations
mods --list
# or
mods -l
# Show a conversation by title or ID
mods --show='naturals'
mods -s='a2e2'
# Delete conversations (irreversible)
mods --delete='naturals' --delete='a2e2'The simplest way to use mods is to provide a prompt string directly. By default, all messages are sent to STDERR, prompts are saved using the first line of the prompt as the title, and glamour is used for formatting if STDOUT is a TTY.
mods 'first 2 primes'You can install Mods using various package managers depending on your operating system:
yay.nix-shell.apt.yum.go install.If you build from source, you can generate shell completions for Bash, ZSH, Fish, and PowerShell using the mods completion command.
# macOS or Linux
brew install charmbracelet/tap/mods
# Windows (with Winget)
winget install charmbracelet.mods
# Arch Linux (btw)
yay -S mods
# Nix
nix-shell -p mods
# Go
go install github.com/charmbracelet/mods@latestYou can extend your most recent conversation using two different methods:
--continue='new_title' to continue the last conversation and save it under a new name.--continue-last to continue the last conversation without changing the title.# Continue and save with a new title
mods 'first 2 primes'
mods --continue='primes as json' 'format as json'
# Continue the last conversation as-is
mods 'first 2 primes'
mods --continue-last 'format as json'Roles allow you to set system prompts for specific tasks. You can define roles in your settings file using YAML.
Example role definition for a shell expert:
roles:
shell:
- you are a shell expert
- you do not explain anything
- you simply output one liners to solve the problems you're asked
- you do not provide any explanation whatsoever, ONLY the commandTo use the role, pass the --role flag:
mods --role shell list files in the current directoryYou can pipe the output of mods to another program. When STDOUT is not a TTY (e.g., when piping), the "Generating" animation is automatically redirected to STDERR so that only the response is streamed to STDOUT.
echo 'as json' | mods 'first 2 primes' | jq .mods CLI provides a way to interact with GPT models directly from the command line, designed specifically for use in shell pipelines. You can pass prompts as command-line arguments or pipe input from STDIN.You can manage your mods configuration and cache locations using the following commands:
--settings flag to open your configuration file in your default $EDITOR.--reset-settings flag to restore settings to their defaults (this creates a .bak backup of your old config).--dirs flag to see your configuration and cache paths.mods --dirs config: Shows the configuration directory.mods --dirs cache: Shows the cache directory.--list-roles flag to see available custom roles.