Skip to main content

Extends HoloViz Panel with an interface that wraps a client-side LLM.

Project description

✨ panel-web-llm

CI pypi-version python-version

This extension for HoloViz Panel introduces a client-side interface for running large language models (LLMs) directly in the browser.

demo

It leverages WebLLM under the hood to provide an in-browser LLM execution environment, enabling fully client-side interactions without relying on server-side APIs.

Features

  • Run LLMs in the Browser: Execute large language models directly in the browser without requiring server-side APIs or cloud services.
  • Offline Capability: Cache models locally in the browser, enabling offline use after initial download.
  • Model Variety: Supports multiple models, including Llama 2 and Qwen 2.5. Check Available Models for the most up-to-date list.
  • Privacy-Preserving: Keeps all computations client-side, ensuring data privacy and security.
  • Panel Integration: Effortlessly incorporate LLM-powered features into interactive Panel applications.

Pin Version

This project is in its early stages, so if you find a version that suits your needs, it’s recommended to pin your version, as updates may introduce changes.

Installation

Install it via pip:

pip install panel-web-llm

Usage

Online

Try it out in Examples.

Command Line Interface

Once installed, you may launch the web LLM in the terminal with the following command:

panel-web-llm

Once the server launches, the Load <model_name> button has been clicked, the model is cached in your browser.

That means, even if you restart the server without internet, you can still run that same model offline, as long as your browser cache is not cleared.

The following is an alias for convenience:

pllm

The default model used is Qwen2.5-Coder-7B-Instruct-q4f16_1-MLC. To default to another model:

panel-web-llm run <model_name>

Replace <model_name> with the name of the model you want to use. For a list of models:

panel-web-llm list

Python

You can seamlessly integrate the Web LLM interface into your Panel applications:

import panel as pn
from panel_web_llm import WebLLMInterface
pn.extension()

template = pn.template.FastListTemplate(
    title="Web LLM Interface", main=[WebLLMInterface()]
)
template.show()

If you don't like the built-in layout of WebLLMInterface, you can instead wrap WebLLM manually:

import panel as pn
from panel_web_llm import WebLLM

pn.extension()

web_llm = WebLLM(load_layout="column")
chat_interface = pn.chat.ChatInterface(
    callback=web_llm.callback,
)

template = pn.template.FastListTemplate(
    title="Web LLM Interface",
    main=[chat_interface],
    sidebar=[web_llm.menu, web_llm],  # important to include `web_llm`
    sidebar_width=350,
)
template.show()

Development

git clone https://github.com/panel-extensions/panel-web-llm
cd panel-web-llm

For a simple setup use uv:

uv venv
source .venv/bin/activate # on linux. Similar commands for windows and osx
uv pip install -e .[dev]
pre-commit run install
pytest tests

For the full Github Actions setup use pixi:

pixi run pre-commit-install
pixi run postinstall
pixi run test

This repository is based on copier-template-panel-extension (you can create your own Panel extension with it)!

To update to the latest template version run:

pixi exec --spec copier --spec ruamel.yaml -- copier update --defaults --trust

Note: copier will show Conflict for files with manual changes during an update. This is normal. As long as there are no merge conflict markers, all patches applied cleanly.

❤️ Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/YourFeature.
  3. Make your changes and commit them: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature/YourFeature.
  5. Open a pull request.

Please ensure your code adheres to the project's coding standards and passes all tests.

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

panel_web_llm-0.0.2.tar.gz (130.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

panel_web_llm-0.0.2-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file panel_web_llm-0.0.2.tar.gz.

File metadata

  • Download URL: panel_web_llm-0.0.2.tar.gz
  • Upload date:
  • Size: 130.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for panel_web_llm-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b06513825a8ad21117b122bd67e0aadc950d5893444d0608eacb02ba88f5b178
MD5 21cb3d295ae3c992d4027c9bca773f7d
BLAKE2b-256 80266f7216c78a61b2d61383f3159167e506144d662e541dda11caf0018d29da

See more details on using hashes here.

Provenance

The following attestation bundles were made for panel_web_llm-0.0.2.tar.gz:

Publisher: build.yml on panel-extensions/panel-web-llm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panel_web_llm-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: panel_web_llm-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for panel_web_llm-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 90dea3ce16c91205db337ca2c255ee2de35892f85c5f05435196d74917fcc073
MD5 c06d54ded8b0d850997053cac837e4d2
BLAKE2b-256 cfe8fb558d459c825b3346890ae3b5d824faf2bb61f49491f1cbd0a2808cbb10

See more details on using hashes here.

Provenance

The following attestation bundles were made for panel_web_llm-0.0.2-py3-none-any.whl:

Publisher: build.yml on panel-extensions/panel-web-llm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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