• Stars
    star
    351
  • Rank 120,157 (Top 3 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created about 2 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

What if GPT could help you notebook?

Install | License | Code of Conduct | Contributing

GenAI: generative AI tooling for IPython

🦾 Get GPT help with code, SQL queries, DataFrames, Exceptions and more in IPython.

🌍 Supports all Jupyter environments, including IPython, JupyterLab, Jupyter Notebook, and Noteable.

TL;DR Get started now

%pip install genai
%load_ext genai

Genai In Action

Genai making a suggestion followed by running suggested code

Introduction

We've taken the context from IPython, mixed it with OpenAI's Large Language Models, and are bringing you a more informed notebook experience that works in all Jupyter environments, including IPython, JupyterLab, Jupyter Notebook, and Noteable. 🦾🌏

Requirements

Python 3.8+

Installation

Poetry

poetry add genai

Pip

pip install genai

Loading the IPython extension

Make sure to set the OPENAI_API_KEY environment variable first before using it in IPython or your preferred notebook platform of choice.

%load_ext genai

Features

  • %%assist magic command to generate code from natural language
  • Custom exception suggestions

Custom Exception Suggestions

In [1]: %load_ext genai

In [2]: import pandas as pd

In [3]: df = pd.DataFrame(dict(col1=['a', 'b', 'c']), index=['first', 'second', 'third'])

In [4]: df.sort_values()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 df.sort_values()

File ~/.pyenv/versions/3.9.9/lib/python3.9/site-packages/pandas/util/_decorators.py:331, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
    325 if len(args) > num_allow_args:
    326     warnings.warn(
    327         msg.format(arguments=_format_argument_list(allow_args)),
    328         FutureWarning,
    329         stacklevel=find_stack_level(),
    330     )
--> 331 return func(*args, **kwargs)

TypeError: sort_values() missing 1 required positional argument: 'by'

πŸ’‘ Suggestion

The error message is indicating that the sort_values() method of a pandas dataframe is missing a required positional argument.

The sort_values() method requires you to pass a column name or list of column names as the by argument. This is used to determine how the sorting will be performed.

Here's an example:

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Carol', 'David', 'Eva'],
    'Age': [32, 24, 28, 35, 29],
    'Salary': [60000, 40000, 35000, 80000, 45000]
})

# sort by Age column:
df_sorted = df.sort_values(by='Age')
print(df_sorted)

In this example, the by argument is set to 'Age', which sorts the dataframe by age in ascending order. Note that you can also pass a list of column names if you want to sort by multiple columns.

Example

In [1]: %load_ext genai

