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 (on the same python venv): chatbot, rudi. 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 :

    • !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.1.tar.gz (11.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: silik_kernel-1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2c5aca7987e94edd6abc4f7ab7b811aa2aed90a2d91b89c97249180e98f67839
MD5 c051650401b4804077892eff6e9b6d8f
BLAKE2b-256 ffed373c1f077cd4cc9adbcc2eac4d92838c53ef0f4ba5d081b6bb28beb4e0c4

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