Skip to main content

A Jupyter/IPython magic command for generating code using GPT.

Project description

GPT magic

A Jupyter/IPython magic command for generating code using GPT

Example

Generating code with GPT by loading the extension and prefixing your line with %gpt.

Alt text

Install

Install with pip

pip install gpt-magic

Please note that users will need to provide their own OpenAI API key. Set an environment variable called OPEN_AI_KEY with your key. Or pass the API key when loading the extension, by running the following line before %load_ext gpt_magic:

import os
os.environ["OPENAI_API_KEY"] = "your_openai_api_key_here"

Usage

%load_ext gpt
%gpt "Your request here"

Model

The current default is the gpt-3-turbo model, but can be changed using OPENAI_MODEL environmental variable.

Using GPT-4 example

import os
os.environ["OPENAI_MODEL"] = "gpt-4"

Arguments

Chat

You can enable memory of all previous requests and responses with the -c argument. By default it's memory-less.

%gpt -c "Write a function which calculates the average of a numpy array"

Temperature

You can set the temperature with -t argument. The default is 0.

%gpt -t 0.5  "Write a function which calculates the average of a numpy array"

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

gpt-magic-0.2.0.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

gpt_magic-0.2.0-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

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