Skip to main content

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.

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

pdb_openai-0.0.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

pdb_openai-0.0.5-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pdb_openai-0.0.5.tar.gz.

File metadata

  • Download URL: pdb_openai-0.0.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.14

File hashes

Hashes for pdb_openai-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c7c38cb77dbffb80ee50173776521d9794997e7c2f9f9697680ccaf5bf4429cf
MD5 d5bc20e2f7714fad543840dd4b5d4e9c
BLAKE2b-256 b911191cfcdfb4ff72b6c2cbb034d30bb5bc8bdfbd27b1e5ed86a5e18a89e48e

See more details on using hashes here.

Provenance

File details

Details for the file pdb_openai-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: pdb_openai-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.14

File hashes

Hashes for pdb_openai-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c1939d192aae1861e1405568389e07bf1cd4752714d9d6ed5f0edab8db660745
MD5 8741f3e64bb359d6e1b4fd9cf20ae143
BLAKE2b-256 bdbefb89c8cbe429604b1415d48dbc941144306627d79eb47cae51610f5a4172

See more details on using hashes here.

Provenance

Supported by

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