Skip to main content

An IPython extension for interacting with OpenAI's models

Project description

IPython + GPT-4

A quick toy implementation of a random idea: what if ipython had a magic function that sent the current session to gpt-4 along with a prompt, and automatically evaluated the result in the current session?

Disclaimer: this is terribly unsafe and should not be used with any sensitive data.

Python 3.9.14 (main, Oct 19 2022, 22:42:39)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %load_ext ipython_gpt

In [2]: names = ["jordan", "octavia", "cyrelle"]

In [3]: gpt write a random greeter, run it with `names`
import random

def random_greeter(names):
    if names:
        name = random.choice(names)
        print(f"Hello, {name}!")
    else:
        print("Hello there!")

# Running the greeter with the provided names
names = ["jordan", "octavia", "cyrelle"]
random_greeter(names)

Hello, jordan!

In [4]: gpt make the greeting more formal
import random

def formal_greeter(names):
    greetings = ["Good day", "Greetings", "Salutations", "Hello"]
    title = "Mx."
    for name in names:
        greeting_selected = random.choice(greetings)
        print(f"{greeting_selected}, {title} {name.capitalize()}!")

formal_greeter(names)

Greetings, Mx. Jordan!
Salutations, Mx. Octavia!
Hello, Mx. Cyrelle!

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

ipython_openai-0.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

ipython_openai-0.0.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file ipython_openai-0.0.2.tar.gz.

File metadata

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

File hashes

Hashes for ipython_openai-0.0.2.tar.gz
Algorithm Hash digest
SHA256 63981c262261cf97fbf0253da49d740d718936c90cf9113f4af0af2b701db85b
MD5 267c23dd7be758cc741cd8e5a114e458
BLAKE2b-256 f210218001e78cf280eb0a4951ccbd525005172e28a381b73592b4d969cb3c88

See more details on using hashes here.

Provenance

File details

Details for the file ipython_openai-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ipython_openai-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 549eda10f32c0d3e15e80115717fc5cb14c5fea4bc16ab49b7c246f13c974184
MD5 e71e3eb130489102815907a004e5ada4
BLAKE2b-256 b4e5a44e0386edafc0862fa10bf0e4243a854bc7898bcb32bd3af33c95f30a1d

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