Skip to main content

Multi-kernel Manager

Project description

Silik Kernel

This is a jupyter kernel that allows to interface with multiple kernels, you can:

  • start, stop and restart kernels,

  • switch between kernels,

  • list available kernels.

As a jupyter kernel, it takes text as input, transfer it to appropriate sub-kernel; and returns the result in a cell output. It gives a single context that is shared between kernels. The cell history is shared with sub-kernels within the 'metadata' attribute of execution messages.

Any kernel can be plugged to silik

Getting started

pip install silik-kernel

The kernel is then installed on the current python venv.

Any jupyter frontend should be able to access the kernel, for example :

Notebook (you might need to restart the IDE) : select 'silik' on top right of the notebook

CLI : Install jupyter-console (pip install jupyter-console); and run jupyter console --kernel silik

Silik Signal Messaging : Access the kernel through Signal Message Application.

To use diverse kernels through silik, you can install some example kernels : https://github.com/Tariqve/jupyter-kernels. You can also create new agent-based kernel by subclassing pydantic-ai base kernel.

You can list the available kernels by running jupyter kernelspec list in a terminal.

Usage

Once the kernel is started, you can :

  • send commands :

    • !help : display this message
    • !start <kernel_type> : starts a kernel; it will be assigned a label. Per example, !start python3 starts and connect to a python3 kernel.
    • !restart <kernel_label> : restart a kernel with its label.
    • !ls : list started kernels.
    • !select <kernel_label>: switch a started kernel with its label
  • run code :

    • if you run !ls, you'll see which kernel you are on.
    • all cells you send will be executed in this kernel, and the result will be given in the cell output. Silik kernel acts as a gateway for the sub-kernels.

Retrieving cells history with a custom kernel

If you want to retrieve the history of the silik kernel within your custom kernel, you just have to access the 'metadata' attribute of the current message. For example (assuming you use subclass the ipykernel, and self is your kernel instance) :

parent = self.get_parent()
metadata = parent.get("metadata", {})
if isinstance(metadata, dict) and "message_history" in metadata:
    print(metadata["message_history"])

The attribute 'message_history' of the metadata is a list of dict, each with :

{
  "role": "user or assistant; user for cell input, assistant for cell output",
  "content": "Input Code if user, output if assistant",
  "uid": "uuidv4"
}

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

silik_kernel-1.2.2.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file silik_kernel-1.2.2.tar.gz.

File metadata

  • Download URL: silik_kernel-1.2.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for silik_kernel-1.2.2.tar.gz
Algorithm Hash digest
SHA256 d9f60dc32c88965d8eabdfe2d0900bb5f26b31eadd18817a9c957764f015968b
MD5 47e3a5bd39c96627969abfeba23d7f88
BLAKE2b-256 0e5b38fdb7ab9a3d42ded5a7df7bd8aaadfdcd72ee525d4fdbad6743aa3cb08a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page