In [2]: %%assist
   ...:
   ...: Can you explain this query to me so I can be sure we're doing the right things?
   ...:
   ...: ```sql
   ...: SELECT
   ...:   COUNT(*) AS num_downloads,
   ...:   DATE_TRUNC(DATE(timestamp), DAY) AS day
   ...: FROM `bigquery-public-data.pypi.file_downloads`
   ...: WHERE
   ...:   file.project = 'genai'
   ...:   -- Only query the last 6 months of history
   ...:   AND DATE(timestamp)
   ...:     BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH)
   ...:     AND CURRENT_DATE()
   ...: GROUP BY day
   ...: ORDER BY day DESC
"This is a SQL query that counts the number of downloads for the 'genai' project on the Python Package Index (PyPI) over the last 6 months, grouped by day. The query selects the count and the date, truncating the date to the day level so that it's easier to read.

Here is a breakdown of each part of the query:

- `SELECT COUNT(*) AS num_downloads, DATE_TRUNC(DATE(timestamp), DAY) AS day`: This selects the count of the number of rows matched by the query as `num_downloads`, and the date truncated to the day level as `day`.
- `FROM `bigquery-public-data.pypi.file_downloads``: This specifies the table to query from.
- `WHERE file.project = 'genai'`: This filters the rows by only including downloads for the 'genai' project.
- `AND DATE(timestamp) BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH) AND CURRENT_DATE()`: This filters the rows by only including downloads from the last 6 months. The `DATE_SUB` function subtracts 6 months from the current date (`CURRENT_DATE()`), `DATE_TRUNC` truncates the result to be the start of the month and `DATE` converts the timestamp column to a date so the `BETWEEN` condition can filter rows between the start of 6 months ago and "today."
- `GROUP BY day`: This groups the rows by day so that the counts are aggregated by date.
- `ORDER BY day DESC`: This orders the rows so that the most recent date appears first in the result."

More Repositories

1

covfefe

covfefe
JavaScript
421
star
2

libvirt-go

[DEPRECATED] Go bindings for libvirt
Go
166
star
3

chatlab

⚑️πŸ§ͺ Fast LLM Tool Calling Experimentation, big and smol
Jupyter Notebook
133
star
4

obama

πŸš“ Move JS forward and standardize with Obama
JavaScript
81
star
5

pipboyrelay

⚑ Pip boy relay for Fallout 4
JavaScript
78
star
6

bookstore

πŸ“š IPython notebook storage on OpenStack clouds
Python
58
star
7

dangermode

Execute IPython & Jupyter from the comforts of chat.openai.com
Python
57
star
8

bitjet

πŸš€ Binary visualization using IPython widgets
JavaScript
57
star
9

atom-achievements

⭐ Unlock Achievements in the Atom Editor!
CoffeeScript
43
star
10

ipython-notebook-cookbook

πŸ“– IPython Notebook Cookbook for Deployment via Chef
Ruby
41
star
11

atom-ipynb

:bowtie: Connect to IPython kernels using the atom editor.
CoffeeScript
24
star
12

gistexec

github.js + gist + thebe === quick runnable nbviewer
JavaScript
20
star
13

i

personal redirect server
JavaScript
17
star
14

jupyterhub-compmodels-deploy

JupyterHub Playbook for the Computational Models class at Berkeley
Python
16
star
15

adjectives

An Array of Adjectives
JavaScript
15
star
16

pivot-pivot

Pivot tabling
JavaScript
11
star
17

nbformatjs

JS implementation of the jupyter notebook format
Jupyter Notebook
11
star
18

autodock

πŸ³β›΅ Perform actions based on a webhook from the Docker hub
Go
11
star
19

multipipboy

Mini-demo of a multiplayer map for Fallout 4
JavaScript
10
star
20

juno

Go bindings for the Jupyter protocol
Go
10
star
21

share-cell

Share code
CSS
9
star
22

iknowthis

fuzz testing framework for Linux system calls
C
8
star
23

metrics-graphics-jupyter

Metrics Graphics for the Jupyter Notebook πŸ“ˆ πŸ“Š πŸ“‰
JavaScript
7
star
24

swift-lang-demos

Demos of Swift, add your own!
Swift
7
star
25

jupyter-react-hooks

Just a little toy example using react hooks and jupyter
TypeScript
6
star
26

yelling

Repository of files yelling at you
6
star
27

language-ipynb

IPython notebook language support in Atom
6
star
28

peekaboo

🍼 On/off Rackspace load balancing switch for your host's services.
Go
5
star
29

old-dotfiles

Dotfiles for Kyles (round II)
Vim Script
5
star
30

iggy

go get gitignores
Shell
5
star
31

kernels-service

🌽 Launch Jupyter Kernels over HTTP
Python
5
star
32

hubcrypt

Encrypt messages using a GitHub user's public key :octocat: πŸ”
Python
5
star
33

atom-python

🐍 Run python commands in atom
CoffeeScript
5
star
34

lit

experimenting with alternative notebook state formations
JavaScript
4
star
35

atom-giphy

GIFs from giphy, into Atom.
CoffeeScript
4
star
36

google-diff-match-patch

Automatically exported from code.google.com/p/google-diff-match-patch
Python
4
star
37

bromine

Minecraft server setup in Docker for my family and friends
JavaScript
4
star
38

pki-examples

A tutorial on creating your own public key infrastructure for microservices
Go
4
star
39

301inabox

πŸ”› HTTP Redirects in a box
Python
4
star
40

hexview

hexdump for python, integration with IPython
Python
4
star
41

bookmarks

Because why would I store these in awkward menu bars
4
star
42

ikernel

Prototyping a javascript kernel for fun and demonstration
JavaScript
4
star
43

vdomify

Convert plain ol' Python objects to VDOM ready objects
Python
4
star
44

jupyter-react-training

React Training for Jupyter Apps
JavaScript
4
star
45

left-shark

Like left-pad, except the examples have sharks.
JavaScript
4
star
46

whereami

Where am I?
JavaScript
3
star
47

atom-snow

❄️ Snow in Atom.
CSS
3
star
48

iolopub

IO Live Once Publication
Go
3
star
49

nodebook

A Notebook for node (experimental)
JavaScript
3
star
50

salt-states-rackspace-monitoring

Install the Rackspace Cloud Monitoring Agent, using Salt States
Scheme
3
star
51

MomokoYokoOhNo

Bridging SQLAlchemy & Momoko
3
star
52

jupyter-environments-talk

On Demand Analytic and Learning Environments with IPython/Jupyter
HTML
3
star
53

chartsworth

Chartsworth, the charts monster
Jupyter Notebook
3
star
54

pydata-notebook

Running through Wes McKinney's Python for Data Analysis Book using IPython notebook
Python
3
star
55

bigcards

Piecing together the commands for setting up the PCI-e cards on the OnMetal IO nodes
Shell
3
star
56

wat

wat
3
star
57

lru-key-store

πŸ”‘πŸͺ Least Recently Used Key Store
Go
3
star
58

invoke-the-core

Provision a CoreOS cluster with an invoke script
Python
3
star
59

whoa

Tinier version of https://github.com/rackerlabs/whoa
C
2
star
60

jupyter-app-demo

Building up a Jupyter App Demo
JavaScript
2
star
61

simple-pyspark-binder

Quick showing of pyspark on binder
Jupyter Notebook
2
star
62

synchronized-object-diff-spec

Thinking πŸ€” on Synchronized Objects for Jupyter/nteract
2
star
63

301inaboxadmin

πŸ”› Admin/API for 301inabox
Python
2
star
64

nginxhibition

nginx tomfoolery as a service
Shell
2
star
65

nbschema

Schemas for the Jupyter Notebook for JS
Jupyter Notebook
2
star
66

zmq-prebuilt-example

Example usage of zmq-prebuilt
JavaScript
2
star
67

Jumpin

πŸ†™ Square platformer written for an Embedded Systems class. The proof-of-concept was written in Java which we then ported over to a combination of C and VHDL for use on the Xilinx Spartan 3.
Java
2
star
68

vaporeon

Vaporized Docker Containers
Go
1
star
69

uptempo

Upload temporary files into a Docker container (tmpnb demo)
Python
1
star
70

index.ipynb

Demo of using index.ipynb on nbviewer
1
star
71

emojiterator

Emoji Generator
JavaScript
1
star
72

python-lsp-zed-extension

Python LSP Server Zed Extension
Rust
1
star
73

docker-rackspace-net

Query the host networking when working in a Docker environment on Rackspace
Shell
1
star
74

learning-graphql

Running through the Learning GraphQL Book
JavaScript
1
star
75

atom-heat

Heat is hot.
CoffeeScript
1
star
76

craft

πŸ”§ Dockerized modded Minecraft server
1
star
77

poked

PokeD(ex)
Python
1
star
78

bitty

bitjet standalone
JavaScript
1
star
79

oneweirdkerneltrick

πŸ‘Ί Hijacking IPython Websockets
JavaScript
1
star
80

jupyter-native

Bring together jupyter native packages all in one
TypeScript
1
star
81

electron-protocol-play

Trying out custom protocols and rendering
JavaScript
1
star
82

ctxtjs

Some quick context switch evaluation in node
JavaScript
1
star
83

next-gen-nteract-components

Prototyping better interfaces for working with cells
JavaScript
1
star
84

rachel

πŸ“΄ Detecting Rachel the Robo Caller
1
star
85

pottytime

🚽 Monitor bandwidth on an interface with some Go code
Go
1
star
86

react-context-backed-jupyter

Exploring the new context API + localStorage
JavaScript
1
star
87

platypu.sh

Platypush
HTML
1
star
88

js-the-good-parts

I'm reading Javascript the Good Parts and dumping stuff here
JavaScript
1
star
89

pipboydata

pip boy data for mucking with
JavaScript
1
star
90

bootstrap-salt-nbviewer

Bootstrapping salt for nbviewer (deprecated)
1
star
91

gitorn

πŸ” Tornado + GitHub OAuth Toy
Python
1
star
92

flareup

πŸŒ… Adjust hosts according to solar flares
Python
1
star
93

playing-with-rx-jupyter

Hacking around with rx-jupyter, creating a dashboard for fun
JavaScript
1
star
94

meatspace

πŸ– Track events bounded by time and space
Python
1
star
95

iolohub

IOLO Hub and IOLO Sub for IOLO Pub
Go
1
star
96

flying-elephants

Tornado mixed with PostgreSQL
1
star
97

immutable-reviver

JSON.parse reviver that creates Immutable.JS objects
JavaScript
1
star
98

repr_llm

Create lightweight representations of Python objects for Large Language Model consumption
Python
1
star
99

happi

Throw up an API, be happy
1
star
100

-

β˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒβ˜ƒ
CoffeeScript
1
star