Improved auto translation support #2
+44
-10
@@ -23,7 +23,7 @@ think:false, which hybrid models need off. Backend quirks (sampling,
|
||||
num_predict cap, think) live in the config, not in the protocol.
|
||||
|
||||
Usage:
|
||||
uv run scripts/llm_translator.py ws://localhost:8410/_translate/KEY
|
||||
uv run scripts/llm_translator.py ws://localhost:8210/_translate/KEY
|
||||
uv run scripts/llm_translator.py wss://example.com/_translate/KEY --config my.json
|
||||
"""
|
||||
|
||||
@@ -277,15 +277,49 @@ def main() -> None:
|
||||
)
|
||||
p.add_argument(
|
||||
"url",
|
||||
help="full translator WebSocket URL including the key, "
|
||||
"e.g. ws://localhost:8410/_translate/KEY",
|
||||
help="full translator WebSocket URL including the access key, "
|
||||
"e.g. ws://localhost:8210/_translate/KEY — printed in the server "
|
||||
"startup log and copyable in the editor's lang tab",
|
||||
)
|
||||
p.add_argument(
|
||||
"--config",
|
||||
help="JSON file overriding any DEFAULT_CONFIG key (see the top of "
|
||||
"this script: api, base_url, model, langs, modes, temperature, "
|
||||
"predict_ratio/cap, think, ...); CLI flags win over the file",
|
||||
)
|
||||
p.add_argument(
|
||||
"--api",
|
||||
choices=["ollama", "openai"],
|
||||
help="LLM endpoint shape: 'ollama' = native /api/chat (needed for "
|
||||
"think:false), 'openai' = /v1/chat/completions (llama.cpp, hosted "
|
||||
"APIs) (default: ollama)",
|
||||
)
|
||||
p.add_argument(
|
||||
"--base-url",
|
||||
help="LLM server root without path, e.g. http://127.0.0.1:11434 "
|
||||
"(default) or https://api.openai.com",
|
||||
)
|
||||
p.add_argument(
|
||||
"--model",
|
||||
help="model string to serve, e.g. qwen3.8:27b (default; the "
|
||||
"structure-proven reference) — announced to the server in Hello",
|
||||
)
|
||||
p.add_argument(
|
||||
"--api-key",
|
||||
help="bearer key for --api openai backends (ollama ignores it)",
|
||||
)
|
||||
p.add_argument(
|
||||
"--langs",
|
||||
help="comma-separated language capabilities announced to the server, "
|
||||
"e.g. de,es,fi,pt,zh (default); jobs come only from the "
|
||||
"intersection with the site's configured target languages",
|
||||
)
|
||||
p.add_argument(
|
||||
"--modes",
|
||||
help="comma-separated job modes to accept: 'markdown,article' "
|
||||
"(default, for a structure-proven model) or 'markdown' for one "
|
||||
"trusted only in scoped mode",
|
||||
)
|
||||
p.add_argument("--config", help="JSON config file (overrides the shipped defaults)")
|
||||
p.add_argument("--base-url", help="LLM server root (no path)")
|
||||
p.add_argument("--model", help="model string to serve")
|
||||
p.add_argument("--api-key", help="API key for openai-api backends")
|
||||
p.add_argument("--langs", help="comma-separated announced languages")
|
||||
p.add_argument("--modes", help="comma-separated accepted job modes")
|
||||
args = p.parse_args()
|
||||
if not args.url.startswith(("ws://", "wss://")):
|
||||
p.error("url must start with ws:// or wss://")
|
||||
@@ -293,7 +327,7 @@ def main() -> None:
|
||||
cfg = dict(DEFAULT_CONFIG)
|
||||
if args.config:
|
||||
cfg.update(json.loads(Path(args.config).read_text()))
|
||||
for key in ("base_url", "model", "api_key"):
|
||||
for key in ("api", "base_url", "model", "api_key"):
|
||||
if getattr(args, key):
|
||||
cfg[key] = getattr(args, key)
|
||||
if args.langs:
|
||||
|
||||
Reference in New Issue
Block a user