Skip to main content

Pdb + GPT-4

A wrapper around the standard Python debugger Pdb that adds 3 special commands for interacting with OpenAI's models.

Installation

pip install pdb_openai

Configuration

Your OpenAI API key should be available in the OPENAI_API_KEY env var. Alternatively, you can pass an api key as an argument to the stop function which triggers a breakpoint in your code.

Usage

Use this debugger similar to how you would invoke pdb:

from pdb_openai import debug; debug.stop()

Once in the session, you can use 3 new commands in addition to the standard pdb workflow. As you interact with the debugger, the session history including input, output and errors are stored in memory. When any of the commands below are invoked, the model gets a transcript of the session in addition to your prompt.

gen

(Pdb OpenAI) gen a 5 line greeter function with randomness
import random
def greet():
    names = ["Alice", "Bob", "Charlie", "Diana", "Edward"]
    greeting = ["Hello", "Hi", "Hey", "Greetings", "What's up"]
    print(f"{random.choice(greeting)}, {random.choice(names)}!")

Run it? (y/n) y

(Pdb OpenAI) greet()
Hello, Bob!

ask

(Pdb OpenAI) ask what happened
When the `greet()` function was called, the following occurred:
1. The function selected a random name from the list `names`, which contains five different names: "Alice", "Bob", "Charlie", "Diana", and "Edward".
2. It also selected a random greeting from the list `greeting`, which includes five different greetings: "Hello", "Hi", "Hey", "Greetings", and "What's up".
3. It combined the selected greeting and name with a formatted string to create a message.
4. Finally, the function printed this message to the console.
Since the selections are random, the exact output can vary with each call to `greet()`, displaying a greeting and a name randomly chosen from the lists provided.

wtf

This is an alias for ask with this prompt: Explain how the program arrived at this state, including the cause of any errors. Be concise. Add one or more ? chars to the command to provide more context to the model.

Metadata

Release files for pdb-openai 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdb-openai 0.0.8
File Size Uploaded
pdb_openai-0.0.8.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdb-openai 0.0.8
File Interpreter ABI Platform
pdb_openai-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / pdb_openai-0.0.8.tar.gz

Download URL pdb_openai-0.0.8.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d304aa2a1e31bc1462d4fa7602ae964a17191fb5a4e25434fab9cf8bba02fdb7
BLAKE2b-256 checksum
How to use checksums
0f7de578e11c00efb2a56a450e157acb833847a080f0f01bfc77957370f4761a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.14

Release files / pdb_openai-0.0.8-py3-none-any.whl

Download URL pdb_openai-0.0.8-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35246d971af8245e638260b6cef8185cfff0df44e0389b8865ac05b91203c785
BLAKE2b-256 checksum
How to use checksums
a529f3c08498cc00edaa316acfd1eea15bb76f8a318e51cbe319bbb80797c778
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.14

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page