yasi

Seamlessly integrate AI with Jupyter Notebooks to unlock the potential of Dialog Engineering

Background

What if you could have a more fluid, interactive conversation with AI? Enter Dialog Engineering, a groundbreaking approach that lets you construct and edit a dialogue with the AI in real-time.

Unlike prompt engineering where you’re just creating a single sentence or paragraph or whatever, that’s actually part of a whole back and forth dialog. All of the previous steps get sent to the AI model as well, not just the prompt. And they all greatly influence how it responds. And how it responds influences you as to what you then add to the dialog. - Jeremy Howard, from the MAD Podcast 34:42

Yasi seamlessly integrates Jupyter Notebooks with AI to unlock the potential of Dialog Engineering. With yasi, you can create, edit, and refine your conversations with AI. It is a DIY implementation of the - yet to be released - platform solveit from answer.ai.

For more information see the following articles:

Usage

Installation

Install latest from the GitHub repository:

$ pip install git+https://github.com/Jack-Byte/yasi.git

or from pypi

$ pip install ipy-yasi

Documentation

Documentation can be found hosted on this GitHub repository’s pages. Additionally you can find package manager specific guidelines on conda and pypi respectively.

How to use

You can try it online with Binder Binder

Import JupyterChat, set openai_base_url (only if you are not using Openai itself), and provide your api key directly or as the env variable OPENAI_API_KEY.

from yasi.core import JupyterChat

jc = JupyterChat(openai_base_url="https://openrouter.ai/api/v1", api_key=None)

Query Openai directly

You can use the send_query method to interacte through a code cell directly. The response will be added as a new markdown cell in your current notebook.

jc.send_query('Kia ora, how are you?')

Kia ora! I’m doing well, thanks for asking! It’s great to connect with you and practice some basic Maori phrases. How can I help you today?

Send Dialoge from your Notebook

JupyterChat is designed to extract messages from your current notebook and construct a dialoge.

It’s searching for markdown cells that contain the tags

  • #| chat_system (optional) sets the context for the conversation, providing the AI with a “hint” about the type of response expected
  • #| chat_user your messages
  • #| chat_assistant the AIs real responses, or the ones that you ingest into the dialog

and sends the dialog to the Openai API.