Files
ss-tools/backend/src/plugins/translate/preview_constants.py
2026-05-20 23:54:53 +03:00

49 lines
2.9 KiB
Python

# #region DEFAULT_EXECUTION_PROMPT_TEMPLATE [C:1] [TYPE Block] [SEMANTICS prompt, template]
# @BRIEF Default LLM prompt template for full execution (batch translation).
# Language detection is handled locally (lingua) — prompt does not request
# detected_source_language, saving LLM tokens.
# Supports both single-language and multi-language modes via {target_languages} placeholder.
DEFAULT_EXECUTION_PROMPT_TEMPLATE: str = (
"Translate the following database content from {source_language} to the following language(s): {target_languages}.\n\n"
"Source dialect: {source_dialect}\n"
"Target dialect(s): {target_dialect}\n"
"Column to translate: {translation_column}\n\n"
"{dictionary_section}"
"IMPORTANT — You MUST use the terminology dictionary above. "
"For any source term listed in the dictionary, you MUST use its exact target translation. "
"Do not translate dictionary terms differently. "
"This is mandatory, not optional.\n\n"
"For each row, provide an accurate translation of the text into each target language.\n\n"
"Rows to translate:\n{rows_json}\n\n"
"Respond with a JSON object in this exact format:\n"
'{{"rows": [{{"row_id": "<row_index>", "<language_code_1>": "<translation_in_lang_1>", "<language_code_2>": "<translation_in_lang_2>"}}]}}\n'
"Include a separate key for EACH target language code with the translated text in that language.\n"
"Each row_id must match the index provided. Return exactly {row_count} entries."
)
# #endregion DEFAULT_EXECUTION_PROMPT_TEMPLATE
# #region DEFAULT_PREVIEW_PROMPT_TEMPLATE [C:1] [TYPE Constant] [SEMANTICS prompt, template]
# @BRIEF Default LLM prompt template for preview (sample translation).
DEFAULT_PREVIEW_PROMPT_TEMPLATE: str = (
"Translate the following database content.\n\n"
"Source dialect: {source_dialect}\n"
"Column to translate: {translation_column}\n\n"
"{dictionary_section}"
"IMPORTANT — You MUST use the terminology dictionary above. "
"For any source term listed in the dictionary, you MUST use its exact target translation. "
"Do not translate dictionary terms differently. "
"This is mandatory, not optional.\n\n"
"Translate to the following languages: {target_languages}\n\n"
"For each row, provide an accurate translation of the '{translation_column}' value into each language.\n"
"Consider the context columns when determining the meaning of the text.\n\n"
"Rows to translate:\n{rows_json}\n\n"
"Respond with a JSON object in this exact format:\n"
'{{"rows": [{{"row_id": "<row_index>", "language_code_1": "<translation_in_lang_1>", "language_code_2": "<translation_in_lang_2>"}}]}}\n'
"Include a separate key for EACH target language code with the translated text in that language.\n"
"Each row_id must match the index provided. Return exactly {row_count} entries."
)
# #endregion DEFAULT_PREVIEW_PROMPT_TEMPLATE