• Stars
    star
    2,261
  • Rank 19,528 (Top 0.4 %)
  • Language
    Go
  • License
    MIT License
  • Created about 1 year ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AI on the command line

Mods!

Mods product art and type treatment
Latest Release Build Status

AI for the command line, built for pipelines.

a GIF of mods running

LLM based AI is really good at interpreting the output of commands and returning the results in CLI friendly text formats like Markdown. Mods is a simple tool that makes it super easy to use AI on the command line and in your pipelines. Mods works with OpenAI and LocalAI

To get started, install Mods and check out some of the examples below. Since Mods has built-in Markdown formatting, you may also want to grab Glow to give the output some pizzazz.

What Can It Do?

Mods works by reading standard in and prefacing it with a prompt supplied in the mods arguments. It sends the input text to an LLM and prints out the result, optionally asking the LLM to format the response as Markdown. This gives you a way to "question" the output of a command. Mods will also work on standard in or an argument supplied prompt individually.

Be sure to check out the examples.

Installation

Mods works with OpenAI compatible endpoints. By default, Mods is configured to support OpenAI's official API and a LocalAI installation running on port 8080. You can configure additional endpoints in your settings file by running mods -s.

OpenAI

Mods uses GPT-4 by default and will fallback to GPT-3.5 Turbo if it's not available. Set the OPENAI_API_KEY environment variable to a valid OpenAI key, which you can get from here.

Mods can also use the Azure OpenAI service. Set the AZURE_OPENAI_KEY environment variable and configure your Azure endpoint with mods -s.

LocalAI

LocalAI allows you to run a multitude of models locally. Mods works with the GPT4ALL-J model as setup in this tutorial. You can define more LocalAI models and endpoints with mods -s.

Install Mods

# macOS or Linux
brew install charmbracelet/tap/mods

# Arch Linux (btw)
yay -S mods

# Debian/Ubuntu
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
sudo apt update && sudo apt install mods

# Fedora/RHEL
echo '[charm]
name=Charm
baseurl=https://repo.charm.sh/yum/
enabled=1
gpgcheck=1
gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
sudo yum install mods

Or, download it:

  • Packages are available in Debian and RPM formats
  • Binaries are available for Linux, macOS, and Windows

Or, just install it with go:

go install github.com/charmbracelet/mods@latest

Saving conversations

All conversations are automatically saved, and can be identified by their latest prompt.

A saved conversation has a SHA1 identifier and a title, similar to how Git works.

Unlike Git, conversations can be updated, keeping their id but having a different title.

Check the examples document for usage examples.

Settings

Mods lets you tune your query with a variety of settings. You can configure Mods with mods -s or pass the settings as environment variables and flags.

Model

-m, --model, MODS_MODEL

Mods uses gpt-4 with OpenAI by default but you can specify any model as long as your account has access to it or you have installed locally with LocalAI.

You can add new models to the settings with mods -s. You can also specify a model and an API endpoint with -m and -a to use models not in the settings file.

Title

-t, --title`

Set a custom save title for the conversation.

Continue last

-C, --continue-last`

Continues the previous conversation.

Continue

-c, --continue

Continue from the last response or a given title or SHA1.

List

-l, --list

Lists all saved conversations.

Show

-s, --show

Show the saved conversation the given title or SHA1.

Delete

--delete

Deletes the saved conversation with the given title or SHA1.

Format As Markdown

-f, --format, MODS_FORMAT

Ask the LLM to format the response as markdown. You can edit the text passed to the LLM with mods -s then changing the format-text value.

Max Tokens

--max-tokens, MODS_MAX_TOKENS

Max tokens tells the LLM to respond in less than this number of tokens. LLMs are better at longer responses so values larger than 256 tend to work best.

Temperature

--temp, MODS_TEMP

Sampling temperature is a number between 0.0 and 2.0 and determines how confident the model is in its choices. Higher values make the output more random and lower values make it more deterministic.

TopP

--topp, MODS_TOPP

Top P is an alternative to sampling temperature. It's a number between 0.0 and 2.0 with smaller numbers narrowing the domain from which the model will create its response.

No Limit

--no-limit, MODS_NO_LIMIT

By default Mods attempts to size the input to the maximum size the allowed by the model. You can potentially squeeze a few more tokens into the input by setting this but also risk getting a max token exceeded error from the OpenAI API.

Include Prompt

-P, --prompt, MODS_INCLUDE_PROMPT

Include prompt will preface the response with the entire prompt, both standard in and the prompt supplied by the arguments.

