969 strings, an instance default and a per-person choice, and no half-done corner: the admin prose is translated too. Design and reasoning: LLeMbas.wiki/Translations. KEYED BY THE ENGLISH SENTENCE A missing entry renders the key, which is the English -- so an untranslated string looks as it always did, an English instance is byte-for-byte 1.6.0, and a half-finished catalogue is a half-translated page rather than a page of dotted key names. The cost is that editing an English sentence orphans its translation silently, which is what tests/test_translations.py asserts in both directions. No gettext: .po -> .mo is a build step and this project does not have one. A JINJA GLOBAL, AND THEREFORE A CONTEXTVAR `t()` is a global for the reason `brand` already documents -- render() is bypassed by 25 TemplateResponse calls and 8 get_template().render() calls, the latter being the SSE frames, which have no Request at all. A global is bound once at import and the language is per person, so the active language is a ContextVar set per request. 🚨 `get_current_user` had to become `async def`. FastAPI runs a sync dependency in a threadpool, and anyio copies the context in and discards it on the way out -- so the language was set where nothing could see it and every page rendered in the instance's language whatever anybody had chosen, with no error anywhere. NOT TRANSLATED, ON PURPOSE Everything a model reads: the 60 prompt fragments, and the dates in harness.py, schedule/runner.py and schedule/compile.py. Only `i18n.stamp` is localised, and only where a person reads it -- with the *format* translatable as well as the words, because "26. septembra 2026" is a different pattern rather than the same one with different words in it. A process locale is not an option: global, not thread-safe, two people's pages at once. A second fragment telling models to answer in the reader's language was written during this work and removed: `core.style` has said it since long before, and test_an_empty_override_turns_a_fragment_off caught the duplicate. THE BULK PASS 1213 sites wrapped by a one-off script that only touched patterns it could not misread. It got three wrong in a way that mattered -- `t('…')` inside `attr="…"` where the sentence held an apostrophe, closing the Jinja string and 500ing two pages whose partials no test renders. tests/test_translations.py now compiles all 110 templates. It also wrapped the product's own name, an SSH key header, a keystroke hint and an example URL, all taken back out: a string is not translatable just because it is a string. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
103 lines
3.5 KiB
TOML
103 lines
3.5 KiB
TOML
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[project]
|
|
name = "lembas"
|
|
# Read from lembas.__version__ rather than written here. Two copies drifted
|
|
# three minor versions apart without anything noticing, because nothing reads
|
|
# this one: the app, the service worker cache key and the page footer all read
|
|
# the module. See [tool.hatch.version] below.
|
|
dynamic = ["version"]
|
|
description = "LLeMbas - a Middle-earth themed web UI for OpenAI-compatible LLM endpoints"
|
|
readme = "README.md"
|
|
requires-python = ">=3.11"
|
|
license = { file = "LICENSE" }
|
|
authors = [{ name = "Jaroslav Benes", email = "admin@ecoposta.sk" }]
|
|
keywords = ["llm", "webui", "openai", "chat", "self-hosted"]
|
|
classifiers = [
|
|
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
"Programming Language :: Python :: 3",
|
|
"Topic :: Communications :: Chat",
|
|
]
|
|
|
|
dependencies = [
|
|
"fastapi>=0.115",
|
|
"uvicorn[standard]>=0.32",
|
|
"jinja2>=3.1",
|
|
"sqlalchemy>=2.0",
|
|
"pydantic>=2.9",
|
|
"pydantic-settings>=2.6",
|
|
"httpx>=0.27",
|
|
"python-multipart>=0.0.12",
|
|
"argon2-cffi>=23.1",
|
|
"cryptography>=43.0",
|
|
"markdown-it-py>=3.0",
|
|
"mdit-py-plugins>=0.4",
|
|
"linkify-it-py>=2.0", # bare URLs in model output become links
|
|
"pygments>=2.18",
|
|
"nh3>=0.2.18",
|
|
"pypdf>=5.1", # PDF text extraction for attachments
|
|
"pillow>=11.0", # image validation and downscaling for vision
|
|
"typer>=0.12",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=8.3",
|
|
"pytest-asyncio>=0.24",
|
|
"ruff>=0.7",
|
|
]
|
|
# DuckDuckGo search. Optional because it brings a compiled HTTP client and an
|
|
# XML parser with it, and the other two search providers need only httpx, which
|
|
# is already a core dependency. Without this the provider is offered in the
|
|
# admin UI with an install hint rather than silently missing.
|
|
search = ["ddgs>=9.0"]
|
|
# Agent chats, which run their commands on a machine reached over SSH. Optional
|
|
# on the same terms as `search`: an instance that never turns agents on should
|
|
# not carry the dependency, and one that does gets told how to install it rather
|
|
# than finding the feature silently missing. `bcrypt` is what decrypts a
|
|
# passphrase-protected OpenSSH key -- without it, pasting one fails opaquely.
|
|
ssh = ["asyncssh[bcrypt]>=2.14"]
|
|
|
|
[project.scripts]
|
|
lembas = "lembas.cli:app"
|
|
|
|
[project.urls]
|
|
Homepage = "https://git.houmeres.sk/Houmeres/LLeMbas"
|
|
|
|
[tool.hatch.version]
|
|
path = "src/lembas/__init__.py"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["src/lembas"]
|
|
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py311"
|
|
src = ["src", "tests"]
|
|
|
|
[tool.ruff.lint]
|
|
select = ["E", "F", "I", "UP", "B", "SIM", "C4"]
|
|
ignore = ["B008"] # FastAPI Depends() in defaults is idiomatic
|
|
|
|
[tool.ruff.lint.per-file-ignores]
|
|
# A translation catalogue is keyed by the English sentence, and a sentence cannot
|
|
# be rewrapped without becoming a different key. Wrapping them would mean every
|
|
# key spelled as an implicit concatenation, which is both unreadable and one
|
|
# stray space away from a silent miss.
|
|
"src/lembas/web/i18n/*.py" = ["E501"]
|
|
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
# Registered so `-m "not slow"` works and an unknown-marker warning does not
|
|
# become an error later. `slow` is for the tests that stand up something real:
|
|
# a uvicorn subprocess on a port, an asyncssh server, a PTY, a git repository
|
|
# built with subprocess. They are the ones worth having and the ones worth
|
|
# being able to skip while iterating.
|
|
markers = [
|
|
"slow: stands up a real server, shell or repository",
|
|
]
|
|
asyncio_mode = "auto"
|
|
filterwarnings = ["ignore::DeprecationWarning"]
|