Skip to content

seconv: advanced translate engine settings in the --settings file (#16373) - #16820

Merged
niksedk merged 2 commits into
SubtitleEdit:mainfrom
Makar8000:claude/seconv-advanced-translate-settings-16373
Nov 10, 2026
Merged

niksedk merged 2 commits into
SubtitleEdit:mainfrom
Makar8000:claude/seconv-advanced-translate-settings-16373

Conversation

@Makar8000

@Makar8000 Makar8000 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Third and last PR for #16373, after #16607 and #16814: the issue's remaining item, "the same keys in the --settings JSON".

Changes

  • A tools.llamaCppAdvanced section in the --settings file with the 15 settings of the GUI's "Advanced..." dialog: batchSize, historyPairs, synopsis, glossary, formality, keepLineBreaks, prompt, temperature, topP, topK, repeatPenalty, maxTokens, contextSize, serverArguments, serverArgumentsOnly. Every key is optional and a key left out keeps the dialog's default. The regular engines ignore the section, so one file serves both engine families.
  • Precedence: an option given on the command line wins over the file, the file over the dialog's defaults (--translate-prompt > tools.llamaCppAdvanced.prompt > built-in). profiles overlay the section like the other sections, so a profile can carry e.g. a per-film synopsis.
  • Implemented like exportImages, the other section that does not live in libse's Configuration: SeConvSettings.ApplyLlamaCppAdvanced overlays the section (base, then profile) onto a SeLlamaCppAdvanced that travels on ConversionOptions.TranslateAdvancedSettings, and AutoTranslateRunner.CreateAdvancedSettings takes it as the base and applies the options on top. The merged result is validated once (batch size and history ranges, {2} in the prompt), so a bad value from the file fails before any conversion with a message naming both sources, and a bad formality fails while the file is loaded. ConvertCommand therefore builds the advanced settings after the file is loaded instead of before it.
  • dump-settings emits the section with the dialog's defaults, and unknown keys inside it are reported like the others (tools.llamaCppAdvanced.<key>).
  • Docs: the --settings row, the Settings JSON listing and prose, a paragraph with an example in the Advanced local engines section, and a mention on the advanced-engines feature page.

Verification

  • dotnet test tests/seconv: 711 passed (9 new), 2 pre-existing skips. New: the section parses with a typo inside it reported, a profile overlays the base, a bad formality throws, dump-settings emits all 15 keys (the existing round-trip test keeps every emitted key loadable), file values act as the base with the option winning, out-of-range and {2} values from the file are refused, and the regular engine ignores the section.
  • The dump-settings listing in the docs is identical to the real output.
  • Real run with llama-server started from PATH and Hy-MT2: a file with synopsis, glossary, contextSize: 8192 and serverArguments: "--cache-reuse 256" plus a profile setting formality: informal, with --translate-batch-size:4 on the command line. The server started with -c 8192 --cache-reuse 256, the 10 lines went out in batches of 4, the glossary term and the informal address are in the output, and the server stopped at exit. Validation of file values, checked with deliberately bad input: formality: "polite" is rejected while the file is loaded, batchSize: 60 is rejected before any conversion starts unless --translate-batch-size overrides it, and the regular llamacpp engine ignores the section.
  • Drafted with AI assistance (Claude Code); the tests and runs above were performed as listed.

🤖 Generated with Claude Code

…btitleEdit#16373)

The --settings file gets a tools.llamaCppAdvanced section with the 15
settings of the GUI's "Advanced..." dialog (batchSize, historyPairs,
synopsis, glossary, formality, keepLineBreaks, prompt, the sampling values,
contextSize, serverArguments, serverArgumentsOnly). Every key is optional; a
command-line option wins over the file and the file over the dialog's
defaults; profiles overlay the section like the others; the regular engines
ignore it.

Like exportImages, the section does not go through libse's Configuration:
SeConvSettings.ApplyLlamaCppAdvanced overlays it onto a SeLlamaCppAdvanced
carried by ConversionOptions.TranslateAdvancedSettings, and
AutoTranslateRunner.CreateAdvancedSettings applies the options on top of
that base. The merged result is validated once, so a bad value from either
source fails before any conversion; ConvertCommand therefore builds the
advanced settings after the file is loaded. dump-settings emits the section
with the dialog's defaults.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The CLI reference and settings documentation incorrectly imply that -1 preserves server defaults instead of explaining the sampling, temperature, and token-limit fallbacks.

1 open issue
What changed in this PR

Completes the settings-file support requested in #16373 by exposing the advanced translation engines’ GUI settings to seconv, building on #16607 and #16814.

Changes:

  • Adds 15 optional tools.llamaCppAdvanced settings, profile overlays, and default-settings output.
  • Applies command-line overrides before validating merged advanced settings.
  • Adds focused tests and documents configuration and precedence.
File Description
tests/​seconv/​Core/​SeConvSettingsTest.cs Tests parsing, profile overlays, unknown keys, and formality validation.
tests/​seconv/​Core/​SeConvSettingsDumpTest.cs Checks advanced-settings defaults and emitted key count.
tests/​seconv/​Core/​AutoTranslateRunnerTest.cs Tests precedence, validation, and regular-engine isolation.
src/​seconv/​Core/​SubtitleConverter.cs Carries advanced settings in conversion options.
src/​seconv/​Core/​SeConvSettings.cs Defines, overlays, and dumps the new settings section.
src/​seconv/​Core/​AutoTranslateRunner.cs Merges file settings with command-line options and validates them.
src/​seconv/​Commands/​ConvertCommand.cs Loads file settings before advanced-settings validation.
docs/​reference/​command-line.md Documents keys, defaults, precedence, and examples.
docs/​features/​auto-translate-advanced.md Links advanced-engine usage to settings-file support.

Review effort: Balanced

Comment thread docs/reference/command-line.md Resolved
Updated the `exportImages` section to clarify the handling of optional keys and sampling values, and added details on key recognition for backward compatibility.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@niksedk
niksedk merged commit bc97dd6 into SubtitleEdit:main Nov 10, 2026
4 checks passed
@Makar8000
Makar8000 deleted the claude/seconv-advanced-translate-settings-16373 branch November 11, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants