Skip to main content

Add your description here

Project description

llm-debug

A Minimal Python Library to debug with LLMs

Ldbg enables to use natural-language prompts while debugging. Prompts are augmented with your current stack, variables, and source context. It is like ShellGPT but for pdb, ipdb, Jupyter, the VS Code Debug Console, etc.

DO NOT USE THIS LIBRARY

“AI everywhere is rocket engines on a skateboard: a thrill that ends in wreckage. The planet pays in energy and emissions, and we pay in something subtler — the slow atrophy of our own intelligence, left idle while the machines do the heavy lifting.” ChatGPT

Here is CJ Reynolds point of view:

I used to enjoy programming. Now, my days are typically spent going back and forth with an LLM and pretty often yelling at it… And part of enjoying programming for me was enjoying the little wins, right? You would work really hard to make something… or to figure something out. And once you figured it out, you'd have that little win. You'd get that dopamine hit and you'd feel good about yourself and you could keep going. I don't get that when I'm using LLMs to write code. Once it's figured something out, I don't feel like I did any work to get there. And then I'm just mad that it's doing the wrong thing. And then we go through this back and forth cycle and it's not fun.

Features

  • 🐍 Generate Python debug commands from natural-language instructions.
  • 🔍 Context-aware: prompt auto-includes call stack, local/global variable previews, current function source, and nearby code.
  • 🤖 Supports multiple LLM providers: OpenAI, Anthropic, DeepSeek, Groq, Together AI, OpenRouter, Ollama

NOTE: In VS Code, you enter the function in the Debug Console, and get the output in the terminal ; so put both tabs (Debug Console and Terminal) side to side.

Installation

uv add ldbg, pixi add --pypi ldbg or pip install ldbg

Quick Start

Example natural-language prompts

  • "Describe my numpy arrays"
  • "plot my_data['b'] as a histogram"
  • "give me an example pandas dataframe about employees"
  • "generate a 3x12x16 example Pillow image from a numpy array"
  • "convert this Pillow image to grayscale"
  • "open this 'image.ome.tiff' with bioio"

Example Session

>>> unknown_data = np.arange(9)
>>> example_dict = {"a": 1, "b": [1, 2, 3]}
>>> example_numbers = list(range(10))
>>> import ldbg
>>> ldbg.gc("describe unknown_data")
The model "gpt-5-mini-2025-08-07" says:

    unknown_data is an numpy array which can be described with the following pandas code:
    
    ```
    pandas.DataFrame(unknown_data).describe()
    ```

    Note: you can use numpy.set_printoptions (or a library like numpyprint) to pretty print your array:
    
    ```
    with np.printoptions(precision=2, suppress=True, threshold=5):
        unknown_data
    ```

Would you like to execute the following code block:
    pandas.DataFrame(unknown_data).describe()
(y/n)

User enters y:

            0
count  9.000000
mean   4.000000
std    2.738613
min    0.000000
25%    2.000000
50%    4.000000
75%    6.000000
max    8.000000



Would you like to execute the following code block:
    with np.printoptions(precision=2, suppress=True, threshold=5):
        unknown_data
(y/n)

User enters n and continues:

>>> ldbg.gc("plot example_numbers as a bar chart")
The model "gpt-5-mini-2025-08-07" says:

    ```
    import matplotlib.pyplot as plt
    plt.bar(range(len(numbers)), numbers)
    plt.show()
    ```

Would you like to execute the following code block:
...

Configuration

By default, llm-debug uses the OpenAI client. So it reads the OPENAI_API_KEY environment variable.

Supported Providers

You can use any of the following LLM providers by setting the LDBG_API environment variable:

OpenAI (default)

export OPENAI_API_KEY="your_api_key_here"

DeepSeek

export LDBG_API="deepseek"
export DEEPSEEK_API_KEY="your_api_key_here"

Anthropic (Claude)

export LDBG_API="anthropic"
export ANTHROPIC_API_KEY="your_api_key_here"

Groq

export LDBG_API="groq"
export GROQ_API_KEY="your_api_key_here"

OpenRouter

export LDBG_API="openrouter"
export OPENROUTER_API_KEY="your_api_key_here"

Together AI

export LDBG_API="together"
export TOGETHER_API_KEY="your_api_key_here"

Ollama (local)

export LDBG_API="ollama"
# No API key required for local Ollama installations

Custom Model

By default, each provider uses its recommended model. You can override this by passing the model parameter to ldbg.gc():

import ldbg
ldbg.gc("describe my_data", model="gpt-4-turbo")
ldbg.gc("describe my_data", model="deepseek-coder")
ldbg.gc("describe my_data", model="claude-3-opus-20240229")

License

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ldbg-0.1.3.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ldbg-0.1.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file ldbg-0.1.3.tar.gz.

File metadata

  • Download URL: ldbg-0.1.3.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for ldbg-0.1.3.tar.gz
Algorithm Hash digest
SHA256 508a65b94d6c59e10216c145b90e50c0735f753fca8e8a00a30c52380bd5caa0
MD5 fa1b3cc21f7a8d7ef1f1fb8fcec93542
BLAKE2b-256 500024bec3760ec768b892e9c293fa848f6186168684ad3eab965c6ebda71418

See more details on using hashes here.

File details

Details for the file ldbg-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ldbg-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for ldbg-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 07a89796b585145af5117c40e8525b232dd6fb4cea9afce724e0df8e90fe9ef2
MD5 a42b7002236c4e85341cf86155229ac2
BLAKE2b-256 6ad7dc78b8f901797a8a3b1647cc4af6111a11cf97fd955758bac7cbf22c2270

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page