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

Uploaded Source

File details

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

File metadata

  • Download URL: silik_kernel-1.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.tar.gz
Algorithm Hash digest
SHA256 c0574b2578497a93b012ded51384082b5b2b04bc56a41d7ec9ebe57bb27cd7e3
MD5 a778cc7adf576df7421cb5887f7018ff
BLAKE2b-256 74fa9e1aca6ed8a76c6fef51338276a41e6360e4851316e5a3c42b8e3735ddcf

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