text-translate/MODULE.md
flemming-it c54c14b28a
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
sign-bundle / sign (push) Failing after 1m51s
feat: selectable wire format — ollama (default), openai (vLLM etc.), anthropic
Port the multi-API client from llm.chat (llm.rs kept in lockstep):
the optional api input selects the dialect, default stays the
unchanged v0.1.x Ollama behavior. openai covers vLLM, LM Studio,
LiteLLM and cloud OpenAI; api-specific error hints; api_key sent
as Bearer (ollama/openai) or x-api-key (anthropic). model_digest
stays an Ollama-only best-effort probe and is documented as such.

Proven end-to-end against a hermetic OpenAI-wire fake (request
shape validated, response parsed) via a hub flow run.

Signed-off-by: flemming-it <sf@flemming.it>
2026-08-20 16:32:59 +02:00

3.7 KiB

text.translate

LLM-backed translation between languages (Ollama, vLLM, any OpenAI-compatible server, or Anthropic). Sends source text to a configured LLM endpoint with a translation system prompt and emits the translated text plus audit-grade model-provenance fields.

Capability

  • text.translate@0.1.0

Inputs

Name Type Description
text text Source text to translate.
target_language text Target language in plain English (e.g. German, French, ja-JP).
source_language text Optional source-language hint. Empty = let the model auto-detect.
endpoint text Chat endpoint URL matching the selected api (Ollama /api/chat, OpenAI-compatible /v1/chat/completions — vLLM etc., Anthropic /v1/messages).
api text Optional wire format: ollama (default), openai, anthropic.
model text Model identifier the endpoint serves (e.g. qwen2.5:14b).
api_key text Optional bearer token for cloud-hosted endpoints.

Outputs

Name Type Description
translation text The translated text.
source_language text Echo of the input value (or detected language when auto).
target_language text Echo of the input value.
model_endpoint text URL the translation was generated against.
model_name text Model identifier as supplied to the LLM API.
model_digest text SHA-256 digest of the served model — Ollama only, empty elsewhere.

The three model_* outputs are the audit primitive: every translation in the flow log can be matched to the exact model hash that produced it, even months later.

Permissions

permissions:
  - "net: localhost"
  - "net: 127.0.0.1"
  - "net: api.openai.com"
  - "net: api.anthropic.com"

The default policy allows local Ollama and the two major hosted providers. Operators with a private LLM endpoint add their hostname to the operator-policy ceiling; the module's permissions are enforced against that ceiling at install time.

Built for regulated environments

The Ollama endpoint defaults to a local daemon — source text never leaves the host. Cloud providers are opt-in via the endpoint URL + operator policy. The model_digest field is the cryptographic root-of-trust for translation provenance: two outputs with the same digest came from the same model weights, period.

Limits in v0.1.0

  • Single-shot translation. Long-document chunked translation with overlap-stitching is the v0.2.0 plan.
  • No glossary / terminology-list support. Operators currently rely on the model's general knowledge; a glossary input is on the v0.2.0 roadmap.

Example flow

name: translate-to-german
inputs:
  source: text
steps:
  - id: translate
    use: text.translate@^0
    with:
      text: $inputs.source
      target_language: "German"
      endpoint: "http://localhost:11434/api/chat"
      model: "qwen2.5:14b"
outputs:
  translation: $translate.translation
  audit_model: $translate.model_digest

Build

cargo build --release --target wasm32-wasip2
# Output: target/wasm32-wasip2/release/text_translate.wasm