Skip to main content

Magics for using GPT-like models inside Jupyter.

Project description

jupytee - magics for using GPT-like models inside Jupyter

Binder

A small, experimental playground with Jupyter magics to use OpenAI's GPT-3 models inside Jupyter environments.

This isn't even alpha software - it's just a quick and dirty prototype. But it works, if you have the python openai package installed and the environment variable OPENAI_API_KEY defined with your personal API key as per the docs.

Yes, the name is a silly play on the pronunciation of GPT and Jupyter.

Installation

pip install jupytee

Usage

To load the extension, use

%load_ext jupytee

The package provides a few core magics, %chat, %pic and %code (along with some extra helpers), that wrap your interactions around the OpenAI Python API. They target the main entry points of the API: text completion, image generation and code completion, respectively.

You can see them in action in the notebook contained in the examples directory (which you can run immediately by clicking on the Binder button above).

Briefly, these are some examples of how you can use them. A simple question (note the extra space before ?, needed b/c IPython's help will otherwise trigger by accident):

%chat What is 100F in Celsius ?

You can control the sampling temperature with -T:

%chat -T 1 --raw Write an uplifting short poem

Markdown (with math) work:

%%chat
Produce the LaTeX form of Maxwell's equations.

For pic, you can control image size and the number of images returned:

%pic -s m -n 2 an astronaut knitting

When generating code, you can iteratively refine the answer by referring to the CODE special word (in all CAPS):

%code A function to add two numbers.

and then:

%code Update CODE to have a docstring explaining its use.

License

BSD 3-Clause.

BSD 3-Clause License

Copyright (c) 2022, Fernando Pérez

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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

jupytee-0.0.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

jupytee-0.0.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jupytee-0.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for jupytee-0.0.2.tar.gz
Algorithm Hash digest
SHA256 52ab002a40582e6acc9730293e70f61a13eb4b121d05d9b51150e0b392107a4b
MD5 8ebbb09a1b0fc5d8f2c7302a19d191a1
BLAKE2b-256 c36f8ebffd206211b30e1531c8ef6ea10a07d3a018a43f89ca0b655c9b0188a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jupytee-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for jupytee-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b9dadd86a13b86cb123abb482cdfb8481ca3f6a201e9693f7f7e33b5e3198f98
MD5 155e9065fb924d1bd64bfb3943204275
BLAKE2b-256 e1e92b509e5f0642b76abf89372045158b13597361e1b0583609a45d05f7b1d7

See more details on using hashes here.

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