feat(ui): add Svelte frontend for /humanize, LibreTranslate option for Step 4, and Docker startup fixes - #29
Conversation
20f9245 to
1575343
Compare
molly554
left a comment
There was a problem hiding this comment.
Review: Changes Requested
Tests pass (38/38), code is well-structured overall, but there are a few issues that need fixing before merge.
🔴 Critical: Branch deletes Atlas Cloud provider (#28)
This branch was forked before PR #28 (Atlas Cloud) was merged into main. As a result, merging this PR will remove the Atlas Cloud provider, its env-var fallback, and its 2 tests from llm_client.py and test_llm_client.py.
Fix: Rebase onto current main and resolve conflicts — keep the Atlas Cloud entries.
🟡 Breaking: Port change 8000 → 8001
humanizer.py CLI --serve and docker-compose.yml / Dockerfile all switch from port 8000 to 8001 without a migration note. Existing Docker users will break silently.
Fix: Either keep 8000 (preferred — less churn), or document the port change prominently in the PR description and README.
🟡 Dependencies: fastapi/uvicorn/pydantic added to base requirements.txt
PR #17 was rejected partly for pulling FastAPI into the base dependency set. The pipeline's core use case is CLI — users who just want python -m src.standard.pipeline shouldn't need FastAPI installed.
Fix: Move fastapi, uvicorn[standard], pydantic to setup.py extras:
extras_require={
"api": ["fastapi>=0.109.0", "uvicorn[standard]>=0.27.0", "pydantic>=2.0.0"],
...
}🟡 API has no authentication
/v1/humanize/standard is open — anyone who can reach the port can burn through your LLM API key. A Docker deployment exposed on a public IP would be a cost risk.
Fix: Add a simple bearer-token check (read from env/config), or at minimum document the risk and recommend running behind a reverse proxy.
🟢 Minor issues
-
Unused imports in
src/standard/api.py:timeandOptionalare imported but never used — remove them. -
_load_config()reads disk on every request: Consider caching with@lru_cacheor loading once at startup via FastAPI lifespan. Current approach is fine for low traffic but will add latency under load. -
normalize_target_lang()is verbose: The 12-language if-chain and the final fallbacktarget_lang.split("-")[0]do the same thing. The fallback alone covers all cases — the explicit branches are unnecessary. -
SPA catch-all route ordering:
@app.get("/{full_path:path}")inhumanizer.pycatches all GET requests whenSTATIC_DIRexists. This works now because the legacy API only has POST endpoints, but adding a new GET route later would be silently shadowed. Consider using a more specific prefix like@app.get("/app/{full_path:path}").
Summary
The LibreTranslate integration, Svelte UI, and API layer are solid work — good test coverage and clean separation. The main blocker is the rebase conflict that would delete Atlas Cloud. Once that's resolved and the dependency/auth issues are addressed, this is ready to merge.
Wire the language field from HumanizeRequest through to TranslationChainProcessor so requests like en-US are honored. Add per-engine normalization (e.g. en-US -> en for Google, ja -> ja-JP for MyMemory) and update the default chain to use ja-JP so the MyMemory hop does not fail.
- Bun and Static Svelte Build UI Frontend - Tests for the v1.5 Standard Pipeline API
1575343 to
32ab4c2
Compare
|
Addressed review items: rebased onto latest main, reverted ports to 8000, moved FastAPI stack to optional api extra, added docker-compose security warning for unauthenticated API exposure. |
Summary
This PR bundles the last 3 commits:
/humanizeflow, built and served by FastAPI.Type of Change
Why
/humanizemeant curl or Postman.Changes
Docker / runtime
docker/Dockerfilenow runs the unified entrypoint:uvicorn src.api:app --port 8001.docker-compose.ymlhealthcheck hitshttp://localhost:8001/v1/health, so it reflects the v1 app instead of just "the port is open."Frontend (Svelte)
frontend/src/*: text input, method + language pickers, result card, error states.frontend/src/lib/api.js: small API helper that checks status/content-type and throws readable errors when the server returns non-JSON (e.g. a proxy HTML error page) instead of blowing up onres.json().distinto/app/static, where FastAPI serves it. One container, no separate dev server in prod.LibreTranslate Step 4 provider (v1.5 Standard Pipeline)
libretranslate_translate(...)insrc/standard/translators.py.src/standard/pipeline.pygetspipeline.step4_provider = "niutrans" | "libretranslate": defaults to Niutrans, so existing setups are unaffected./v1/config(src/standard/api.py) now exposesstep4_providerandlibretranslate_base_url: non-sensitive values only.src/standard/__init__.py.config/config.tomldocuments the new keys:[pipeline] step4_providerand[providers.libretranslate].Tests
tests/test_standard_api.py: route shapes/validation, config redaction, language normalization, legacy bridge reachability, and the new/v1/configfields.tests/test_standard_pipeline.py: Step 4 defaults to Niutrans, switches to LibreTranslate when configured, and the response shape stays the same either way.Visual / UI changes - REQUIRED if you touched anything that renders