Git Product home page Git Product logo

Pretzel ๐Ÿฅจ

Modern, open-source Jupyter alternative.
Try it here ยป

Discord ยท Website ยท Issues ยท Contact

Github Stars Issues Join Pretzel on Discord License Commits-per-month

Pretzel.AI.Overview.with.Subtitles.mp4

Pretzel is a fork of Jupyter with the goal to improve Jupyter's capabilities. For our first few features, we've added AI code generation and editing, inline tab completion, sidebar chat and error fixing to Jupyter.

Switching to Pretzel from Jupyter is extremely easy since it's simply an improved version of Jupyter. All of your Jupyter config, settings, keybindings, and extensions will work out of the box.

Quick Start

  • Installation: pip install pretzelai then run pretzel lab to open the web interface. OR, use our free hosted version: pretzelai.app
  • Simply start typing in a cell to get inline tab completions
  • In any Jupyter cell, click โ€œAsk AIโ€ or press Cmd+K (Mac) / Ctrl+K (Linux/Windows) to prompt AI
  • Use the AI Sidebar with Ctrl+Cmd+B (Mac) or Ctrl+Alt+B (Linux/Windows) to chat with AI, generate code, and ask questions
  • To use your own model (OpenAI, Anthropic/Claude, Ollama or Groq), see the Configuration section


Our roadmap includes building features such as:

  • Native AI code generation and understanding features similar to Cursor
  • Frictionless realtime collaboration: pair-programming, comments, version history, etc.
  • SQL support (both in code cells and as a standalone SQL IDE)
  • Visual analysis builder (see more here)
  • VSCode like code-writing experience using Monaco
  • 1-click dashboard creation and sharing from Jupyter notebooks

Installation

Using pip

You can install Pretzel by using pip:

pip install pretzelai

If using conda, first install pip with conda install pip followed by pip install pretzelai.

Then, start Pretzel with:

pretzel lab

Just as with Jupyter, you should see a URL to access the Pretzel interface.

To use your own AI model, see the Configuration section.

Running within a docker container

If you're having trouble installing Pretzel (for eg on Windows), you can run it in a Docker container.

  1. Create a Dockerfile:
