markdown-flow 0.2.71__tar.gz → 0.2.73__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.
Files changed (48) hide show
  1. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/PKG-INFO +1 -1
  2. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/__init__.py +1 -1
  3. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/constants.py +2 -2
  4. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/core.py +6 -6
  5. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/output.py +3 -3
  6. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/variable.py +1 -1
  7. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/system_prompt.md +11 -5
  8. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/tag_filter.py +5 -5
  9. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow.egg-info/PKG-INFO +1 -1
  10. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/LICENSE +0 -0
  11. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/README.md +0 -0
  12. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/constants_system_prompt.py +0 -0
  13. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/enums.py +0 -0
  14. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/exceptions.py +0 -0
  15. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/formatter/__init__.py +0 -0
  16. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/formatter/classifier.py +0 -0
  17. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/formatter/format.py +0 -0
  18. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/formatter/patterns.py +0 -0
  19. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/formatter/stream.py +0 -0
  20. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/formatter/types.py +0 -0
  21. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/llm.py +0 -0
  22. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/models.py +0 -0
  23. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/__init__.py +0 -0
  24. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/code_fence_utils.py +0 -0
  25. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/html_comment_utils.py +0 -0
  26. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/interaction.py +0 -0
  27. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/json_parser.py +0 -0
  28. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/preprocessor.py +0 -0
  29. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/parser/validation.py +0 -0
  30. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/providers/__init__.py +0 -0
  31. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/providers/config.py +0 -0
  32. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/providers/openai.py +0 -0
  33. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow/utils.py +0 -0
  34. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow.egg-info/SOURCES.txt +0 -0
  35. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow.egg-info/dependency_links.txt +0 -0
  36. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/markdown_flow.egg-info/top_level.txt +0 -0
  37. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/pyproject.toml +0 -0
  38. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/setup.cfg +0 -0
  39. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_dynamic_interaction.py +0 -0
  40. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_formatter.py +0 -0
  41. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_formatter_stream.py +0 -0
  42. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_html_comment_utils.py +0 -0
  43. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_markdownflow_basic.py +0 -0
  44. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_parser_interaction.py +0 -0
  45. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_parser_output.py +0 -0
  46. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_parser_variable.py +0 -0
  47. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/tests/test_preprocessor.py +0 -0
  48. {markdown_flow-0.2.71 → markdown_flow-0.2.73}/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.71
3
+ Version: 0.2.73
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
@@ -88,5 +88,5 @@ __all__ = [
88
88
  "replace_variables_in_text",
89
89
  ]
90
90
 
91
- __version__ = "0.2.71"
91
+ __version__ = "0.2.73"
92
92
  # __version__ = "0.2.45-alpha-1"
@@ -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 = "<preserve_or_translate>"
74
- OUTPUT_INSTRUCTION_SUFFIX = "</preserve_or_translate>"
73
+ OUTPUT_INSTRUCTION_PREFIX = "<mandatory_output>"
74
+ OUTPUT_INSTRUCTION_SUFFIX = "</mandatory_output>"
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 输出中可能泄露的 preserve_or_translate 标签
556
+ # 过滤 LLM 输出中可能泄露的 mandatory_output 标签
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
- # 过滤 preserve_or_translate 标签(处理跨 chunk 分割)
572
+ # 过滤 mandatory_output 标签(处理跨 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 输出中可能泄露的 preserve_or_translate 标签
714
+ # 过滤 LLM 输出中可能泄露的 mandatory_output 标签
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 输出中可能泄露的 preserve_or_translate 标签
756
+ # 过滤 LLM 输出中可能泄露的 mandatory_output 标签
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 <preserve_or_translate> tags, translate content inside tags to {self._output_language}, keep formatting.]\n\n"
1260
+ instruction = f"[INSTRUCTION: Remove <mandatory_output> tags, translate content inside tags to {self._output_language}, keep formatting.]\n\n"
1261
1261
  else:
