Skip to main content

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

Project description

✨ panel-web-llm

CI conda-forge pypi-version python-version

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

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

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.0.tar.gz (129.2 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.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panel_web_llm-0.0.0.tar.gz
  • Upload date:
  • Size: 129.2 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.0.tar.gz
Algorithm Hash digest
SHA256 ba2a04fd720f497526dfb2e5218d391ef0d50614e1751991ae940823e18927ce
MD5 78d8cd9320b07522e47aa9738f5fa433
BLAKE2b-256 e00d7c31269ce1cf351f4f5c498d3ff4e5565cce793167ac935bdafbcac149e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for panel_web_llm-0.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: panel_web_llm-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f223ccd5aed30fec275aefa8b3b7189a88ed7c3ae0e64900ad555137b554b9be
MD5 4069f6f95a734db26c16b34f51e246ef
BLAKE2b-256 a23bcbaade626528795d0c6dcb06999a6e8a799e201a1758e09b80abef209ac7

See more details on using hashes here.

Provenance

The following attestation bundles were made for panel_web_llm-0.0.0-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