interplane.Get Omega
Read in your language

aien-translate

aien-dev/aien-translate

Brought by drakestapleton

branch main Branches Tags History

aien-translate / AGENTS.md

92 lines · 6254 bytes Raw Blame History Source

aien-translate (translation server for translate.js, backed by your own model)

aien-translate is a Rust HTTP server that answers the translate.js translation protocol (/translate.json and friends) by sending text to an OpenAI-style chat model server, normally AIEN's own inference runtime. Every translation is checked by a guard before a visitor sees it and saved in a SQLite cache. The scripts/ folder holds Python tools that use a running server to translate a README, a built static website, or a LaTeX paper. Shared rules: read https://www.aienos.com/agents/RULES.md first. This file adds what is specific to this repository; where the two differ, this file wins here.

Scope

Installation

git clone https://github.com/aien-dev/aien-translate.git
cd aien-translate
cargo build --release

Needs a stable Rust toolchain. SQLite is bundled through rusqlite, so no system library is needed. The binary is target/release/aien-translate.

Running the server for real needs a model server that offers GET /v1/models and POST /v1/chat/completions (AIEN's aien-serve-http or any OpenAI-style chat server). The tests do not need one.

Configuration

All configuration is by flag; there is no config file and no environment variable besides HOME (used for the default cache path).

--listen           loopback address only
--engine           base URL of the model server
--cache            SQLite file for saved translations
--keep-file        names never translated, one per line (default: built-in list)
--auth-token-file  local proxy bearer secret (required for public-site proxying)

./target/release/aien-translate --help prints the defaults. The listener refuses non-loopback addresses. Public browser traffic must use a same-origin authenticated and per-visitor-rate-limited reverse proxy; the browser never receives the backend token. See README.md for the deployment contract.

Usage

# Unit tests and end-to-end tests against a fake model (no GPU, no network)
cargo test

# Flag summary and defaults
./target/release/aien-translate --help

# Run the server (needs a reachable model server)
./target/release/aien-translate --listen <addr:port> --engine <model-server-url>

# Check a running server
curl http://<addr:port>/health
curl -X POST http://<addr:port>/translate.json \
  -d 'from=english&to=japanese&text=%5B%22Hello%20world%22%5D'

Scripts (all need a running aien-translate; pass its address with --server URL):

python3 scripts/translate_readme.py [--server URL] [lang ...]   # writes docs/i18n/README.<code>.md
python3 scripts/translate_site.py DIST OUT --langs zh-CN,ja [--server URL] [--base-url URL]   # needs beautifulsoup4
python3 scripts/translate_latex.py paper.tex OUT_DIR --langs zh-CN,ja [--server URL] [--doi DOI] [--dry-run]
python3 demo/check.py URL   # needs Playwright and a served demo/ folder with translate.js

translate_latex.py --dry-run prints the pieces the model would see and translates nothing. translate_readme.py has no --help; unknown arguments are read as language codes.

Conventions

Safety and approvals

Further reading