context message

Co-authored-by: APodoinikov <APodoynikov@detmir.ru>
This commit is contained in:
illian64 2025-09-28 09:52:02 +07:00 committed by GitHub
parent 5a2f225955
commit a82b52fd7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 10 additions and 10 deletions

View file

@ -107,6 +107,6 @@ def get_context(items_to_context: list[str], params: FileProcessingContextParams
if len(result_list) == 0:
return None
else:
return params.prompt.replace("%%context%%", params.paragraph_join_str.join(result_list))
return params.prompt.replace("%%context_text%%", params.paragraph_join_str.join(result_list))
else:
return None

View file

@ -49,8 +49,8 @@
Для этого берется несколько предыдущих параграфов из текста и добавляется, как контекст для перевода.
* * * enabled - включено или выключено добавление контекста.
* * * prompt - текст, описывающий контекст и содержимое нескольких параграфов текста, который следует до переводимого.
Текст должен содержать сам запрос и слово `%%context%%`, которое будет заменено на предыдущий текст в файле.
В общем виде контекст должен быть такой: `Используй этот контекст для улучшений перевода. Контекст:\n%%context%%\n`
Текст должен содержать сам запрос и слово `%%context_text%%`, которое будет заменено на предыдущий текст в файле.
В общем виде контекст должен быть такой: `Используй этот контекст для улучшений перевода. Контекст:\n%%context_text%%\n`
* * * expected_length - длина котекста (без описания) недолжна быть более этой длины (параметр `include_at_least_one_paragraph` может изменить это поведение)
* * * include_at_least_one_paragraph - включить как минимум один параграф из текста ранее, даже если его длина боле, чем `expected_length`.
* * * paragraph_join_str - символ для соединения параграфов контекста, если их более одного.
@ -121,7 +121,7 @@
1. 100 (100 + следующий параграф 700 больше, чем ограничение 500)
2. 700 (700 больше, чем ограничение в 500, но хотя бы один параграф в части должен быть обязательно)
3. 250, 50, 50 (200 + 50 + 50 = 300, меньше, чем ограничение в 500, но следующий параграф - 400, уже больше ограничения)
4. 400 (меньше чем ограничение в 500, но следующий параграф - 200, превысит ограничение)
4. 400 (меньше чем ограничение в 500, но следующий параграф - 150, 400 + 150 превысит ограничение)
5. 150, 200 - (меньше чем ограничение в 500)
Аналогичное разбиение будет выполнено и при включенном параметре `split_by_sentences_and_length` и `split_expected_length` = 500, и

View file

@ -72,13 +72,13 @@ http://127.0.0.1:4990/translate?text=hi&from_lang=en&to_lang=ru&context=context&
* **kobold_cpp** - [проект](https://github.com/LostRuins/koboldcpp), [документация](plugins-translate/kobold_cpp.md).
Внешний инструмент для работы с моделями.
Поддерживаются основные популярные модели - Qwen, mistral, gpt-oss и другие.
Требуется запустить KoboldCpp, загрузить и открыть в нем необходимую модель.
Требуется запустить KoboldCpp, загрузить необходимую модель, настроить и открыть ее.
* **lm_studio** - [проект](https://github.com/LostRuins/koboldcpp), [документация](plugins-translate/lm_studio.md).
Внешний инструмент для работы с моделями.
Поддерживаются основные популярные модели - Qwen, gemma, mistral, gpt-oss и другие.
Требуется запустить LM Studio, загрузить и открыть в нем необходимую модель.
Требуется запустить LM Studio, загрузить необходимую модель, настроить и открыть ее.
* **madlad_400_ctranslate2** - [проект](https://huggingface.co/docs/transformers/model_doc/madlad-400) (A Multilingual And Document-Level Large Audited Dataset),

View file

@ -66,7 +66,7 @@ manifest = {
"overwrite_processed_files": True,
"context": {
"enabled": True,
"prompt": "To improve the translation, use the following context, which is the paragraphs that preceded the text to be translated. Context: %%context%%",
"context_message": "Use the given context to improve the quality and consistency of the translation. Don't include this context or any piece in your answer.\nCONTEXT (preceding text):\"\"\"\n%%context_text%%\n\"\"\"\n",
"expected_length": 500,
"include_at_least_one_paragraph": True,
"paragraph_join_str": "\n",

View file

@ -19,7 +19,7 @@ def start(core: AppCore):
"default_options": {
"custom_url": "http://127.0.0.1:5001", #
"prompt": "You are professional translator. Translate text from %%from_lang%% to %%to_lang%%. Don't add any notes or any additional info in your answer, write only translate. Text: ",
"prompt": "You are a professional translator from %%from_lang%% to %%to_lang%%. Your task is to translate a text provided below.\n%%context_prompt%%\nINSTRUCTION:Carefully analyze the context. Pay special attention to Terminology, Style, Consistency. Provide only the translation. Do not include any additional information, explanations, notes, or comments in your response. The output should be the pure translated text only.\nTEXT TO TRANSLATE:",
"prompt_postfix": "",
"prompt_no_think_postfix": False,
},

View file

@ -20,7 +20,7 @@ def start(core: AppCore):
"default_options": {
"custom_url": "http://localhost:1234", #
"prompt": "You are professional translator. Translate text from %%from_lang%% to %%to_lang%%. Don't add any notes or any additional info in your answer, write only translate. Text: ",
"prompt": "You are a professional translator from %%from_lang%% to %%to_lang%%. Your task is to translate a text provided below.\n%%context_prompt%%\nINSTRUCTION:Carefully analyze the context. Pay special attention to Terminology, Style, Consistency. Provide only the translation. Do not include any additional information, explanations, notes, or comments in your response. The output should be the pure translated text only.\nTEXT TO TRANSLATE:",
"prompt_postfix": "",
"prompt_no_think_postfix": False,
"use_library_for_request": True,

View file

@ -15,7 +15,7 @@ class FileProcessTest(TestCase):
def test_get_context(self):
items_to_context = ["111", "222", "333", "444", "555"]
params = FileProcessingContextParams(enabled=True, prompt="Use context: %%context%%", expected_length=9,
params = FileProcessingContextParams(enabled=True, prompt="Use context: %%context_text%%", expected_length=9,
include_at_least_one_paragraph=True, paragraph_join_str="\n")
context = file_processor.get_context(items_to_context, params, "000")