AI 0.4.0: The AI translation tools move into the AI module
AI 0.4.0 takes over AI translation from PhoenixKit core. The AI Translate dialog that content modules show next to their forms, and the background jobs behind it, are now part of the AI module, with a sturdier way of reading the model’s answer.
Translation in one place
A module whose content can be translated, such as a catalogue or a publishing post, now only supplies a small adapter: how to load a record, which fields to send and how to store the result. It lists its adapters through ai_translatables/0, and the AI module finds them. The AI module does the rest: queuing one background job per language, skipping a language that is already being translated, calling the endpoint with the chosen prompt, reading the reply and reporting progress back to the open form.
In the dialog you pick an endpoint and a translation prompt, then translate the current language, only the missing languages, or all languages, which overwrites existing translations. If no translation prompt exists, Generate Default Prompt creates one.
Reasoning models
Some models write out their thinking before the answer. The reply parser now removes complete thinking blocks first, and only reads a section marker at the start of a line, so reasoning that mentions a marker can no longer be stored as a translation. A reply with no usable sections now fails cleanly instead. Under the endpoint choice, the dialog notes that reasoning models are slower and that a standard model is recommended for translation.
Fixes
A finished translation is now applied to an open form only for the languages that form asked for. Translations started in another tab on the same record no longer overwrite unsaved edits.
Upgrading
No migration. The jobs run on Oban’s default queue.
Full release notes: AI 0.4.0
0.4.0 · 8 June 2026
Added
- AI translation pipeline + UI (moved from core). A generic, multi-consumer AI-translation layer now lives in the plugin; consumers (publishing/catalogue/projects) wire in a tiny adapter + form binding and get the rest for free:
PhoenixKitAI.Translatable— adapter behaviour:fetch/2, optional scopedfetch/3,source_fields/2,put_translation/4, optionalpubsub_topics/1PhoenixKitAI.Translation— theask_with_prompt/4call + structured---FIELD---response parser, with every failure path normalized to{:error, atom_or_tuple}PhoenixKitAI.Translations— enqueue, scope-aware in-flight dedup, payload-minimal PubSub broadcasts,missing_languages/3, and idempotent default endpoint/prompt provisioningPhoenixKitAI.TranslateWorker— the generic Oban worker (threadsresource_scopetofetch/3when the adapter exports it; transient-vs-deterministic retry/snooze/discard classification)PhoenixKitAI.Translatables— duck-typed adapter discovery scanningPhoenixKit.ModuleRegistryforai_translatables/0PhoenixKitAI.Components.AITranslate{,.Embed,.FormBinding,.FormGlue}— the shared AI-translate modal UI + LiveView state/progress/stall glue
- Reasoning-model parser hardening (
PhoenixKitAI.Translation.parse_response/2): strips balanced<think>/<thinking>/<reasoning>/<thought>blocks before parsing (an unclosed block is left intact so a real answer is never deleted) and anchors opening---MARKER---to start-of-line, so chain-of-thought that mentions a marker inline can’t open a section. Reasoning output degrades to a clean:no_markersparse error instead of a mis-parsed blob that overflowed a consumer’s column on persist. PhoenixKitAI.Routes.ai_path/0— plugin-owned/admin/aipath helper (was a module-specific helper in core’sPhoenixKit.Utils.Routes)- Reasoning-model UX hint under the endpoint selector in the AI-translate modal: reasoning models are slower and may return unstructured output — prefer a standard model for translation
- Env-gated local-path dep override in
mix.exs(<APP>_PATH, e.g.PHOENIX_KIT_PATH=../phoenix_kit) for cross-repo development; unset resolves to the published Hex pin, somix deps.get/mix hex.publish/ CI are unaffected
Changed
- Dependency refresh (
mix.lock)
Fixed
- AI-translate form applies a completed translation to the live changeset only for languages this session dispatched — a translation triggered in another session/tab on the same resource no longer clobbers unsaved edits
mix precommitgreen end to end (credo--strict0 issues, dialyzer 0 errors): closed pre-existing alias-order / nesting / alias-usage findings via behavior-preserving extraction, and removed a dialyzer-dead clause inTranslation
AI 0.4.0. Install or update: {:phoenix_kit_ai, "~> 0.4"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.