[GH-ISSUE #2883] [Feature]: Customizable translation prompt presets #1466

Closed
opened 2026-10-21 05:35:56 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @qvazzar on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2883

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

The current translator in Marinara Engine uses a hardcoded system prompt with no way to customize it. Users who want to:

  • Change the translation instruction style (formal, casual, literary, etc.)
  • Add chat context for better translation quality
  • Include character names, user names, or conversation history in the prompt
  • Extract translations from markdown code blocks when the LLM wraps output in ```
  • Experiment with different prompt strategies for different scenarios

…have no way to do this without modifying the source code.

This was previously requested in issue #525, which was closed as scope-risk. This implementation addresses the scope concerns by keeping the change backward-compatible and limiting scope to prompt customization only — no sampler controls, no model changes, no reasoning visibility.

Proposed solution

Add a Translation Prompt Preset system, modeled after the existing impersonation prompt UI (as suggested in the original issue).

Presets

  • A new translation_prompts table stores named preset templates.
  • One built-in system preset is seeded on first startup:
    • Default — the exact original hardcoded prompt (backward compatible).
  • The system preset is read-only (cannot be modified or deleted).
  • Users can create, rename, edit, and delete their own presets.

Template variables (Handlebars)

Variable Description
{{text}} The text being translated
{{language}} Target language (from chat settings)
{{sourceLanguage}} Input language (optional, from chat settings)
{{charName}} Character name (for incoming messages)
{{userName}} User name (for outgoing messages)
{{chat}} Array of recent chat messages for context

Where custom prompts apply

Feature Prompt source
Manual translate button User's selected preset
Auto-Translate Responses User's selected preset
Translate My Messages User's selected preset
Chat Context Messages Configurable (0-20 last messages, per-chat)
Filter Code Block Per-preset toggle, extracts text from ``` blocks

UI (Chat Settings → Translation, AI mode)

Dropdown with preset list, create/rename/delete buttons, editable textarea (debounced auto-save), filter code block checkbox, chat context count. System preset shown in read-only mode.

Alternatives considered

  1. Server-side template rendering — renders Handlebars on the server instead of the client. Rejected because it requires sending chat context in the translate request, which the client already has.

  2. Single per-chat override field — a single textarea override without presets. Rejected because presets are reusable across chats and provide better UX.

  3. Extending the existing translate endpoint with hardcoded options — rejected because it doesn't scale (each new variation would require code changes).

Additional context

  • Issue #525 — original feature request that motivated this implementation
  • SillyTavern Magic Translation — reference implementation with customizable prompts
  • Backward compatible — unconfigured chats use the exact same hardcoded prompt as before. No database migration needed (file-storage compatible). System presets are protected.
  • Manual verification performed:
    • Custom prompt renders correctly in manual translate
    • Custom prompt applies to auto-translate (AI responses)
    • Custom prompt applies to Translate My Messages (user input)
    • Preset CRUD works (create, rename, edit, delete)
    • System presets cannot be modified or deleted
    • Filter code block extraction works
    • Chat context is included in the rendered prompt in manual translate
    • Backward compatible: Google Translate, DeepL, and unconfigured AI continue to work
    • pnpm check passes

Implementation ready — the feature is fully implemented and tested on a local fork. A draft PR against staging can be opened once the direction is agreed upon.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • [] I DID NOT read this template and provide the requested details.
Originally created by @qvazzar on GitHub (Jun 27, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2883 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? The current translator in Marinara Engine uses a hardcoded system prompt with no way to customize it. Users who want to: - Change the translation instruction style (formal, casual, literary, etc.) - Add chat context for better translation quality - Include character names, user names, or conversation history in the prompt - Extract translations from markdown code blocks when the LLM wraps output in ``` - Experiment with different prompt strategies for different scenarios …have no way to do this without modifying the source code. This was previously requested in issue #525, which was closed as `scope-risk`. This implementation addresses the scope concerns by keeping the change backward-compatible and limiting scope to prompt customization only — no sampler controls, no model changes, no reasoning visibility. ## Proposed solution Add a **Translation Prompt Preset** system, modeled after the existing impersonation prompt UI (as suggested in the original issue). ### Presets - A new `translation_prompts` table stores named preset templates. - One built-in system preset is seeded on first startup: - **Default** — the exact original hardcoded prompt (backward compatible). - The system preset is **read-only** (cannot be modified or deleted). - Users can create, rename, edit, and delete their own presets. ### Template variables (Handlebars) | Variable | Description | |----------|-------------| | `{{text}}` | The text being translated | | `{{language}}` | Target language (from chat settings) | | `{{sourceLanguage}}` | Input language (optional, from chat settings) | | `{{charName}}` | Character name (for incoming messages) | | `{{userName}}` | User name (for outgoing messages) | | `{{chat}}` | Array of recent chat messages for context | ### Where custom prompts apply | Feature | Prompt source | |---------|-------------| | Manual translate button | User's selected preset | | Auto-Translate Responses | User's selected preset | | Translate My Messages | User's selected preset | | Chat Context Messages | Configurable (0-20 last messages, per-chat) | | Filter Code Block | Per-preset toggle, extracts text from ``` blocks | ### UI (Chat Settings → Translation, AI mode) Dropdown with preset list, create/rename/delete buttons, editable textarea (debounced auto-save), filter code block checkbox, chat context count. System preset shown in read-only mode. ## Alternatives considered 1. **Server-side template rendering** — renders Handlebars on the server instead of the client. Rejected because it requires sending chat context in the translate request, which the client already has. 2. **Single per-chat override field** — a single textarea override without presets. Rejected because presets are reusable across chats and provide better UX. 3. **Extending the existing translate endpoint with hardcoded options** — rejected because it doesn't scale (each new variation would require code changes). ## Additional context - **Issue #525** — original feature request that motivated this implementation - **SillyTavern Magic Translation** — reference implementation with customizable prompts - **Backward compatible** — unconfigured chats use the exact same hardcoded prompt as before. No database migration needed (file-storage compatible). System presets are protected. - **Manual verification performed:** - Custom prompt renders correctly in manual translate - Custom prompt applies to auto-translate (AI responses) - Custom prompt applies to Translate My Messages (user input) - Preset CRUD works (create, rename, edit, delete) - System presets cannot be modified or deleted - Filter code block extraction works - Chat context is included in the rendered prompt in manual translate - Backward compatible: Google Translate, DeepL, and unconfigured AI continue to work - `pnpm check` passes **Implementation ready** — the feature is fully implemented and tested on a local fork. A draft PR against `staging` can be opened once the direction is agreed upon. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:35:56 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jun 27, 2026):

Sure, I'll add the prompt to edit in the Translation section of Chat Settings in any mode. Will make it so the new prompt replaces the default one, but you will have an option to restore the original.

<!-- gh-comment-id:4816391869 --> @SpicyMarinara commented on GitHub (Jun 27, 2026): Sure, I'll add the prompt to edit in the Translation section of Chat Settings in any mode. Will make it so the new prompt replaces the default one, but you will have an option to restore the original.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 27, 2026):

Implemented the AI translation prompt override in Chat Settings.

What changed:

  • Added a Translation -> AI Prompt field that shows the built-in default and stores only chat-local overrides.
  • Added a Restore action to return to the built-in default prompt.
  • Sent the configured prompt through manual message translation, draft translation, and auto-translate after generation.
  • Updated the translate API to accept the optional system prompt while keeping the existing default fallback.

Validation:

  • pnpm build:shared
  • pnpm --filter @marinara-engine/server lint
  • pnpm --filter @marinara-engine/client lint
  • git diff --check
<!-- gh-comment-id:4816482683 --> @SpicyMarinara commented on GitHub (Jun 27, 2026): Implemented the AI translation prompt override in Chat Settings. What changed: - Added a Translation -> AI Prompt field that shows the built-in default and stores only chat-local overrides. - Added a Restore action to return to the built-in default prompt. - Sent the configured prompt through manual message translation, draft translation, and auto-translate after generation. - Updated the translate API to accept the optional system prompt while keeping the existing default fallback. Validation: - pnpm build:shared - pnpm --filter @marinara-engine/server lint - pnpm --filter @marinara-engine/client lint - git diff --check
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1466
No description provided.