A lightweight, elegant CLI for AI chat.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
🔮 Local Sage
A lightweight LLM chat interface that embraces the command line.
Local Sage running in Zellij, alongside Helix and Yazi.
About 🔎
Local Sage is an open-source CLI for chatting with LLMs. Not automation, not agents, just pure dialogue.
Featuring live Markdown rendering with inline math conversion for a silky smooth chatting experience. Designed to hook into any OpenAI API endpoint, and tested with local LLMs hosted via llama.cpp.
What else makes Local Sage shine? ✨
- Conversations live in your shell, rendering directly to standard output for persistent history.
- Fancy prompts with command completion and in-memory history.
- Context-aware file management. See the Under the Hood section for more info!
- Small but mighty, below 2000 lines of Python 🐍.
Plus everything you'd expect from a solid chat frontend.
- Session management: load, save, delete, reset, and summarize sessions.
- Profile management: save, delete, and switch model profiles.
- Reasoning/Chain-of-thought support with a dedicated Reasoning panel.
- Context length monitoring, shown through a subtle status panel.
There is also a collection of built-in Markdown themes to choose from to customize your sessions!
Compatibility 🔩
Python 3.10 or later required.
The big three (Linux, macOS, and Windows) are all supported. Ensure your terminal emulator has relatively modern features. Alacritty works well. So does kitty and Ghostty.
You can use non-local models with Local Sage if desired. If you set an API key, the CLI will store it safely in your OS's built-in credential manager via keyring.
Installation 💽
Install a Python package manager for your OS. Both uv and pipx are highly recommended.
For uv, open your terminal and type:
uv tool install localsage
Or, for pipx, type:
pipx install localsage
Type localsage into your terminal to launch the CLI. Type !h to view command usage.
Getting Started ✔️
Configuration is done entirely through interactive commands. You never have to touch a config file.
- Configure a profile with
!profileadd. - Type
!switchto switch to your new profile. - Use
!ctxto set your context length. - (Optional) Set your own system prompt with
!promptor an API key with!key.
Typical API endpoint format: http://ipaddress:port/v1
Tip: If you press tab while at the main prompt, you can access a command completer for easy command use.
Dependencies 🧰
Local Sage is designed with minimal dependencies, keeping the download light and minimizing library bloat.
- Rich - Used extensively throughout. Panels, live rendering, etc.
- prompt_toolkit - Prompts and completers, also used extensively.
- OpenAI - Provides all API interaction as well as the conversation history list.
- keyring - Safely handles API keys on all platforms.
- tiktoken - Provides tokenization and enables context length calculation.
- platformdirs - Detects default directories across operating systems.
- pylatexenc - Absolutely vital for live math sanitization.
File Locations 📁
Your config file, session files, and error logs are stored in your user's data directory.
| OS | Directory |
|---|---|
| Linux: | ~/.local/share/LocalSage |
| macOS: | ~/Library/Application Support/LocalSage |
| Windows: | %localappdata%/LocalSage |
Display Notes 🖥️
Typing into the terminal while streaming is active may cause visual artifacting. Avoid typing into the terminal until the current generation finishes.
A monospaced Nerd font is HIGHLY recommended. It ensures that Markdown, math, and icons all align well on-screen. The main prompt uses a Nerd font chevron.
Under the Hood 🛠️
Context-Aware File Management
If you re-attach a file, context consumption is massively reduced by removing the original file from the conversation history and then appending the new copy. Removing an attachment (via the !purge command) will fully refund its context consumption.
Rendering & Streaming (For Technical Users)
At its core, Local Sage uses the Rich library combined with a custom math sanitizer to render live Markdown and readable inline math. Chunk processing is frame-synchronized to the refresh rate of a rich.live display, meaning that the entire rendering process occurs at a customizable interval. Effectively a hand-rolled, lightweight, synchronized rendering engine running right in your terminal.
You can adjust the refresh rate using the !rate command (30 FPS by default).
Limitations 🛑
Once the live panel group fills the terminal viewport, real-time rendering cannot continue due to terminal constraints. By default, the Response panel consumes the Reasoning panel to conserve space (toggleable with the !consume command).
This should only be noticeable on large responses that consume over an entire viewport's worth of vertical space.
Local Sage is text-only. This limitation keeps Local Sage portable, lightweight, and backend-agnostic.
Local Sage will only ever store one API key in your keychain. If you switch providers often, you will have to swap your API key with !key.
Versioning 🔧
The project follows basic versioning:
- 1.0.x - Minor patches consisting of bug fixes and aesthetic tweaks.
- 1.x.0 - Major patches consisting of feature expansions or necessary refactors.
Current version: 1.1 - Featuring a full architectural refactor, a fix for a pesky keyring exception, and command name adjustments for better UX.
License ⚖️
Local Sage is released under the MIT License.
Closing Notes 🫵
Local Sage is an open-source, single-dev project built purely for the love of the game. Please be kind!
Contributions are always welcome! See Contributing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file localsage-1.1.1.tar.gz.
File metadata
- Download URL: localsage-1.1.1.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51c6b48cc4e005f5f66918a02caf21fd9d26296b21fbe5342056e986989bfaee
|
|
| MD5 |
82e2fddf79ac8d7a63e0e8067ecb5e34
|
|
| BLAKE2b-256 |
895e61fa8d0fcae4f6b472e8c769b31dbedd9f296dbf4caa93adcfedaf23ef88
|
Provenance
The following attestation bundles were made for localsage-1.1.1.tar.gz:
Publisher:
python-publish.yml on Kyleg142/localsage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
localsage-1.1.1.tar.gz -
Subject digest:
51c6b48cc4e005f5f66918a02caf21fd9d26296b21fbe5342056e986989bfaee - Sigstore transparency entry: 724642060
- Sigstore integration time:
-
Permalink:
Kyleg142/localsage@574ceb2d54cc6106303d26f886a6df6a30c0918f -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/Kyleg142
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@574ceb2d54cc6106303d26f886a6df6a30c0918f -
Trigger Event:
release
-
Statement type:
File details
Details for the file localsage-1.1.1-py3-none-any.whl.
File metadata
- Download URL: localsage-1.1.1-py3-none-any.whl
- Upload date:
- Size: 26.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32fcedd13f9cb2039b23b59dd7d42571bf0525c52bf8c7c478de635fbe7adb50
|
|
| MD5 |
f78f4331ce335a8463c9db9a6d40efc9
|
|
| BLAKE2b-256 |
e3c6d38083e214e092733ecab4c92531c5ffb444a59944a903bfb4be7f96b70d
|
Provenance
The following attestation bundles were made for localsage-1.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on Kyleg142/localsage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
localsage-1.1.1-py3-none-any.whl -
Subject digest:
32fcedd13f9cb2039b23b59dd7d42571bf0525c52bf8c7c478de635fbe7adb50 - Sigstore transparency entry: 724642065
- Sigstore integration time:
-
Permalink:
Kyleg142/localsage@574ceb2d54cc6106303d26f886a6df6a30c0918f -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/Kyleg142
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@574ceb2d54cc6106303d26f886a6df6a30c0918f -
Trigger Event:
release
-
Statement type: