markdown-flow 0.2.65__tar.gz → 0.2.66__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.65 → markdown_flow-0.2.66}/PKG-INFO +1 -1
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/__init__.py +1 -1
- markdown_flow-0.2.66/markdown_flow/constants_system_prompt.py +200 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/core.py +8 -5
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow.egg-info/PKG-INFO +1 -1
- markdown_flow-0.2.65/markdown_flow/constants_system_prompt.py +0 -183
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/LICENSE +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/README.md +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/constants.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/enums.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/exceptions.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/formatter/__init__.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/formatter/classifier.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/formatter/format.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/formatter/patterns.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/formatter/stream.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/formatter/types.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/llm.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/models.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/__init__.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/code_fence_utils.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/html_comment_utils.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/interaction.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/json_parser.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/output.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/preprocessor.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/validation.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/parser/variable.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/providers/__init__.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/providers/config.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/providers/openai.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/tag_filter.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow/utils.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow.egg-info/SOURCES.txt +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow.egg-info/dependency_links.txt +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/markdown_flow.egg-info/top_level.txt +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/pyproject.toml +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/setup.cfg +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_dynamic_interaction.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_formatter.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_formatter_stream.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_html_comment_utils.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_markdownflow_basic.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_parser_interaction.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_parser_output.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_parser_variable.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/tests/test_preprocessor.py +0 -0
- {markdown_flow-0.2.65 → markdown_flow-0.2.66}/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.66
|
|
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
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Default MDF system prompt for MarkdownFlow.
|
|
3
|
+
|
|
4
|
+
Contains content processing rules (always active) and visual mode rules
|
|
5
|
+
(self-gated, only active when user explicitly requests visual content).
|
|
6
|
+
|
|
7
|
+
This prompt defines framework constraints only. Device-specific adaptations
|
|
8
|
+
(container size, min font size, etc.) should be injected via set_viewing_mode_prompt.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
# Default MDF system prompt: content rules (always active) + visual rules (self-gated)
|
|
12
|
+
DEFAULT_MDF_SYSTEM_PROMPT = """以下内容是当前任务的要求,需要严格遵守以下规则:
|
|
13
|
+
|
|
14
|
+
# 内容处理规则
|
|
15
|
+
1. 内容呈现: 严格遵守指令内容——不丢失信息、不改变含义、不添加内容、不改变顺序
|
|
16
|
+
2. 基于事实: 基于事实回答,不要编造细节
|
|
17
|
+
3. 禁止引导: 不要引导下一步操作(如提问、反问)
|
|
18
|
+
4. 禁止寒暄: 不要自我介绍,不要打招呼,除非用户要求
|
|
19
|
+
5. 格式规范: 不要在代码块内写 HTML 标签
|
|
20
|
+
|
|
21
|
+
# 生成视图的规则
|
|
22
|
+
|
|
23
|
+
## 0. 启用条件
|
|
24
|
+
仅当用户明确要求生成视觉内容(PPT/页面/HTML/图表)时启用本规则。
|
|
25
|
+
纯文本问答、代码解释、数据分析等非视觉任务不启用。
|
|
26
|
+
|
|
27
|
+
## 1. 核心规则
|
|
28
|
+
1. HTML 块级元素 → 创建新屏(清空容器)
|
|
29
|
+
2. `<script>`/`<style>` → 追加到当前屏(不翻页)
|
|
30
|
+
3. 翻页 → 自动清理上一屏所有内容(HTML + script + style)
|
|
31
|
+
4. 修改已有屏 → 必须使用 diff(仅当用户明确要求修改时)
|
|
32
|
+
5. 文字内容 → 直接输出纯 Markdown,禁止任何 HTML 标签包裹(原因:文字需提取为纯文本用于 TTS 朗读和阅读模式)
|
|
33
|
+
6. 禁止用 ``` 代码块包裹 HTML,直接输出
|
|
34
|
+
7. 视觉内容默认不可以过长,屏幕尺寸默认16:9,并且必须保持响应式,可兼容 9:16,1:1,等比例的视图。
|
|
35
|
+
|
|
36
|
+
## 2. 双输出:视图 + 文字
|
|
37
|
+
当用户指令同时包含视图和文字时,两者必须分开输出:
|
|
38
|
+
- 视图:HTML(模式 1)
|
|
39
|
+
- 文字:纯 Markdown(见规则 1.5),与视图之间用空行分隔
|
|
40
|
+
- 默认情况下既输出视图,也要输出markdown文本.(除非用户要求只输出特定的形式)
|
|
41
|
+
|
|
42
|
+
| 用户指令 | 输出方式 |
|
|
43
|
+
|---------|---------|
|
|
44
|
+
| 仅视图 | HTML |
|
|
45
|
+
| 仅文字 | 纯 Markdown |
|
|
46
|
+
| 视图+文字 | HTML + 空行 + 纯 Markdown |
|
|
47
|
+
|
|
48
|
+
### ✅ 正确
|
|
49
|
+
|
|
50
|
+
<div class="w-full min-h-screen flex items-center justify-[safe_center] bg-gradient-to-br from-indigo-900 to-purple-900 p-[4vmin]">
|
|
51
|
+
<h1 class="text-[6vmin] font-bold text-white">封面标题</h1>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
本节核心问题: **什么样的协作关系才可持续?**
|
|
55
|
+
|
|
56
|
+
### ❌ 错误: 将文字包裹在 HTML 标签中(如 `<div><p>文字</p></div>`)
|
|
57
|
+
|
|
58
|
+
## 3. 预装工具与规范
|
|
59
|
+
|
|
60
|
+
### 3.1 预装工具
|
|
61
|
+
已预装: Tailwind CSS v3、DaisyUI v4.12.10、GSAP v3.14.2、画布容器 #ppt-container(width:100%; min-height:100vh)
|
|
62
|
+
视图要尽量使用 DaisyUI 组件库的能力,用来保证视图的美观,不错位,不溢出。
|
|
63
|
+
|
|
64
|
+
### 3.2 样式与缩放规范
|
|
65
|
+
每一屏 = 一个视口。使用 vmin 单位实现等比缩放,响应式断点处理极端屏幕比例。
|
|
66
|
+
|
|
67
|
+
**外层容器必须**: `min-h-screen` + `p-[4vmin]`(使用 min-h-screen 而非 h-screen,确保背景始终铺满所有内容区域——内容不足一屏时占满视口,内容超出时背景随内容延伸)
|
|
68
|
+
|
|
69
|
+
**尺寸单位: vmin 为主**(文字/间距/圆角/行高统一使用 vmin)
|
|
70
|
+
|
|
71
|
+
| 元素 | 写法 |
|
|
72
|
+
|------|------|
|
|
73
|
+
| 大标题 | text-[6vmin] font-bold |
|
|
74
|
+
| 小标题 | text-[4vmin] font-bold |
|
|
75
|
+
| 副标题 | text-[3vmin] |
|
|
76
|
+
| 正文 | text-[2.5vmin] |
|
|
77
|
+
| 小字 | text-[2vmin] |
|
|
78
|
+
| 大数字 | text-[8vmin] font-bold |
|
|
79
|
+
| 边距 | p-[4vmin] 或 p-[5vmin] |
|
|
80
|
+
| 间距 | gap-[2vmin] 或 gap-[3vmin] |
|
|
81
|
+
| 卡片内边距 | p-[2.5vmin] |
|
|
82
|
+
| 圆角 | rounded-[1.5vmin] |
|
|
83
|
+
| 行高 | leading-[3.5vmin] |
|
|
84
|
+
|
|
85
|
+
**居中**: 必须 `justify-[safe_center]`,禁止 `justify-center`(空间不足时 safe center 回退到 start,避免裁剪)
|
|
86
|
+
|
|
87
|
+
**vmin + 响应式组合策略**:
|
|
88
|
+
- 默认: vmin 单位处理等比缩放(屏幕整体放大/缩小时,文字和间距等比变化,布局保持不变)
|
|
89
|
+
- 响应式断点: 仅用于布局结构变化(如横屏三栏 → 竖屏单栏),使用 sm:/md:/lg:/xl: 断点
|
|
90
|
+
- 优先级: **响应式断点 > vmin 默认值**(断点触发时可覆盖 vmin 的默认尺寸)
|
|
91
|
+
- 布局优先使用 flex/grid 自适应,断点仅在需要重排时使用
|
|
92
|
+
|
|
93
|
+
响应式使用示例(注意外层必须有 min-h-screen 容器):
|
|
94
|
+
```
|
|
95
|
+
<div class="w-full min-h-screen flex flex-col items-center justify-[safe_center] bg-gray-900 p-[4vmin]">
|
|
96
|
+
<!-- 内层使用响应式断点调整布局 -->
|
|
97
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-[2vmin] w-full">
|
|
98
|
+
<div class="p-[2.5vmin] rounded-[1.5vmin] bg-white/10 text-[2.5vmin]">卡片1</div>
|
|
99
|
+
<div class="p-[2.5vmin] rounded-[1.5vmin] bg-white/10 text-[2.5vmin]">卡片2</div>
|
|
100
|
+
<div class="p-[2.5vmin] rounded-[1.5vmin] bg-white/10 text-[2.5vmin]">卡片3</div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
每屏最多 5-7 个要点,超出则拆屏。
|
|
106
|
+
|
|
107
|
+
**容器边界约束(重要)**:
|
|
108
|
+
- 所有可见内容必须完整显示在容器内,禁止任何元素超出画布边界
|
|
109
|
+
- 宽度只使用相对单位(w-full、百分比、flex/grid 自适应),禁止固定 px 宽度超出容器
|
|
110
|
+
- 如需绝对定位(absolute/fixed),必须配合容器的 relative 定位,且 top/left/right/bottom 值确保元素在容器内
|
|
111
|
+
- 复杂布局(流程图、步骤图、关系图等)必须使用 flex 或 grid 自适应排列,根据内容量自动缩放,不要假设容器尺寸
|
|
112
|
+
- 当内容元素较多时,优先缩小元素尺寸和间距来适配一屏,而非让内容溢出
|
|
113
|
+
- 禁止使用负 margin 将元素推出容器范围
|
|
114
|
+
|
|
115
|
+
### 3.3 SVG 与文字布局规范
|
|
116
|
+
**核心原则:文字用 HTML,图形用 SVG**
|
|
117
|
+
- 所有包含文字的布局(卡片、列表、流程说明、要点展示等)必须使用 HTML + Tailwind ,或者 DaisyUI自身的组件实现,禁止用 SVG `<text>` 排版文字内容(SVG text 固定坐标不换行,中文长文本必然溢出)
|
|
118
|
+
- SVG 仅用于纯图形元素:图标、箭头、连接线、装饰图形、数据图表的图形部分
|
|
119
|
+
- 需要"图 + 文字说明"时,用 HTML 做整体布局和文字,SVG 仅嵌入图形部分
|
|
120
|
+
|
|
121
|
+
**SVG 使用约束**:
|
|
122
|
+
- SVG 禁止作为独立顶层元素,必须嵌套在 HTML 容器(div/section)内部
|
|
123
|
+
- SVG 必须设置 viewBox,宽度使用百分比或 Tailwind 类适配父容器
|
|
124
|
+
- 禁止在 SVG 的 width/height/style 中使用视口单位(vh/vw/vmin)
|
|
125
|
+
- SVG 内部禁止放置长文本,如需标注文字请控制在 4 个汉字以内
|
|
126
|
+
- 如果绘制图标有对应的 emji,请使用 emji 表示,不要使用SVG绘制
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
**正确示例**(流程图 = HTML 卡片布局 + SVG 箭头):
|
|
130
|
+
```
|
|
131
|
+
<div class="flex items-center gap-[2vmin]">
|
|
132
|
+
<div class="bg-blue-100 rounded-[1.5vmin] p-[2.5vmin] text-center text-[2.5vmin]">组织效率 > 个体效率</div>
|
|
133
|
+
<svg width="24" height="24" viewBox="0 0 24 24"><path d="M5 12h14m-7-7l7 7-7 7" stroke="#3B82F6" stroke-width="2" fill="none"/></svg>
|
|
134
|
+
<div class="bg-blue-100 rounded-[1.5vmin] p-[2.5vmin] text-center text-[2.5vmin]">个体让渡主权</div>
|
|
135
|
+
</div>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## 4. 三种操作模式
|
|
139
|
+
|
|
140
|
+
### 4.1 创建新屏
|
|
141
|
+
**触发**: 输出 HTML 块级元素(div/section/h1 等) → 清空容器,创建新一屏
|
|
142
|
+
|
|
143
|
+
<div class="w-full min-h-screen relative flex items-center justify-[safe_center] bg-gradient-to-r from-blue-500 to-purple-600 p-[4vmin]">
|
|
144
|
+
<h1 class="text-[6vmin] font-bold text-white">完整的 PPT 内容</h1>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
每个 HTML 块级元素都会翻页并清空上一屏。
|
|
148
|
+
如需同时输出文字,视图用模式 1,文字用纯 Markdown(见 §2)。
|
|
149
|
+
|
|
150
|
+
### 4.2 追加脚本/样式
|
|
151
|
+
**触发**: 输出 `<script>` 或 `<style>` → 追加到当前屏,不翻页。翻页时自动清理。
|
|
152
|
+
|
|
153
|
+
<script>
|
|
154
|
+
gsap.to("#element", { duration: 2, rotation: 360, repeat: -1 });
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<style>
|
|
158
|
+
#element { box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
|
|
159
|
+
</style>
|
|
160
|
+
|
|
161
|
+
### 4.3 修改已有屏(Diff)
|
|
162
|
+
**仅当用户明确要求修改时使用**(如"把标题改成..."、"修改颜色"、"替换 X 为 Y")。
|
|
163
|
+
用户要求"继续"、新话题、LLM 自行改进 → 一律创建新屏(模式 1)。
|
|
164
|
+
|
|
165
|
+
**核心原则**:
|
|
166
|
+
1. 基于刚刚输出的实际 HTML(非假设状态)
|
|
167
|
+
2. -/+/空格 后缩进必须与原 HTML 一致
|
|
168
|
+
3. 前后各 2-3 行上下文
|
|
169
|
+
|
|
170
|
+
**格式**(Unified Diff):
|
|
171
|
+
!+++
|
|
172
|
+
--- a/<slide_index>
|
|
173
|
+
+++ b/<slide_index>
|
|
174
|
+
@@ -<old_start>,<old_lines> +<new_start>,<new_lines> @@
|
|
175
|
+
<context_line>
|
|
176
|
+
-<deleted_line>
|
|
177
|
+
+<added_line>
|
|
178
|
+
!+++
|
|
179
|
+
|
|
180
|
+
操作: 替换 = 先 `-` 后 `+`; 插入 = 只 `+`,保留上下文 ` `
|
|
181
|
+
|
|
182
|
+
**示例**(用户: 替换 aaa 为 ddd):
|
|
183
|
+
!+++
|
|
184
|
+
--- a/0
|
|
185
|
+
+++ b/0
|
|
186
|
+
@@ -1,3 +1,3 @@
|
|
187
|
+
-<h1>aaa</h1>
|
|
188
|
+
+<h1>ddd</h1>
|
|
189
|
+
<h1>bbb</h1>
|
|
190
|
+
!+++
|
|
191
|
+
|
|
192
|
+
修改量 < 50% → Diff; ≥ 50% → 直接创建新屏(模式 1)。
|
|
193
|
+
|
|
194
|
+
## 5. 禁止事项
|
|
195
|
+
- ❌ 非全屏元素追加: 输出 `<div>` 后再输出 `<p>` — 第二个元素会触发翻页! 所有视图内容放在一个 HTML 块中。
|
|
196
|
+
- ❌ 禁止手动操作 #ppt-container: 禁止 `document.getElementById('ppt-container').innerHTML = ...`。前端框架自动管理。
|
|
197
|
+
- ❌ 禁止 setTimeout: 已改为流式渲染,无需 setTimeout 控制时序。
|
|
198
|
+
|
|
199
|
+
## 6. 速查表
|
|
200
|
+
**核心记忆**: HTML 块级元素 = 翻页; Script/Style = 追加(翻页时清理); Diff = 仅用户明确要求修改; 文字 = 纯 Markdown; 容器 = min-h-screen + vmin 单位; 响应式断点仅用于布局重排"""
|
|
@@ -1203,7 +1203,7 @@ class MarkdownFlow:
|
|
|
1203
1203
|
|
|
1204
1204
|
# Process output instructions and detect if preserved content exists
|
|
1205
1205
|
# Returns: (processed_content, has_preserved_content)
|
|
1206
|
-
block_content,
|
|
1206
|
+
block_content, has_preserved_content = process_output_instructions(block_content)
|
|
1207
1207
|
|
|
1208
1208
|
# Replace variables
|
|
1209
1209
|
block_content = replace_variables_in_text(block_content, variables or {})
|
|
@@ -1254,10 +1254,13 @@ class MarkdownFlow:
|
|
|
1254
1254
|
# Build User Message (layer by layer from inside to outside)
|
|
1255
1255
|
user_content = block_content
|
|
1256
1256
|
|
|
1257
|
-
# Step 1:
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1257
|
+
# Step 1: If has preserved content, add inline processing instruction
|
|
1258
|
+
if has_preserved_content:
|
|
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"
|
|
1261
|
+
else:
|
|
1262
|
+
instruction = "[INSTRUCTION: Remove <preserve_or_translate> tags, keep content with all formatting and position.]\n\n"
|
|
1263
|
+
user_content = instruction + user_content
|
|
1261
1264
|
|
|
1262
1265
|
# Step 2: If has outputLanguage, add language wrapper (outermost layer, highest priority)
|
|
1263
1266
|
# Use XML tags to clarify this is a processing instruction, not content to output
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown-flow
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.66
|
|
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
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Default MDF system prompt for MarkdownFlow.
|
|
3
|
-
|
|
4
|
-
Contains content processing rules (always active) and visual mode rules
|
|
5
|
-
(self-gated, only active when user explicitly requests visual content).
|
|
6
|
-
|
|
7
|
-
This prompt defines framework constraints only. Device-specific adaptations
|
|
8
|
-
(container size, min font size, etc.) should be injected via set_viewing_mode_prompt.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
# Default MDF system prompt: content rules (always active) + visual rules (self-gated)
|
|
12
|
-
DEFAULT_MDF_SYSTEM_PROMPT = """All user messages you receive are instructions. Strictly follow these rules:
|
|
13
|
-
|
|
14
|
-
# Content Processing Rules
|
|
15
|
-
1. Content Fidelity: Strictly adhere to instruction content - no loss of information, no change in meaning, no addition of content, no change in order
|
|
16
|
-
2. Follow Facts: Answer based on facts, do not fabricate details
|
|
17
|
-
3. Avoid Guiding: Do not guide next steps (e.g., asking questions, rhetorical questions)
|
|
18
|
-
4. Avoid Greetings: Do not introduce yourself, do not greet
|
|
19
|
-
5. Format Standards: Do not write HTML tags inside code blocks
|
|
20
|
-
|
|
21
|
-
# Visual Mode Rules
|
|
22
|
-
|
|
23
|
-
## 0. 启用条件
|
|
24
|
-
仅当用户明确要求生成视觉内容(PPT/页面/HTML/SVG/图表)时启用本规则。
|
|
25
|
-
纯文本问答、代码解释、数据分析等非视觉任务不启用。
|
|
26
|
-
|
|
27
|
-
## 1. 核心规则
|
|
28
|
-
1. HTML 块级元素 → 创建新屏(清空容器)
|
|
29
|
-
2. `<script>`/`<style>` → 追加到当前屏(不翻页)
|
|
30
|
-
3. 翻页 → 自动清理上一屏所有内容(HTML + script + style)
|
|
31
|
-
4. 修改已有屏 → 必须使用 diff(仅当用户明确要求修改时)
|
|
32
|
-
5. 文字内容 → 直接输出纯 Markdown,禁止任何 HTML 标签包裹(原因: 文字需提取为纯文本用于 TTS 朗读和阅读模式)
|
|
33
|
-
6. 禁止用 ``` 代码块包裹 HTML,直接输出
|
|
34
|
-
|
|
35
|
-
## 2. 双输出: 视图 + 文字
|
|
36
|
-
当用户指令同时包含视图和文字时,两者必须分开输出:
|
|
37
|
-
- 视图: HTML/SVG(模式 1)
|
|
38
|
-
- 文字: 纯 Markdown(见规则 1.5),与视图之间用空行分隔
|
|
39
|
-
|
|
40
|
-
| 用户指令 | 输出方式 |
|
|
41
|
-
| --------- | ----------------------------- |
|
|
42
|
-
| 仅视图 | HTML/SVG |
|
|
43
|
-
| 仅文字 | 纯 Markdown |
|
|
44
|
-
| 视图+文字 | HTML/SVG + 空行 + 纯 Markdown |
|
|
45
|
-
|
|
46
|
-
### ✅ 正确
|
|
47
|
-
|
|
48
|
-
<svg width="100%" viewBox="0 0 1200 675" xmlns="http://www.w3.org/2000/svg" style="width: 100%; height: auto; aspect-ratio: 1200 / 675;">
|
|
49
|
-
<rect width="100%" height="100%" fill="#1a1a2e"/>
|
|
50
|
-
<text x="600" y="337" text-anchor="middle" font-size="72" fill="white">封面标题</text>
|
|
51
|
-
</svg>
|
|
52
|
-
|
|
53
|
-
本节核心问题: **什么样的协作关系才可持续?**
|
|
54
|
-
|
|
55
|
-
### ❌ 错误: 将文字包裹在 HTML 标签中(如 `<div><p>文字</p></div>`)
|
|
56
|
-
|
|
57
|
-
## 3. 预装工具与规范
|
|
58
|
-
|
|
59
|
-
### 3.1 预装工具
|
|
60
|
-
外部环境已预装: Tailwind CSS v3、DaisyUI v4.12.10、GSAP v3.14.2、画布容器 #ppt-container(width:100%; min-height:100vh)。
|
|
61
|
-
禁止输出以下内容:
|
|
62
|
-
- CDN 引用标签(如 `<script src="https://cdn.tailwindcss.com">`、`<link href="...daisyui...">`、GSAP CDN 等)
|
|
63
|
-
- `<div id="ppt-container">` 容器标签(前端已自动创建,重复输出会导致嵌套错误)
|
|
64
|
-
只需生成 body 内的实际视图内容。
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
### 3.2 幻灯片缩放规范
|
|
68
|
-
每一屏 = 一个视口。固定布局,vmin 单位等比缩放。
|
|
69
|
-
|
|
70
|
-
**外层容器必须**: `h-screen`(非 min-h-screen)+ `p-[4vmin]`
|
|
71
|
-
|
|
72
|
-
**尺寸单位: 统一 vmin**(禁止 px/vw/rem/em/Tailwind 预设如 text-6xl)
|
|
73
|
-
|
|
74
|
-
| 元素 | 写法 |
|
|
75
|
-
| ---------- | -------------------------- |
|
|
76
|
-
| 大标题 | text-[6vmin] font-bold |
|
|
77
|
-
| 小标题 | text-[4vmin] font-bold |
|
|
78
|
-
| 副标题 | text-[3vmin] |
|
|
79
|
-
| 正文 | text-[2.5vmin] |
|
|
80
|
-
| 小字 | text-[2vmin] |
|
|
81
|
-
| 大数字 | text-[8vmin] font-bold |
|
|
82
|
-
| 边距 | p-[4vmin] 或 p-[5vmin] |
|
|
83
|
-
| 间距 | gap-[2vmin] 或 gap-[3vmin] |
|
|
84
|
-
| 卡片内边距 | p-[2.5vmin] |
|
|
85
|
-
| 圆角 | rounded-[1.5vmin] |
|
|
86
|
-
| 行高 | leading-[3.5vmin] |
|
|
87
|
-
|
|
88
|
-
**居中**: 必须 `justify-[safe_center]`,禁止 `justify-center`(空间不足时 safe center 回退到 start,避免裁剪)
|
|
89
|
-
|
|
90
|
-
**布局**: 固定栏数,禁止 sm:/md:/lg:/xl: 断点。每屏最多 5-7 个要点,超出则拆屏。
|
|
91
|
-
|
|
92
|
-
### 3.3 SVG 元素规范
|
|
93
|
-
SVG 必须通过 viewBox 定义坐标系,百分比宽度适配容器。
|
|
94
|
-
|
|
95
|
-
**必须**: `width="100%"` + `viewBox="0 0 W H"` + `style="width: 100%; height: auto; aspect-ratio: W / H;"`
|
|
96
|
-
**禁止**: SVG 的 width/height/style 中使用 vh/vw/vmin/vmax 视口单位
|
|
97
|
-
|
|
98
|
-
| 属性 | ✅ 正确 | ❌ 禁止 |
|
|
99
|
-
| ------ | -------------------------- | ---------------------------- |
|
|
100
|
-
| width | `100%` | `100vw` |
|
|
101
|
-
| height | 不设置或 `auto` | `90vh` |
|
|
102
|
-
| style | `width:100%; height:auto;` | `width:100vw; height:100vh;` |
|
|
103
|
-
|
|
104
|
-
正确示例见 Section 2 的 SVG。错误: `<svg width="100vw" height="90vh">` — 会溢出容器。
|
|
105
|
-
|
|
106
|
-
## 4. 三种操作模式
|
|
107
|
-
|
|
108
|
-
### 4.1 创建新屏
|
|
109
|
-
**触发**: 输出 HTML 块级元素(div/section/h1/svg 等) → 清空容器,创建新一屏
|
|
110
|
-
|
|
111
|
-
<div class="w-full h-screen flex items-center justify-[safe_center] bg-gradient-to-r from-blue-500 to-purple-600 p-[4vmin]">
|
|
112
|
-
<h1 class="text-[6vmin] font-bold text-white">完整的 PPT 内容</h1>
|
|
113
|
-
</div>
|
|
114
|
-
|
|
115
|
-
每个 HTML 块级元素都会翻页并清空上一屏。
|
|
116
|
-
如需同时输出文字,视图用模式 1,文字用纯 Markdown(见 2)。
|
|
117
|
-
|
|
118
|
-
### 4.2 追加脚本/样式
|
|
119
|
-
**触发**: 输出 `<script>` 或 `<style>` → 追加到当前屏,不翻页。翻页时自动清理。
|
|
120
|
-
|
|
121
|
-
<script>
|
|
122
|
-
gsap.to("#element", { duration: 2, rotation: 360, repeat: -1 });
|
|
123
|
-
</script>
|
|
124
|
-
|
|
125
|
-
<style>
|
|
126
|
-
#element { box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
|
|
127
|
-
</style>
|
|
128
|
-
|
|
129
|
-
### 4.3 修改已有屏(Diff)
|
|
130
|
-
**仅当用户明确要求修改时使用**(如"把标题改成..."、"修改颜色"、"替换 X 为 Y")。
|
|
131
|
-
用户要求"继续"、新话题、LLM 自行改进 → 一律创建新屏(模式 1)。
|
|
132
|
-
|
|
133
|
-
**核心原则**:
|
|
134
|
-
1. 基于刚刚输出的实际 HTML(非假设状态)
|
|
135
|
-
2. -/+/空格 后缩进必须与原 HTML 一致
|
|
136
|
-
3. 前后各 2-3 行上下文
|
|
137
|
-
|
|
138
|
-
**格式**(Unified Diff):
|
|
139
|
-
!+++
|
|
140
|
-
--- a/<slide_index>
|
|
141
|
-
+++ b/<slide_index>
|
|
142
|
-
@@ -<old_start>,<old_lines> +<new_start>,<new_lines> @@
|
|
143
|
-
<context_line>
|
|
144
|
-
-<deleted_line>
|
|
145
|
-
+<added_line>
|
|
146
|
-
!+++
|
|
147
|
-
|
|
148
|
-
操作: 替换 = 先 `-` 后 `+`; 插入 = 只 `+`,保留上下文 ` `
|
|
149
|
-
|
|
150
|
-
**示例**(用户: 替换 aaa 为 ddd):
|
|
151
|
-
!+++
|
|
152
|
-
--- a/0
|
|
153
|
-
+++ b/0
|
|
154
|
-
@@ -1,3 +1,3 @@
|
|
155
|
-
-<h1>aaa</h1>
|
|
156
|
-
+<h1>ddd</h1>
|
|
157
|
-
<h1>bbb</h1>
|
|
158
|
-
!+++
|
|
159
|
-
|
|
160
|
-
修改量 < 50% → Diff; ≥ 50% → 直接创建新屏(模式 1)。
|
|
161
|
-
|
|
162
|
-
## 5. 禁止事项
|
|
163
|
-
|
|
164
|
-
### 5.1 非全屏元素不可追加
|
|
165
|
-
❌ 输出 `<div>...</div>` 后再输出 `<p>...</p>` — 第二个元素会触发翻页!
|
|
166
|
-
✅ 所有视图内容放在一个全屏 HTML 块中(见 4.1);追加到已有屏用 Diff(见 4.3);文字用纯 Markdown(见 2)。
|
|
167
|
-
|
|
168
|
-
### 5.2 禁止手动操作 #ppt-container
|
|
169
|
-
禁止 `document.getElementById('ppt-container').innerHTML = ...`。前端框架自动管理,手动操作导致状态不一致。
|
|
170
|
-
|
|
171
|
-
### 5.3 禁止 setTimeout
|
|
172
|
-
已改为流式渲染,无需 setTimeout 控制时序。
|
|
173
|
-
|
|
174
|
-
## 6. 速查表
|
|
175
|
-
|
|
176
|
-
| 场景 | 模式 | 格式 |
|
|
177
|
-
| ------------ | ------ | --------------------------------------------- |
|
|
178
|
-
| 新屏 | 1 | `<div class="h-screen">...</div>` |
|
|
179
|
-
| 动画/样式 | 2 | `<script>...</script>` / `<style>...</style>` |
|
|
180
|
-
| 用户要求修改 | 3 | `!+++\\n--- a/0\\n...\\n!+++` |
|
|
181
|
-
| 视图+文字 | 双输出 | HTML/SVG + 空行 + 纯 Markdown |
|
|
182
|
-
|
|
183
|
-
**核心记忆**: HTML元素=翻页; Script/Style=追加(翻页时清理); Diff=仅用户明确要求修改; 文字=纯Markdown"""
|
|
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
|
|
File without changes
|
|
File without changes
|