1262
- instruction = "[INSTRUCTION: Remove <preserve_or_translate> tags, keep content with all formatting and position.]\n\n"
1262
+ instruction = "[INSTRUCTION: Remove <mandatory_output> 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!=== → <preserve_or_translate>content</preserve_or_translate> (single line !===, highest priority)
85
- 2. !===\ncontent\n!=== → <preserve_or_translate>content</preserve_or_translate> (multiline fence)
86
- 3. ===content=== → <preserve_or_translate>content</preserve_or_translate> (single line ===, historical compatibility)
84
+ 1. !===content!=== → <mandatory_output>content</mandatory_output> (single line !===, highest priority)
85
+ 2. !===\ncontent\n!=== → <mandatory_output>content</mandatory_output> (multiline fence)
86
+ 3. ===content=== → <mandatory_output>content</mandatory_output> (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 <preserve_or_translate> tag.
50
+ Check if the given position is inside a <mandatory_output> tag.
51
51
 
52
52
  Detection logic:
53
53
  1. Find the most recent opening tag before pos
@@ -1,6 +1,7 @@
1
1
  以下是你必须严格遵守的规则:
2
2
 
3
3
  # 一、内容处理规则
4
+
4
5
  1. 严格遵守指令内容——不丢失信息、不改变含义、不添加内容、不改变顺序
5
6
  2. 基于事实回答,不编造细节
6
7
  3. 不引导下一步操作(不提问、不反问)
@@ -27,11 +28,12 @@
27
28
 
28
29
  每屏 = 一个铺满视口的固定容器,不可滚动。外层容器写法:
29
30
 
30
- ```
31
+ ```html
31
32
  <div style="width:100%; height:100vh; overflow-x:hidden; overflow-y:auto; display:flex; flex-direction:column; align-items:center; justify-content:safe center; padding:3.5em; font-size:clamp(12px,calc(100vw/48),3vh)">
32
33
  <!-- 内容 -->
33
34
  </div>
34
35
  ```
36
+
35
37
  每屏 HTML 后必须紧跟:
36
38
  <style>
37
39
  *,*::before,*::after{box-sizing:border-box;overflow-wrap:break-word;word-wrap:break-word}
@@ -49,7 +51,6 @@
49
51
  | 正文 | font-size:1em |
50
52
  | 小字 | font-size:0.85em |
51
53
 
52
-
53
54
  ### 2.5 SVG 规范
54
55
 
55
56
  文字用 HTML 排版,SVG 仅用于纯图形(图标、箭头、连接线)。SVG 必须嵌套在 HTML 容器内,设置 viewBox,宽度用百分比。SVG 内文字限 4 个汉字以内。有对应 emoji 的图标用 emoji,不用 SVG 绘制。
@@ -57,19 +58,23 @@
57
58
  ### 2.6 预装工具
58
59
 
59
60
  已预装: Tailwind CSS v3、DaisyUI v4.12.10、GSAP v3.14.2、画布容器 #ppt-container
60
- ** 优先使用 DaisyUI 组件 和 Tailwind 样式 **
61
- - html页面 需要 timeline 和 steps 必须使用 DaisyUI 组件库中的组件
62
- - DaisyUI timeline 和 steps 均使用 ul 和 li 控制
61
+ **优先使用 DaisyUI 组件 和 Tailwind 样式**
62
+
63
+ - html页面 需要 timeline 和 steps 必须使用 DaisyUI 组件库中的组件
64
+ - DaisyUI 的 timeline 和 steps 均使用 ul 和 li 控制
63
65
 
64
66
  ## 3. 操作模式
65
67
 
66
68
  ### 3.1 创建新屏
69
+
67
70
  输出 HTML 块级元素 → 清空容器,创建新一屏。
68
71
 
69
72
  ### 3.2 追加脚本/样式
73
+
70
74
  输出 `<script>` 或 `<style>` → 追加到当前屏,不翻页。
71
75
 
72
76
  ### 3.3 修改已有屏(Diff)
77
+
73
78
  仅当用户明确要求修改时使用。格式:
74
79
 
75
80
  !+++
@@ -92,3 +97,4 @@
92
97
  5. 禁止 setTimeout
93
98
  6. 禁止连续输出多个块级元素(会触发多次翻页),所有内容放在一个根元素内
94
99
  7. 禁止无关联html,只输出script 和style
100
+ 8. 禁止 `<script>` / `<style>` 出现在文字后面,必须且只能出现在 `<div>` 后面,中间不可以穿插纯文字或者markdown文本
@@ -1,5 +1,5 @@
1
1
  """
2
- preserve_or_translate 标签过滤器
2
+ mandatory_output 标签过滤器
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, # <preserve_or_translate>
13
- OUTPUT_INSTRUCTION_SUFFIX, # </preserve_or_translate>
12
+ OUTPUT_INSTRUCTION_PREFIX, # <mandatory_output>
13
+ OUTPUT_INSTRUCTION_SUFFIX, # </mandatory_output>
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
- """从完整文本中移除所有 preserve_or_translate 标签。
20
+ """从完整文本中移除所有 mandatory_output 标签。
21
21
 
22
22
  用于 Complete 模式,此时拿到的是完整文本。
23
23
  """
@@ -36,7 +36,7 @@ def _is_tag_prefix(s: str) -> bool:
36
36
  class StreamTagFilter:
37
37
  """流式模式下的标签过滤器。
38
38
 
39
- 处理标签可能跨 chunk 分割的情况(如 chunk1="<preserve_or",chunk2="_translate>")。
39
+ 处理标签可能跨 chunk 分割的情况(如 chunk1="<mandatory_",chunk2="output>")。
40
40
  维护一个最多 _MAX_TAG_LEN-1 字符的缓冲区,保存可能是标签前缀的尾部内容。
41
41
  """
42
42
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-flow
3
- Version: 0.2.71
3
+ Version: 0.2.73
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