Skip to main content

NbSwitch is a tool for modifying the use case of lessons inside jupyter notebooks, pure markdown, and other file formats.

Project description

NbSwitch

NbSwitch let's you bring a notebook with educational content, describe a new use case, and change the original one to that using Claude Sonnet 3.5!

alt text

There are thousands of incredible educational notebooks out there that could be shown some love, so, what if that meant that, in the case of data-related topics, we could change the use case of any given notebook to a completely new one? That's what NbSwitch is for. :sunglasses:

As of now, the app works in the following way:

  1. Select your notebook and write a prompt (there is no order for this at the moment). Press the wide green button.
  2. Claude will go through the notebook and, based on a template prompt and your written one, it will evaluate which cells need to change and which don't and then return a list with the index of each of the cells that will need to be changed.
  3. The second pass through Claude includes:
    1. A slightly different prompt template
    2. your prompt again
    3. the list of cells that need to be changed
  4. Then the endpoint returns HTML back to the front-end with both the new and the original notebook
  5. Scroll down for a button to download your .ipynb file.

The app can be found live here.

Limitations

  • Make sure your notebook has not been run before you upload it.
  • Don't add overly long notebooks, e.g., those requiring more than max_tokens=4_096.
  • Didn't test it on mobile (this might be more useful for markdown files for the obsidian lovers (myself included :smiley: ))

alt text

This project was created as part of Anthropic's June 2024 Hackathon and it was build using their Claude Sonnet 3.5 model.

While I made this app to participate in the Hackathon, I see a lot of value in this project and will continue to polish and host it for free for as long as I can. The code will remain open-source as well. :)

Note: The code in this repo is fresh out of the oven, meaning, its ugliness might offend people, its lack of tests might give some a cardiac arrest, and its lack of React or something similar in the front-end might... (I'll leave that last one to you).

Set Up

Create an environment.

python -m venv venv

or

mamba create -n hackathon python=3.11

Activate your environment.

source venv/bin/activate

or

mamba activate hackathon

Install the dependencies.

pip install -r requirements.txt

Run the app.

uvicorn main:app --reload

Tech Stack

  • anthropic - SDK to interact with Anthropic's suite of models.
  • instructor - tool for enforcing structured output from LLMs using pydantic.
  • pydantic - typescript for Python.
  • fastapi - for processing and serving requests.
  • nbconvert - to change notebooks from one format to another.
  • nbformat - to manipulate the JSON structure of a notebook.
  • AlpineJS - interactions in the front-end.
  • Pines UI - Tailwind CSS and AlpineJS components.
  • HTMX - for sending the request to the back-end.

Roadmap

  • (Important!) Optimize the process for generating the new notebooks, right now, it is relatively expensive to change one.
  • (Important!) Add an error message in case the user does not add a notebook and only a prompt.
  • Provide a way for users to input their own API key.
  • Limit the usage (maybe to 10 notebooks per person and per month as I am paying for it)
  • Add support for markdown files
  • Add support for marimo files
  • Add example notebooks
  • Add more example prompts
  • Add interactivity where, for example, the user could select a part of the notebook they didn't like and ask Claude to change it.
  • Allow users to bring in notebooks with outputs
  • Allow users to add a name to their new notebooks or select a random one for them
  • Create CLI

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

nbswitch-0.0.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

nbswitch-0.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file nbswitch-0.0.1.tar.gz.

File metadata

  • Download URL: nbswitch-0.0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.16.1 CPython/3.12.4 Linux/6.9.8-arch1-1

File hashes

Hashes for nbswitch-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0c7807203dff243ca35278c46b2ff3192233e79c6e0364b607c2ed3a7d06652c
MD5 f34276e1f5854c63b5137cfc65cc0796
BLAKE2b-256 ae51ce1228dd0017d1d96e18c4c3347165147efcab47400e3178638d7e7862bc

See more details on using hashes here.

File details

Details for the file nbswitch-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: nbswitch-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.16.1 CPython/3.12.4 Linux/6.9.8-arch1-1

File hashes

Hashes for nbswitch-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b63cda75eac25a951b6a3aa7df49474d07eab70ab4d0b4d0f1e0f5a1bb75780
MD5 79df40ae62ac7e05eb5d6587f07b8651
BLAKE2b-256 3592eaae9b4c26f5cd12d80f356ba4fee4de1fb49f2afe18df072b76fe688ce2

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