Spaces:
Running
Running
|
Download README.md from HuggingFaceSwarms/PyBot: direct link, hf CLI and curl.
- Browser
- Download file 2.18 kB
-
https://huggingface.co/spaces/HuggingFaceSwarms/PyBot/resolve/main/README.md
- Command line
-
hf download hf://spaces/HuggingFaceSwarms/PyBot/README.md
-
curl -L -o README.md https://huggingface.co/spaces/HuggingFaceSwarms/PyBot/resolve/main/README.md
2.18 kB
metadata
title: PyBot
emoji: 🐍
colorFrom: gray
colorTo: gray
sdk: docker
app_port: 7860
pinned: false
PyBot: Can Python be a chatbot?
A chat demo that runs PyBot, a chatbot written in plain Python, entirely in your browser: Pyodide (CPython compiled to WebAssembly) runs the bot in a Web Worker, and this Space only serves files. Each reply shows which of PyBot's modules and files produced it; click a file to read it on GitHub.
Files
index.html: the page (chat, the reply's trace, and a treemap of PyBot's files; Plotly from jsDelivr).worker.js: loads Pyodide 314.0.7 from jsDelivr and the bot bundle, then answers turns. Like transformers.js does for model files, it keeps the bundle in Cache Storage, so a second visit doesn't download it again.pybot_web.py: the glue: fixed random seeds as in the benchmark's eval server (so replies match the leaderboard run), the trace viasys.monitoring, and the file that holds a reply's text.pybot-<sha12>.zip:bot/**.pyccompiled for Pyodide's CPython 3.14 (loading skips compiling 33 MB of source), plusnorm.json(each file's text, letters and digits only) for finding the file that holds a reply. It is built from the same code asbot/in the GitHub repo.tree.json: PyBot's files and line counts for the treemap, and the repo its file links open.Dockerfile: only serves the files above (python -m http.server). A static Space would redirect the large files to a CDN without CORS headers, which blocks the worker's fetch of the bundle and the fonts.
Rebuild from a newer bot
git clone https://github.com/huggingface/pybot && (cd pybot && zip -qr ../bot-src.zip bot -i '*.py')
npm install pyodide@314.0.7 # the same version as worker.js: bytecode only loads in the Python that compiled it
node build/build.mjs bot-src.zip build/build_bundle.py pybot-<sha12>.zip
Then regenerate tree.json ([path, line count] for every bot/**.py) and update BUNDLE in worker.js (a new
name makes browsers download the new bundle). To test locally, serve this folder (python -m http.server) and open it.