FROM python:3.9-slim
RUN apt-get update && apt-get install -y \
    build-essential \
    gcc \
    && rm -rf /var/lib/apt/lists/*
WORKDIR /root/pretzel
RUN pip install pretzelai
EXPOSE 8888
CMD ["pretzel", "lab", "--ip=0.0.0.0", "--allow-root", "--notebook-dir=/root/pretzel", "--ServerApp.allow_remote_access=True", "--ServerApp.token=''", "--no-browser"]
  1. In the same folder where you have your Dockerfile, run docker build -t pretzel .

  2. To run pretzel, you can run: docker run --name pretzel -p 8888:8888 pretzel and once the container is running, you can access it at http://localhost:8888/lab. To stop the container, press Ctrl + C followed by docker stop pretzel.

If you want to access your current folder in Pretzel, you can run: docker run --rm -p 8888:8888 -v $(pwd):/root/pretzel pretzel - this will map your current directory to the container's /root/pretzel folder. Make sure Docker has access to your current directory.

To update Pretzel to the latest version, just rebuild the Docker image with the --no-cache flag: docker build --no-cache -t pretzel . and now you can run docker like step 3.

Bleeding Edge Version

Bugs possible. To use the latest version of Pretzel:

  • Make sure Node.js is installed and is version 20
  • Clone and install the package
git clone https://github.com/pretzelai/pretzelai.git
cd pretzelai
pip install .

Usage

Inline Tab Completion

  • Start typing in a cell to get inline tab completions
  • Wait for 1 second to trigger completions

The default Pretzel AI Server uses Mistral's Codestral but you can switch the inline completion model in Pretzel AI Settings. See the configuration section.

Generating and editing code in notebook cells

  • In a cell, press Cmd+K (Mac) / Ctrl+K (Windows/Linux) or click "Ask AI" to open AI prompt textbox and write your code generation/editing instruction
    • Mention @variable to refer to variables and dataframes in memory
    • We automatically send relevant code in the current notebook as context to the AI
  • If there's existing code in a cell, the prompt will edit the existing code
    • If you select/highlight some code in the cell, only the selected code will be edited
  • You can accept/reject the response or edit your prompt if you want to re-submit with modifications
  • Use โ†‘ / โ†“ to cycle through prompt history

Using the AI Sidebar

  • Use Ctrl+Cmd+B (Mac) / Ctrl+Alt+B (Linux/Windows) or the Pretzel Icon on the right sidebar to activate the AI Sidebar
  • You can ask questions, generate code, or search for existing code
  • The AI always uses the code in the active cell as context. If you highlight some code in the active cell, only the highlighted code will be used as context
  • We automatically send relevant code in the current notebook as context to the AI
  • You can also use the @ syntax to refer to variables and dataframes in memory, similar to the notebook cells

Example uses of AI Sidebar:

  • "Modify the function my_function to be more efficient" โ† this will find the function my_function in the whole notebook and modify it
  • "Where is the code that removes outliers"? โ† this will search the notebook for code that removes outliers and show it to you
  • (While cursor is in a cell with some code) "Can you explain what this code does?" โ† this will explain the code in the current cell
  • "Plot a histogram of @df for age" โ† this will generate code to plot a histogram of the 'age' column from the dataframe named 'df'
  • "Calculate the mean revenue in @salesdata for each product type" โ† _this will generate code to calculate mean revenue by product type using the sales_data dataframe

Adding code in the middle of existing code

  • Put your cursor either on an empty line or an existing line of code. Bring up the AI prompting text box with Cmd+K
  • Start your prompt with the word inject or ij (case-insensitive) - this tells the AI to only add new code and not edit the existing code in the cell
  • Code will be added one line below where your cursor was placed

Fix errors with AI

  • When there's an error, you'll see a button on top-right "Fix Error with AI". Click it try fixing the error

Configuration

Pretzel works out-of-the-box, no configuration needed. We DO NOT store any code or data you send to the Pretzel AI Server.

Still, if you want to use a different AI model, you can configure Pretzel to use AI models from multiple different vendors, including local models. In this case, the AI request goes directly from your computer to the AI service (OpenAI, Anthropic etc).

  • Open the Settings menu in the top menubar, then click Pretzel AI Settings
  • Under AI Settings you can pick which AI models to use for chat and for inline completion (see screenshot below)
    • We recommend using GPT-4 class models (e.g., GPT-4 Turbo, GPT-4o, Claude-3.5 Sonnet, Claude-3 Opus and Llama-3.1 405B) for the best performance

Under the section Configure AI Services, you can

  • Enable or disable certain AI services (for eg, Azure and Ollama are disabled by default but can be enabled)
  • Enter your API key or URL as needed for each service

Remember to save your settings after making changes. Pretzel will validate your configuration to ensure everything is set up correctly.

help image here

Please note: We haven't tested Azure Enterprise OpenAI models yet. If you find any bugs, please report them in GitHub issues and we'll fix them ASAP.

Feedback, bugs and docs

Jupyter specific information

The original Jupyter documentation is available here and the Jupyterlab README is available here.

Privacy Policy, Data Collection and Retention

We collect no personal information. We use basic telemetry for only the AI features we've built - for example, when you click on "Ask AI", we receive an event that someone clicked on "Ask AI". We only associate an anonymous ID to your user. If you allow cookies, that helps us tell that it's the same user across multiple browser sessions (which is very helpful!). If you don't allow cookies, every time you open a browser, you're a new anonymous user to us.

We also collect prompts (but not the responses) for the AI features we've built. This can be turned off in the settings (Settings > Pretzel AI > Uncheck Prompt Telemetry) but we'd really appreciate if you didn't - this is very helpful in improving our prompts.

We do not collect any code whatsoever. Even when you use Pretzel's cloud AI server for completions, we don't store any of this code.

If you use the hosted version of Pretzel (https://pretzelai.app), we create a user for you based on your email address. You can always simply log-in and delete any data you may have stored on our hosted server. We make no backups or copies of your data.

Our hosted server is free to use. However, we will delete your data and your account 30 days after your last login. If you'd like to delete your account sooner, please email us at [email protected] with the subject line "Account Deletion" and we'll delete your account immediately.

FAQ

Q. What happened to the old version of Pretzel AI - the visual, in-browser data manipulation tool?

A. It's available in the pretzelai_visual folder here. Please see this PR for more info.

Q. What AI model does Pretzel use?

A. Pretzel uses different AI models for various tasks:

  1. Default model: GPT-4o

    • Offers a good balance between speed and quality
    • Can be changed in Pretzel Settings if you're using your own API key
  2. Inline completions: Mistral's Codestral model

    • Excellent for code completion
    • Very fast performance (22B parameter model)
  3. Fallback option:

    • If you're using your own API key without providing a Mistral API Key, Pretzel will use GPT-4o for inline completions as well

We're continuing to experiment with models and supporting local models and Anthropic's Claude is at the top of our list.

Q. What about feature X?

A. There's a ton we want to build. Please open an issue and tell us what you want us to build!

Q. Where's the roadmap?

A. We have a rough roadmap at the top of this README. There are many features we'd like to build, but there's just two of us. So, we're collecting feedback about what would be most helpful. Please open an issue or just email us with your feedback! Based on what we find, we'll prioritize our roadmap.

Q. Why are you using the AGPL license? Or, why not use MIT/BSD3 licenses?

A. Our goal with building Pretzel is to make an amazing data tool that is free for both individuals and companies to use. That said, we are a two-person startup - and we don't want some third party to just take our code and sell a hosted version of it without giving back to the community. Jupyter code is licensed as BSD-3 and if we keep our new code BSD-3 licensed, there would be no way to stop a third party from doing this. As a result, we went with the AGPLv3 license for all the new code. This ensures that if someone else does want to take our code and sell it (SaaS or otherwise), they have to open-source all of their modifications under AGPLv3 as well.

Q. Why a fork of Jupyter? Why not contribute into Jupyter directly?

A. This deserves a longer answer but here's the short answer: We've set out to make the new de-facto, modern, open-source data tool. Initially, we wanted to start from scratch. However, after talking to several data professionals, we realized it will be very hard to get people to switch to a new tool, no matter how good. The best way to get people to switch is to not have them switch at all. That's why we decided to fork Jupyter - for the near zero switching costs. Also, Jupyter is a mature product, and we're shipping feature really fast - frankly, at the pace we're shipping features, the code we write won't be accepted into the Jupyter codebase ๐Ÿ˜…. There are also many downsides to this decision - we've had to spend considerable time understanding the whole Jupyter ecosystem and multiple codebases, the complex release processes, the various APIs etc. However, we think this is the right decision for us.

Q. My company is worried about using an AGPLv3 licensed tool. What can I do?

A. The AGPL is a barrier ONLY IF you're modifying Pretzel AND redistributing it to the public. If you're simply using it as a tool in your company (even with modifications), the AGPL DOES NOT ask you to share your code. Still, if AGPL is an issue for you, please contact us, and we can figure out something that works.

Q. How are you planning on making money? OR, how are you free? I'm worried that you'll make this tool paid in the future.

A. We're planning on selling a hosted version of the tool to companies to make money. This hosted version will probably have some company specific features that individuals don't want or need such as data access controls, connectors for data sources, integration with GitHub, hosted and shareable dashboard, scalable and on-demand compute for large data jobs etc. We will not retroactively make Pretzel's individual version paid.

Pretzel AI's Projects

pretzelai icon pretzelai

The modern replacement for Jupyter Notebooks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.