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.1.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for ipython_openai-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d95ee5c13614d8c746c90a08127cf793b4dee02e4fa120963dcc000679865b7f |
|
MD5 | 23bfc26ea9312f89a6bfa2233c0afdb2 |
|
BLAKE2b-256 | fb1bb7390cc87e1a207bb2601d4bbb2571dfef249844479a48af391cdcd2cb7f |