markdown-flow 0.2.16__py3-none-any.whl → 0.2.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of markdown-flow might be problematic. Click here for more details.
- markdown_flow/__init__.py +1 -1
- markdown_flow/constants.py +43 -18
- markdown_flow/core.py +71 -502
- markdown_flow/llm.py +7 -9
- markdown_flow/utils.py +6 -8
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/METADATA +36 -118
- markdown_flow-0.2.17.dist-info/RECORD +13 -0
- markdown_flow-0.2.16.dist-info/RECORD +0 -13
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/WHEEL +0 -0
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/licenses/LICENSE +0 -0
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/top_level.txt +0 -0
markdown_flow/__init__.py
CHANGED
markdown_flow/constants.py
CHANGED
|
@@ -9,7 +9,7 @@ import re
|
|
|
9
9
|
|
|
10
10
|
# Pre-compiled regex patterns
|
|
11
11
|
COMPILED_PERCENT_VARIABLE_REGEX = re.compile(
|
|
12
|
-
r"%\{\{([
|
|
12
|
+
r"%\{\{([^}]+)\}\}" # Match %{{variable}} format for preserved variables
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
# Interaction regex base patterns
|
|
@@ -20,11 +20,11 @@ INTERACTION_PATTERN_SPLIT = r"((?<!\\)\?\[[^\]]*\](?!\())" # Pattern for re.spl
|
|
|
20
20
|
# InteractionParser specific regex patterns
|
|
21
21
|
COMPILED_INTERACTION_REGEX = re.compile(INTERACTION_PATTERN) # Main interaction pattern matcher
|
|
22
22
|
COMPILED_LAYER1_INTERACTION_REGEX = COMPILED_INTERACTION_REGEX # Layer 1: Basic format validation (alias)
|
|
23
|
-
COMPILED_LAYER2_VARIABLE_REGEX = re.compile(r"^%\{\{([
|
|
23
|
+
COMPILED_LAYER2_VARIABLE_REGEX = re.compile(r"^%\{\{([^}]+)\}\}(.*)$") # Layer 2: Variable detection
|
|
24
24
|
COMPILED_LAYER3_ELLIPSIS_REGEX = re.compile(r"^(.*)\.\.\.(.*)") # Layer 3: Split content around ellipsis
|
|
25
25
|
COMPILED_LAYER3_BUTTON_VALUE_REGEX = re.compile(r"^(.+)//(.+)$") # Layer 3: Parse Button//value format
|
|
26
26
|
COMPILED_BRACE_VARIABLE_REGEX = re.compile(
|
|
27
|
-
r"(?<!%)\{\{([
|
|
27
|
+
r"(?<!%)\{\{([^}]+)\}\}" # Match {{variable}} format for replaceable variables
|
|
28
28
|
)
|
|
29
29
|
COMPILED_INTERACTION_CONTENT_RECONSTRUCT_REGEX = re.compile(
|
|
30
30
|
r"(\?\[[^]]*\.\.\.)([^]]*\])" # Reconstruct interaction content: prefix + question + suffix
|
|
@@ -47,8 +47,8 @@ INLINE_PRESERVE_PATTERN = r"^===(.+)=== *$"
|
|
|
47
47
|
COMPILED_INLINE_PRESERVE_REGEX = re.compile(INLINE_PRESERVE_PATTERN)
|
|
48
48
|
|
|
49
49
|
# Output instruction markers
|
|
50
|
-
OUTPUT_INSTRUCTION_PREFIX = "
|
|
51
|
-
OUTPUT_INSTRUCTION_SUFFIX = "
|
|
50
|
+
OUTPUT_INSTRUCTION_PREFIX = "<preserve_or_translate>"
|
|
51
|
+
OUTPUT_INSTRUCTION_SUFFIX = "</preserve_or_translate>"
|
|
52
52
|
|
|
53
53
|
# System message templates
|
|
54
54
|
DEFAULT_VALIDATION_SYSTEM_MESSAGE = "你是一个输入验证助手,需要严格按照指定的格式和规则处理用户输入。"
|
|
@@ -90,19 +90,44 @@ VALIDATION_RESPONSE_OK = "ok"
|
|
|
90
90
|
VALIDATION_RESPONSE_ILLEGAL = "illegal"
|
|
91
91
|
|
|
92
92
|
# Output instruction processing
|
|
93
|
-
OUTPUT_INSTRUCTION_EXPLANATION = f"""
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
93
|
+
OUTPUT_INSTRUCTION_EXPLANATION = f"""<preserve_or_translate_instruction>
|
|
94
|
+
对{OUTPUT_INSTRUCTION_PREFIX}{OUTPUT_INSTRUCTION_SUFFIX}标记之间的内容的处理规则:
|
|
95
|
+
|
|
96
|
+
<default_behavior>
|
|
97
|
+
默认行为: 完全保持原样输出
|
|
98
|
+
- 标记之间的内容必须逐字原样输出
|
|
99
|
+
- 严禁改写、润色、优化或调整任何表达方式
|
|
100
|
+
- 严禁添加、删除或替换任何文字
|
|
101
|
+
</default_behavior>
|
|
102
|
+
|
|
103
|
+
<exception_rule>
|
|
104
|
+
唯一例外: 语言翻译
|
|
105
|
+
- 仅当内容需要从一种语言翻译成另一种语言时,才可以翻译
|
|
106
|
+
- 翻译时必须保持原文的完整含义、语气和格式
|
|
107
|
+
- 如果内容无需翻译,则绝对不允许做任何改动
|
|
108
|
+
</exception_rule>
|
|
109
|
+
|
|
110
|
+
<output_requirement>
|
|
111
|
+
输出要求:
|
|
112
|
+
- 不要输出{OUTPUT_INSTRUCTION_PREFIX}{OUTPUT_INSTRUCTION_SUFFIX}标记本身
|
|
113
|
+
- 只输出标记之间的实际内容
|
|
114
|
+
</output_requirement>
|
|
115
|
+
|
|
116
|
+
<examples>
|
|
117
|
+
示例1 - 保持原样:
|
|
118
|
+
<original_content>{OUTPUT_INSTRUCTION_PREFIX}**下面我们做个练习。**{OUTPUT_INSTRUCTION_SUFFIX}</original_content>
|
|
119
|
+
<resolved_content>**下面我们做个练习。**</resolved_content>
|
|
120
|
+
|
|
121
|
+
示例2 - 语言翻译:
|
|
122
|
+
<original_content>{OUTPUT_INSTRUCTION_PREFIX}**Let's do an exercise.**{OUTPUT_INSTRUCTION_SUFFIX}</original_content>
|
|
123
|
+
<resolved_content>**让我们做个练习。**</resolved_content>
|
|
124
|
+
|
|
125
|
+
示例3 - 错误示范(同语言改写):
|
|
126
|
+
<original_content>{OUTPUT_INSTRUCTION_PREFIX}**下面我们做个练习。**{OUTPUT_INSTRUCTION_SUFFIX}</original_content>
|
|
127
|
+
<wrong_output>**来,咱们做个有趣的小练习**</wrong_output>
|
|
128
|
+
<reason>错误: 擅自改写了中文内容</reason>
|
|
129
|
+
</examples>
|
|
130
|
+
</preserve_or_translate_instruction>
|
|
106
131
|
|
|
107
132
|
"""
|
|
108
133
|
|