Skip to main content

An IPython extension for interacting with OpenAI's models

Project description

IPython + GPT-4

A quick 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?

Installation

pip install ipython_openai

Then, you can either load the extension during an ipython session with %load_ext ipython_openai or add the following to your ipython config.

c.InteractiveShellApp.extensions = ['ipython_openai']

Usage

This extension adds two new "magic" functions

gen

In [1]: 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

In [2]: greet()
Hello, Bob!

ask

In [3]: 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.

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.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

ipython_openai-0.0.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ipython_openai-0.0.3.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 ipython_openai-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ae1c697d0e664c0677c2efc11e505be2b9302c9aa3f7966fbdc9002b16430221
MD5 ed50d2c5c045fb626b9776c07ceac625
BLAKE2b-256 2af70ec1c9f9567c19b498b4e433594005f08bd2c43a8c48c84df56e3d6f7740

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for ipython_openai-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 36a51be3e9153913a5274cc9134c465896d49c21d500fa085f5c53c8ff65f3b3
MD5 18f19d45191d2949ea9d9a64af07f2a6
BLAKE2b-256 9bd497ffd913d9b1cf0a1b7043bd21cde13b97d3537e1fec10cbda433226d0c1

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