markdown-flow 0.2.73__tar.gz → 0.2.74__tar.gz
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.
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/PKG-INFO +1 -1
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/__init__.py +1 -1
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/constants.py +2 -2
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/core.py +6 -6
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/output.py +3 -3
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/variable.py +1 -1
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/tag_filter.py +4 -4
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow.egg-info/PKG-INFO +1 -1
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/LICENSE +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/README.md +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/constants_system_prompt.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/enums.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/exceptions.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/formatter/__init__.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/formatter/classifier.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/formatter/format.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/formatter/patterns.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/formatter/stream.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/formatter/types.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/llm.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/models.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/__init__.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/code_fence_utils.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/html_comment_utils.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/interaction.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/json_parser.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/preprocessor.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/parser/validation.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/providers/__init__.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/providers/config.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/providers/openai.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/system_prompt.md +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow/utils.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow.egg-info/SOURCES.txt +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow.egg-info/dependency_links.txt +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/markdown_flow.egg-info/top_level.txt +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/pyproject.toml +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/setup.cfg +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_dynamic_interaction.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_formatter.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_formatter_stream.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_html_comment_utils.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_markdownflow_basic.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_parser_interaction.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_parser_output.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_parser_variable.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_preprocessor.py +0 -0
- {markdown_flow-0.2.73 → markdown_flow-0.2.74}/tests/test_preserved_simple.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown-flow
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.74
|
|
4
4
|
Summary: An agent library designed to parse and process MarkdownFlow documents
|
|
5
5
|
Project-URL: Homepage, https://github.com/ai-shifu/markdown-flow-agent-py
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/ai-shifu/markdown-flow-agent-py/issues
|
|
@@ -70,8 +70,8 @@ JSON_OBJECT_PATTERN = r"\{(?:[^{}]|(?:\{[^{}]*\}))*\}"
|
|
|
70
70
|
COMPILED_JSON_OBJECT_REGEX = re.compile(JSON_OBJECT_PATTERN)
|
|
71
71
|
|
|
72
72
|
# Output instruction markers
|
|
73
|
-
OUTPUT_INSTRUCTION_PREFIX = "
|
|
74
|
-
OUTPUT_INSTRUCTION_SUFFIX = "
|
|
73
|
+
OUTPUT_INSTRUCTION_PREFIX = "<原样输出>"
|
|
74
|
+
OUTPUT_INSTRUCTION_SUFFIX = "</原样输出>"
|
|
75
75
|
|
|
76
76
|
# Output Language Control - Three-layer anchoring templates
|
|
77
77
|
OUTPUT_LANGUAGE_INSTRUCTION_TOP = """<output_language_override>
|
|
@@ -553,7 +553,7 @@ class MarkdownFlow:
|
|
|
553
553
|
raise ValueError(LLM_PROVIDER_REQUIRED_ERROR)
|
|
554
554
|
|
|
555
555
|
content = self._llm_provider.complete(messages, model=self._model, temperature=self._temperature)
|
|
556
|
-
# 过滤 LLM 输出中可能泄露的
|
|
556
|
+
# 过滤 LLM 输出中可能泄露的 原样输出 标签
|
|
557
557
|
content = strip_preserve_tags(content)
|
|
558
558
|
result = LLMResult(content=content, prompt=messages[-1]["content"])
|
|
559
559
|
if content:
|
|
@@ -569,7 +569,7 @@ class MarkdownFlow:
|
|
|
569
569
|
stream_fmt = StreamFormatter()
|
|
570
570
|
prompt_text = messages[-1]["content"]
|
|
571
571
|
for chunk in self._llm_provider.stream(messages, model=self._model, temperature=self._temperature): # type: ignore[attr-defined]
|
|
572
|
-
# 过滤
|
|
572
|
+
# 过滤 原样输出 标签(处理跨 chunk 分割)
|
|
573
573
|
filtered = tag_filter.process(chunk)
|
|
574
574
|
if filtered:
|
|
575
575
|
for elem in stream_fmt.process(filtered):
|
|
@@ -711,7 +711,7 @@ class MarkdownFlow:
|
|
|
711
711
|
# Reconstruct interaction content with translation
|
|
712
712
|
translated_content = self._reconstruct_with_translation(processed_block.content, translatable_json, translated_json, interaction_info)
|
|
713
713
|
|
|
714
|
-
# 过滤 LLM 输出中可能泄露的
|
|
714
|
+
# 过滤 LLM 输出中可能泄露的 原样输出 标签
|
|
715
715
|
translated_content = strip_preserve_tags(translated_content)
|
|
716
716
|
|
|
717
717
|
return LLMResult(
|
|
@@ -753,7 +753,7 @@ class MarkdownFlow:
|
|
|
753
753
|
# Reconstruct interaction content with translation
|
|
754
754
|
translated_content = self._reconstruct_with_translation(processed_block.content, translatable_json, full_response, interaction_info)
|
|
755
755
|
|
|
756
|
-
# 过滤 LLM 输出中可能泄露的
|
|
756
|
+
# 过滤 LLM 输出中可能泄露的 原样输出 标签
|
|
757
757
|
translated_content = strip_preserve_tags(translated_content)
|
|
758
758
|
|
|
759
759
|
# Return complete content once (not incremental)
|
|
@@ -1257,9 +1257,9 @@ class MarkdownFlow:
|
|
|
1257
1257
|
# Step 1: If has preserved content, add inline processing instruction
|
|
1258
1258
|
if has_preserved_content:
|
|
1259
1259
|
if self._output_language:
|
|
1260
|
-
instruction = f"[INSTRUCTION: Remove
|
|
1260
|
+
instruction = f"[INSTRUCTION: Remove <原样输出> tags, translate content inside tags to {self._output_language}, keep formatting.]\n\n"
|
|
1261
1261
|
else:
|
|
1262
|
-
instruction = "[INSTRUCTION: Remove
|
|
1262
|
+
instruction = "[INSTRUCTION: Remove <原样输出> tags, keep content with all formatting and position.]\n\n"
|
|
1263
1263
|
user_content = instruction + user_content
|
|
1264
1264
|
|
|
1265
1265
|
# Step 2: If has outputLanguage, add language wrapper (outermost layer, highest priority)
|
|
@@ -81,9 +81,9 @@ def process_output_instructions(content: str) -> tuple[str, bool]:
|
|
|
81
81
|
Process output instruction markers, converting === and !=== formats to XML format.
|
|
82
82
|
|
|
83
83
|
Priority rules (to avoid conflicts):
|
|
84
|
-
1. !===content!=== →
|
|
85
|
-
2. !===\ncontent\n!=== →
|
|
86
|
-
3. ===content=== →
|
|
84
|
+
1. !===content!=== → <原样输出>content</原样输出> (single line !===, highest priority)
|
|
85
|
+
2. !===\ncontent\n!=== → <原样输出>content</原样输出> (multiline fence)
|
|
86
|
+
3. ===content=== → <原样输出>content</原样输出> (single line ===, historical compatibility)
|
|
87
87
|
|
|
88
88
|
Args:
|
|
89
89
|
content: Raw content containing output instructions
|
|
@@ -47,7 +47,7 @@ def extract_variables_from_text(text: str) -> list[str]:
|
|
|
47
47
|
|
|
48
48
|
def is_inside_preserve_tag(text: str, pos: int) -> bool:
|
|
49
49
|
"""
|
|
50
|
-
Check if the given position is inside a
|
|
50
|
+
Check if the given position is inside a <原样输出> tag.
|
|
51
51
|
|
|
52
52
|
Detection logic:
|
|
53
53
|
1. Find the most recent opening tag before pos
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
原样输出 标签过滤器
|
|
3
3
|
|
|
4
4
|
LLM 有时不遵守 system prompt 中的指令,会在输出中保留这些标签。
|
|
5
5
|
本模块提供硬过滤,确保返回给调用方的内容中不包含这些标签。
|
|
@@ -9,15 +9,15 @@ from .constants import OUTPUT_INSTRUCTION_PREFIX, OUTPUT_INSTRUCTION_SUFFIX
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
_PRESERVE_TAGS = [
|
|
12
|
-
OUTPUT_INSTRUCTION_PREFIX, #
|
|
13
|
-
OUTPUT_INSTRUCTION_SUFFIX, #
|
|
12
|
+
OUTPUT_INSTRUCTION_PREFIX, # <原样输出>
|
|
13
|
+
OUTPUT_INSTRUCTION_SUFFIX, # </原样输出>
|
|
14
14
|
]
|
|
15
15
|
|
|
16
16
|
_MAX_TAG_LEN = max(len(tag) for tag in _PRESERVE_TAGS)
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def strip_preserve_tags(content: str) -> str:
|
|
20
|
-
"""从完整文本中移除所有
|
|
20
|
+
"""从完整文本中移除所有 原样输出 标签。
|
|
21
21
|
|
|
22
22
|
用于 Complete 模式,此时拿到的是完整文本。
|
|
23
23
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown-flow
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.74
|
|
4
4
|
Summary: An agent library designed to parse and process MarkdownFlow documents
|
|
5
5
|
Project-URL: Homepage, https://github.com/ai-shifu/markdown-flow-agent-py
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/ai-shifu/markdown-flow-agent-py/issues
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|