Include Prompt Args

-p, --prompt-args, MODS_INCLUDE_PROMPT_ARGS

Include prompt args will include only the prompt supplied by the arguments. This can be useful if your standard in content is long and you just a want a summary before the response.

Max Retries

--max-retries, MODS_MAX_RETRIES

The maximum number of retries to failed API calls. The retries happen with an exponential backoff.

Fanciness

--fanciness, MODS_FANCINESS

Your desired level of fanciness.

Quiet

-q, --quiet, MODS_QUIET

Output nothing to standard err.

Reset Settings

--reset-settings

Backup your old settings file and reset everything to the defaults.

No Cache

--no-cache, MODS_NO_CACHE

Disables conversation saving.

HTTP Proxy

-x, --http-proxy, MODS_HTTP_PROXY

Use the HTTP proxy to the connect the API endpoints.

Whatcha Think?

Weโ€™d love to hear your thoughts on this project. Feel free to drop us a note.

License

MIT


Part of Charm.

The Charm logo

Charm็ƒญ็ˆฑๅผ€ๆบ โ€ข Charm loves open source

More Repositories

1

bubbletea

A powerful little TUI framework ๐Ÿ—
Go
23,251
star
2

gum

A tool for glamorous shell scripts ๐ŸŽ€
Go
16,385
star
3

glow

Render markdown on the CLI, with pizzazz! ๐Ÿ’…๐Ÿป
Go
14,499
star
4

vhs

Your CLI home video recorder ๐Ÿ“ผ
Go
13,375
star
5

lipgloss

Style definitions for nice terminal layouts ๐Ÿ‘„
Go
7,073
star
6

soft-serve

The mighty, self-hostable Git server for the command line๐Ÿฆ
Go
4,638
star
7

bubbles

TUI components for Bubble Tea ๐Ÿซง
Go
4,509
star
8

huh

Build terminal forms and prompts ๐Ÿคท๐Ÿปโ€โ™€๏ธ
Go
2,956
star
9

wish

Make SSH apps, just like that! ๐Ÿ’ซ
Go
2,816
star
10

charm

The Charm Tool and Library ๐ŸŒŸ
Go
2,177
star
11

glamour

Stylesheet-based markdown rendering for your CLI apps ๐Ÿ’‡๐Ÿปโ€โ™€๏ธ
Go
2,057
star
12

pop

Send emails from your terminal ๐Ÿ“ฌ
Go
2,044
star
13

log

A minimal, colorful Go logging library ๐Ÿชต
Go
1,901
star
14

skate

A personal key value store ๐Ÿ›ผ
Go
1,167
star
15

wishlist

The SSH directory โœจ
Go
959
star
16

harmonica

A simple, physics-based animation library ๐ŸŽผ
Go
945
star
17

melt

๐ŸงŠ Backup and restore Ed25519 SSH keys with seed words.
Go
418
star
18

kancli

A tutorial for building a command line kanban board in Go
Go
155
star
19

vhs-action

Keep your GIFs up to date with VHS + GitHub actions ๐Ÿ“ฝ๏ธ
TypeScript
141
star
20

keygen

An SSH key pair generator ๐Ÿ—๏ธ
Go
101
star
21

bubbletea-app-template

A template repository to create Bubbletea apps.
Go
99
star
22

inspo

Share and explore projects you can build with Charm libraries
87
star
23

taskcli

A tutorial for building a Taskwarrior-inspired task tracker in Go using glamorous CLI libraries
Go
77
star
24

wizard-tutorial

A basic wizard made with Bubble Tea and Lip Gloss. Follow along with the tutorial video for this project:
Go
73
star
25

tree-sitter-vhs

Syntax highlighting for VHS with tree-sitter ๐ŸŒณ
C
69
star
26

x

Charm experimental packages.
Go
65
star
27

confettysh

confetti over ssh
Go
49
star
28

catwalk

Open source 3D models from Charm ๐Ÿงธ
49
star
29

soft-serve-action

Synchronize GitHub repositories to your Soft Serve instance ๐Ÿฆ
43
star
30

git-lfs-transfer

Server-side implementation of the Git LFS pure-SSH protocol
Go
42
star
31

promwish

Prometheus middleware for Wish
Go
37
star
32

meta

Charm's meta configuration files ๐Ÿซฅ
23
star
33

homebrew-tap

Our homebrew tap ๐Ÿบ
Ruby
21
star
34

scoop-bucket

Charmbracelet Scoop Bucket
14
star
35

nur

Nix
13
star
36

.github

1
star