A python debugger with OpenAI integrations
Project description
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.
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
Built Distribution
File details
Details for the file pdb_openai-0.0.8.tar.gz
.
File metadata
- Download URL: pdb_openai-0.0.8.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d304aa2a1e31bc1462d4fa7602ae964a17191fb5a4e25434fab9cf8bba02fdb7 |
|
MD5 | 12146bb36bda9224f2668867ad2b2462 |
|
BLAKE2b-256 | 0f7de578e11c00efb2a56a450e157acb833847a080f0f01bfc77957370f4761a |
File details
Details for the file pdb_openai-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: pdb_openai-0.0.8-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35246d971af8245e638260b6cef8185cfff0df44e0389b8865ac05b91203c785 |
|
MD5 | 76911249d4619f98b536010afb804108 |
|
BLAKE2b-256 | a529f3c08498cc00edaa316acfd1eea15bb76f8a318e51cbe319bbb80797c778 |