Jupyter Pilot is a Python package that uses the OpenAI API to generate code from natural language prompts. It is designed to simplify the process of writing code and to make programming more accessible to non-programmers.
To install Jupyter Pilot, simply run:
pip install jupyterpilot
Please run: pip install --upgrade jupyterpilot
Note: Most of these errors are model generated. For this exact reason, the code creates a test.py in the same working directory as that of the notebook. User can read and manually or programmatically remove these errors.
To use JupyterPilot, import the pysetup
class from the jupyterpilot
module:
from jupyterpilot import pysetup
Then, create an instance of CodetoCell
with your OpenAI API key:
openai_key = "YOUR_API_KEY"
cc = pysetup.CodetoCell(openai_key)
Call the get_code
method with a natural language prompt to generate code:
prompt = "Create a function to get stock data from yahoo finance api"
cc.get_code(prompt)
This will create a file called test1.py
with the generated code and import statements, and then load the code into a Jupyter Notebook cell for further use.
You can pass options to the CodetoCell
constructor to customize its behavior:
cc = pysetup.CodetoCell(
openai_key=openai_key,
model="code-cushman-001", # Choose a different model (optional)
tokens=2048, # Increase the number of tokens (optional)
tokens=1024 # (optional),
temperature=0.1 # (optional),
top_p=1 # (optional),
penalty=0, # (optional)
presence_penalty=0 # (optional)
)
You can choose a different model by setting the model
parameter to a different model ID. Other models can be found on the OpenAI API documentation.
You can increase the number of tokens by setting the tokens
parameter to a larger value. The maximum number of tokens supported by the code-cushman-001
model is 2048, while the code-davinci-002
model supports up to 8000 tokens.
JupyterPilot is licensed under the MIT License. See the LICENSE file for details.