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.6.tar.gz
.
File metadata
- Download URL: pdb_openai-0.0.6.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c4e8818801e57c5a7afafeb5d24e0bf9c26b822753b6f4a3ec584e672ef2e8a |
|
MD5 | 820a870fe3960eed2f029b655e8736db |
|
BLAKE2b-256 | d86b732cc2820fe77cef1ed2a30448c7302aeb03163586b176a84e8870751ec8 |
Provenance
File details
Details for the file pdb_openai-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: pdb_openai-0.0.6-py3-none-any.whl
- Upload date:
- Size: 4.8 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 | bc15bcfefc6dfaaa41212ca5929b859d1acad954a54a53ad139b12e871bfbe04 |
|
MD5 | d7840d20e8728c15b0be18d441c5fa37 |
|
BLAKE2b-256 | c84bab70a989ff4b62e4a736d346b9dc1996dd9a1afd799d5e1ef49870ab721b |