DebGPT -- General Purpose Terminal LLM Tool with Some Debian-Specific Design
Project description
% DebGPT(1) | General Purpose Terminal LLM Tool with Some Debian-Specific Design % Copyright (C) 2024-2025 Mo Zhou lumin@debian.org; GNU LGPL-3.0+ License.
NAME
DebGPT - General Purpose Terminal LLM Tool with Some Debian-Specific Design
"AI" = "Artificial Idiot"
SYNOPSIS
debgpt [arguments] [subcommand [subcommand-arguments]]
DESCRIPTION
DebGPT is a lightweight terminal tool designed for everyday use with Large Language Models (LLMs), aiming to explore their potential in aiding Debian/Linux development. The possible use cases include general language understanding and editing, code generation, writing documentation, code editing, and more as you can imagine.
To achieve that, DebGPT gathers relevant information from various sources like
files, directories, and URLs, and compiles it into a prompt for the LLM. DebGPT
supports a range of LLM backends, both self-hosted and third-party,
including any OpenAI-API compatible service (via the openai frontend),
Anthropic, Google Gemini, and ZMQ
(DebGPT's built-in backend for self-containment).
TABLE OF CONTENTS
- NAME
- SYNOPSIS
- DESCRIPTION
- QUICK START
- FRONTENDS
- TUTORIAL
- TROUBLESHOOTING
- BACKENDS
- REFERENCES
- LICENSE and ACKNOWLEDGEMENT
QUICK START
First, install DebGPT from PyPI or Git repository:
pip3 install debgpt
pip3 install git+https://salsa.debian.org/deeplearning-team/debgpt.git
The recommended way to get started is the TUI-based configuration wizard, which
walks you through selecting a frontend and providing credentials. If you already
have an API key handy, you can skip the wizard and set the environment variable
directly (e.g., export OPENAI_API_KEY="your-api-key"). To (re-)configure at
any time, run:
debgpt config
Or use debgpt genconfig to generate a configuration template and place it at
$HOME/.config/debgpt/config.toml. Both config and genconfig will inherit
any existing configurations.
Upon completion, you can start an interactive chat with the LLM:
debgpt
Enjoy the chat!
Hint: A collection of samples generated using DebGPT can be found at this repository.
FRONTENDS
The frontend is a client that communicates with an LLM inference backend. It is
responsible for sending user input to the backend and receiving responses while
Available frontend options (specified by --frontend|-F):
-
openai— the OpenAI-API protocol, compatible with OpenAI's own service as well as any other provider or self-hosted deployment that exposes an OpenAI-compatible endpoint; API reference -
anthropic— Anthropic's Claude models; API reference -
google— Google's Gemini models; API reference -
vllm— a dedicated configuration slot for self-hosted or other OpenAI-API compatible services; vLLM docs -
zmq— DebGPT's built-in, self-contained LLM backend -
dryrun— debugging mode; prints the assembled prompt without sending it
Note, when directing DebGPT at a third-party service, review that provider's terms of use and exercise caution about sharing sensitive material.
TUTORIAL
The following examples are carefully ordered. You can start from the first example and gradually move to the next one.
1. Interaction Mode with LLM and CLI Behavior
When no arguments are given, debgpt leads you into a general terminal
chatting client with LLM backends. Use debgpt -h to see detailed options.
debgpt
During the interactive chatting mode, you may press / and see a list of
available escaped commands that will not be seen as LLM prompt.
-
/save <path.txt>: save the last LLM response to the specified file. -
/reset: clear the context. So you can start a new conversation without quitting. -
/quit: quit the chatting mode. You can pressCtrl-Dto quit as well.
The first user prompt can be provided through argument (--ask|-A|-a):
debgpt -A "Who are you? And what can LLM do?"
By specifying the --quit|-Q option, the program will quit after receiving
the first response from LLM. For instance, we can let it mimic fortune
with temperature 1.0 (--temperature|-T 1.0) for higher randomness:
debgpt -T 1.0 -QA 'Greet with me, and tell me a joke.'
After each session, the chatting history will be saved in ~/.cache/debgpt as
a json file in a unique name. The command debgpt replay can replay the last
session if you forgot what LLM has replied to you.
The program can write the last LLM response to a file through -o <file>,
and read question from stdin:
debgpt -Qa 'write a hello world in rakudo for me' -o hello.raku
debgpt -HQ stdin < question.txt | tee result.txt
After getting familiarized with the fundamental usage and its CLI behavior,
we can directly move on to the most important feature of this tool, namely the
special prompt reader -- MapReduce.
2. Context Readers for Additional Information
Context Reader is a function that reads the plain text contents from the
specified resource, and wrap them as a part of a prompt for the LLM. The
context readers can be arbitrarily combined together or specified multiple
times through the unified argument --file|-f. It can read from a file,
a PDF file, a directory, a URL, a Debian Policy section, a Debian Developer
Reference section, a Debian BTS page, a Debian build status page (buildd),
a Google search result, etc. The specification syntax of the unified reader
--file|-f can be found using the command debgpt -f : or debgpt -f '?'.
Some simple examples are shown below:
# read a plain text file or PDF file and ask a question
debgpt -Hf README.md -a 'very briefly teach me how to use this DebGPT.'
debgpt -Hf debgpt/policy.py -A 'explain the code'
debgpt -Hf my-resume.pdf -a 'Does this person have any foss-related experience?'
# read a directory
debgpt -Hf debian/ -a 'how is this package built? How many binary packages will be produced?'
# read a URL
debgpt -Hf 'https://www.debian.org/vote/2022/vote_003' -A 'Please explain the differences among the above choices.'
# pipe a command line
debgpt -Hf cmd:'git diff --staged' -A 'briefly summarize the changes and provide a git commit message.'
The reader can be specified multiple times to put multiple information source
into a single context. The full list of supported reader specs, as well as
corresponding examples, can be printed using debgpt -f :, or debgpt -f "?",
or debgpt -x :.
3. Inplace Editing of a File
The argument [--inplace|-i] is for in-place editing of a file. It is a
read-write reader that does the same as --file|-f (read-only) does, but
the inplace one will write the LLM response back to the file. We expect the
user to use this feature for editing a file.
If specified, the edits (in UNIX diff format) will be printed to the screen.
The --inplace|-i will mandate the --quit|-Q behavior, and will turn
off markdown rendering.
The following example will ask LLM to edit the pyproject.toml file, adding
pygments to its dependencies. This really works correctly.
debgpt -Hi pyproject.toml -a 'edit this file, adding pygments to its dependencies.'
If working in a Git repository, we can make things more automated:
You may further append --inplace-git-add-commit to automatically add and
commit the changes to the Git repository. If you want to review before commit,
specify --inplace-git-p-add-commit|-I argument instead.
debgpt -Hi pyproject.toml -a 'edit this file, adding pygments to its dependencies.' --inplace-git-add-commit
The commit resulted by the above example can be seen at this link. Recent LLMs are strong enough to easily and correctly add type annotations and doc strings in DebGPT's python codebase, see example here.
4. MapReduce for Any Length Context
The "MapReduce" feature is the choice if you want the LLM to read bulk documentations.
Generally, LLMs have a limited context length. If you want to ask a question regarding a very long context, you can split the context into multiple parts, and extract the relevant information from each part. Then, you can ask the LLM to answer the question based on the extracted information.
The implementation of this is fairly simple: split the gathered information texts until the pre-defined maximum chunk size is satisfied, ask the LLM to extract relevant information from each chunk, and then repeatedly merge the extracted information through LLM summarization, until there is only one chunk left. As a result, this functionality can be very quota-consuming if you are going to deal with long texts. Please keep an eye on your bill when you try this on a paied API service.
This functionality is implemented as the --mapreduce|-x argument. The user
has to specify the --ask|-A|-a argument to tell LLM what kind of question we
want to ask so it can extract the right information. It will summarize if the
--ask|-A|-a argument is missing.
Some usage examples of MapReduce are as follows:
# load a long file (such as buildlog) and ask question
debgpt -Hx buildlog.txt -A 'Why does the build fail? How to fix it?'
debgpt -Hx 'https://www.debian.org/doc/debian-policy/policy.txt' -A 'what is the purpose of the archive?'
debgpt -Hx policy: -A 'what package should enter contrib instead of main or non-free?'
# this will automatically find the buildlog path
debgpt -Hx sbuild: -A 'why does the build fail? do you have any suggestion?'
# I'm really lazy to learn or recall details
debgpt -H -x policy: -x devref: -a 'which document (and which section) talked about Multi-Arch: ?'
# search google, read pages, and answer question (the --ask|-a|-A is the google search keyword unless specified following "google:")
debgpt -Hx google: -a 'how to start python programming?'
debgpt -Hx google:'debian packaging' -a 'how to learn debian packaging?'
# load a directory and ask question
debgpt -Hx . -a 'which file of this debgpt project implemented mapreduce? how does it work?'
debgpt -Hx . -a 'teach me how to use this software. Is there any hidden functionality that is not written in its readme?'
debgpt -Hx ./debian -A 'how is this package built? how many binary packages will be produced?'
# load Debian mailing list threads and answer question
debgpt -Hx ldo:debian-devel/2025/05 -a 'write a news report to summarize what happened in this month. Always cite the source URL.'
debgpt -Hx ldo:debian-vote/2025/04,05 -a 'what is the result of the AI DFSG gr? Always cite the source URL.'
The full list of supported reader specs, as well as corresponding examples, can
be printed using debgpt -f :, or debgpt -f "?", or debgpt -x :.
The -H argument will skip printing the first prompt generated by debgpt,
because it is typically very lengthy, and only useful for debugging and
development purpose. To further tweak the mapreduce behavior, you may want to
check the --mapreduce_chunksize <int> and --mapreduce_parallelism <int>
arguments.
5. Piping through Everywhere
Being able to pipe the inputs and outputs among different programs is one of the reasons why I love the UNIX philosophy.
The pipe mode is useful when you want to use debgpt in a shell script Try the
follows on the Makefile in debgpt repo. Later we will introduce a in-place
editing functionality which is more convenient than this one.
cat Makefile | debgpt -a 'delete the deprecated targets' pipe | tee tmp ; mv tmp Makefile; git diff
The pipe mode can be used for editing something in vim in-place.
# In vim debgpt/task.py, use 'V' mode to select the task_backend function, then
:'<,'>!debgpt -a 'add type annotations and comments to this function' pipe
This looks interesting, right? debgpt has a git wrapper that automatically
generates the git commit message for the staged contents and commit the message.
Just try debgpt git commit --amend to see how it works. This will also be
mentioned in the subcommands section.
6. DebGPT Subcommands
Git subcommand.
Let LLM automatically generate the git commit message, and call git to commit it:
debgpt git commit --amend
If you don't even want to git commit --amend the committed message, just
remove --amend from it.
Sbuild subcommand.
A shortcut to review and fix issues with building a Debian package via sbuild in the current directory. This implies the -H option (hide the first prompt) and automatically asks the LLM to build the package and fix potential problems:
debgpt sbuild
7. Prompt Engineering
As you may have seen, the biggest variation in LLM usage happens in the context
including how you provide the context readers, and how you ask the question
through --ask|-A|-a. By adjusting the way you provide those information
and ask the question, you can get significantly different results. To properly
make LLM work for you, you may need to go through some basic prompt engineering
methods.
The following are some references on this topic:
- OpenAI's Guide https://platform.openai.com/docs/guides/prompt-engineering
Advanced usage of LLM such as Chain-of-Thought (CoT) will not be covered in this document. Please refer external resources for more information.
The usage of LLM is limited by our imaginations. I am glad to hear from you if you have more good ideas on how we can make LLMs useful for Debian development: https://salsa.debian.org/deeplearning-team/debgpt/-/issues
8. Debian Specific Usage Cases
-
Analysis of the sbuild buildlog
-
Analysis of the ratt buildlog directory
TROUBLESHOOTING
-
Context overlength: If the result from context readers (such as feeding
--filewith a huge text file) is too long, you can switch to the--mapreduce|-xspecial reader, or switch to a model or service provider that supports longer context. -
Chunk size (
--mapreduce_chunksize): In DebGPT, the internal measurement of text length is simply bytes. That's because different LLMs use different tokenizers, and DebGPT wants to support as many LLM inference backends as possible. To simplify software development, I just use bytes. That means accurate calculation and detection of context overlength cannot be done. A rough estimate is that each token has 4 characters in English. That means, if your LLM context size is 32k (tokens), we should be able to use roughly 128k (bytes) chunk size with DebGPT.
BACKENDS
The backend is the server side that runs the LLM inference and communicates with the client frontend. It can be self-hosted or provided by a third party. Here we only discuss the self-hosted backends, i.e., vLLM (or any OpenAI-API compatible service), and the DebGPT built-in ZMQ.
ZMQ (DebGPT Built-in)
This tool provides one backend implementation: zmq.
zmq: Only needed when you choose the ZMQ front end for self-hosted LLM inference server.
If you plan to use the openai or dryrun frontends, there is no specific
hardware requirement. If you would like to self-host the LLM inference backend
(ZMQ backend), powerful hardware is required.
LLM Selections
The concrete hardware requirement depends on the LLM you would like to use. A variety of open-access LLMs can be found here
https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboardGenerally, when trying to do prompt engineering only, the "instruction-tuned" LLMs and "RL-tuned" (RL is reinforcement learning) LLMs are recommended.
The pretrained (raw) LLMs are not quite useful in this case, as they have not yet gone through instruction tuning, nor reinforcement learning tuning procedure. These pretrained LLMs will more likely generate garbage and not follow your instructions, or simply repeat your instruction. We will only revisit the pretrained LLMs when we plan to start collecting data and fine-tune (e.g., LoRA) a model in the far future.
You can specify any Hugging Face model ID directly using the --model_id option.
By default, we use:
Qwen/Qwen3.5-0.8B(default) : This model is extremely lightweight and requires very little disk space/VRAM.
Different LLMs will pose different hardware requirements. Please see the "Hardware Requirements" subsection below.
Hardware Requirements
By default, we recommend doing LLM inference in fp16 precision. If the VRAM
(such as CUDA memory) is limited, you may also switch to even lower preicisions
such as 8bit and 4bit. For pure CPU inference, we only support fp32
precision now.
Note, Multi-GPU inference is supported by the underlying transformers library. If you have multiple GPUs, this memory requirement is roughly divided by your number of GPUs.
Hardware requirements for the default model (Qwen/Qwen3.5-0.8B):
Qwen/Qwen3.5-0.8B+fp16(cuda/cpu): Extremely lightweight, can run on almost any modern GPU or CPU with 4GB+ RAM/VRAM.
Usage of the ZMQ Backend
If you want to run the default LLM with different precisions:
debgpt backend --max_new_tokens=1024 --device cuda --precision fp16
debgpt backend --max_new_tokens=1024 --device cuda --precision bf16
debgpt backend --max_new_tokens=1024 --device cuda --precision 8bit
debgpt backend --max_new_tokens=1024 --device cuda --precision 4bit
The only supported precision on CPU is fp32 (for now). If you want to fall back to CPU computation (very slow):
debgpt backend --max_new_tokens=1024 --device cpu --precision fp32
The argument --max_new_tokens does not matter much and you can adjust it (it
is the maximum length of each llm reply). You can adjust it as wish.
REFERENCES
[1] Access large language models from the command-line : https://github.com/simonw/llm
[2] Turn your task descriptions into precise shell commands : https://github.com/sderev/shellgenius
[3] LangChain: Build context-aware reasoning applications : https://python.langchain.com/docs/introduction/
[4] Moonshot - A simple and modular tool to evaluate and red-team any LLM application. : https://github.com/aiverify-foundation/moonshot?tab=readme-ov-file
[5] LLMxMapReduce (Concurrent work. Their method is more advanced than mine) : https://arxiv.org/abs/2410.09342
LICENSE and ACKNOWLEDGEMENT
DebGPT development is helped with various open-access and commercial LLMs on code suggestion, code writing, code editing, document writing, with human reviews and modifications.
Copyright (C) 2024-2025 Mo Zhou <lumin@debian.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
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 debgpt-0.8.2.tar.gz.
File metadata
- Download URL: debgpt-0.8.2.tar.gz
- Upload date:
- Size: 106.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cf12c7edcf85cdff4e7e79a4d576c3482fadeb15e9eeaece8829e7774ad2bf0
|
|
| MD5 |
4547c5fce825605bd91061c80c5c16f0
|
|
| BLAKE2b-256 |
50765ca551aaaa373e5054dfab3e3a2d6ce25117d832805ca0c8fcd49faab01c
|
File details
Details for the file debgpt-0.8.2-py3-none-any.whl.
File metadata
- Download URL: debgpt-0.8.2-py3-none-any.whl
- Upload date:
- Size: 117.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba788322a6acefdc5fee165b54ea6a0f58fe657d454b901ea59880b1942db8b4
|
|
| MD5 |
14a82f8f186562f602360e33e167c627
|
|
| BLAKE2b-256 |
5ffe23fdd90beedb287edf35b6c2d40a6b86d64a8e80af6c12059a3fa0d92a89
|