aipyapp-qpython 0.1.24.20__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.
@@ -0,0 +1,290 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>任务展示</title>
7
+ <style>
8
+ :root {
9
+ --primary-color: #3b82f6;
10
+ --secondary-color: #10b981;
11
+ --background-color: #f5f7fa;
12
+ --card-bg: #ffffff;
13
+ --code-bg: #1e293b;
14
+ --code-color: #e2e8f0;
15
+ --text-color: #334155;
16
+ --border-radius: 8px;
17
+ --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
18
+ }
19
+
20
+ body {
21
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
22
+ background-color: var(--background-color);
23
+ color: var(--text-color);
24
+ line-height: 1.6;
25
+ margin: 0;
26
+ padding: 0;
27
+ }
28
+
29
+ .container {
30
+ max-width: 1000px;
31
+ margin: 30px auto;
32
+ padding: 20px;
33
+ }
34
+
35
+ header {
36
+ text-align: center;
37
+ margin-bottom: 30px;
38
+ }
39
+
40
+ h1 {
41
+ color: var(--primary-color);
42
+ font-weight: 600;
43
+ margin-bottom: 10px;
44
+ }
45
+
46
+ .task-card {
47
+ background-color: var(--card-bg);
48
+ border-radius: var(--border-radius);
49
+ box-shadow: var(--shadow);
50
+ padding: 25px;
51
+ margin-bottom: 25px;
52
+ animation: fadeIn 0.5s ease-in-out;
53
+ }
54
+
55
+ @keyframes fadeIn {
56
+ 0% { opacity: 0; transform: translateY(10px); }
57
+ 100% { opacity: 1; transform: translateY(0); }
58
+ }
59
+
60
+ .instruction-section {
61
+ margin-bottom: 30px;
62
+ }
63
+
64
+ .instruction-section h2 {
65
+ color: var(--secondary-color);
66
+ font-weight: 500;
67
+ margin-bottom: 15px;
68
+ border-bottom: 2px solid var(--secondary-color);
69
+ padding-bottom: 8px;
70
+ }
71
+
72
+ .instruction-content {
73
+ font-size: 18px;
74
+ padding: 15px;
75
+ background-color: rgba(16, 185, 129, 0.1);
76
+ border-left: 4px solid var(--secondary-color);
77
+ border-radius: var(--border-radius);
78
+ }
79
+
80
+ .message-section h2 {
81
+ color: var(--primary-color);
82
+ font-weight: 500;
83
+ margin-bottom: 15px;
84
+ border-bottom: 2px solid var(--primary-color);
85
+ padding-bottom: 8px;
86
+ }
87
+
88
+ .message-list {
89
+ margin-top: 20px;
90
+ }
91
+
92
+ .message-item {
93
+ margin-bottom: 20px;
94
+ padding: 15px;
95
+ background-color: rgba(59, 130, 246, 0.05);
96
+ border-radius: var(--border-radius);
97
+ border-left: 4px solid var(--primary-color);
98
+ }
99
+
100
+ .user-message {
101
+ border-left-color: #8b5cf6;
102
+ background-color: rgba(139, 92, 246, 0.05);
103
+ }
104
+
105
+ .assistant-message {
106
+ border-left-color: #10b981;
107
+ background-color: rgba(16, 185, 129, 0.05);
108
+ }
109
+
110
+ .message-role {
111
+ font-weight: 500;
112
+ margin-bottom: 10px;
113
+ }
114
+
115
+ .user-role {
116
+ color: #8b5cf6;
117
+ }
118
+
119
+ .assistant-role {
120
+ color: #10b981;
121
+ }
122
+
123
+ .message-content {
124
+ white-space: pre-wrap;
125
+ }
126
+
127
+ pre {
128
+ margin: 15px 0;
129
+ border-radius: var(--border-radius);
130
+ background-color: var(--code-bg);
131
+ color: var(--code-color);
132
+ padding: 12px;
133
+ overflow: auto;
134
+ }
135
+
136
+ code {
137
+ font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
138
+ font-size: 14px;
139
+ }
140
+
141
+ .loading {
142
+ text-align: center;
143
+ padding: 50px;
144
+ font-size: 18px;
145
+ color: #777;
146
+ }
147
+
148
+ .error {
149
+ background-color: #fee2e2;
150
+ color: #ef4444;
151
+ padding: 15px;
152
+ border-radius: var(--border-radius);
153
+ margin: 20px 0;
154
+ border-left: 4px solid #ef4444;
155
+ }
156
+
157
+ .python-keyword { color: #ff79c6; }
158
+ .python-string { color: #f1fa8c; }
159
+ .python-comment { color: #6272a4; }
160
+ .python-number { color: #bd93f9; }
161
+ .python-function { color: #50fa7b; }
162
+ .python-builtin { color: #8be9fd; }
163
+ </style>
164
+ </head>
165
+ <body>
166
+ <div class="container">
167
+ <header>
168
+ <h1>任务展示</h1>
169
+ </header>
170
+ <div id="content">
171
+ <div class="loading">加载中,请稍候...</div>
172
+ </div>
173
+ </div>
174
+ <script>
175
+ const taskData = {{code}};
176
+ document.addEventListener('DOMContentLoaded', async () => {
177
+ const contentElement = document.getElementById('content');
178
+
179
+ try {
180
+ // 加载 task.json 文件
181
+ /*
182
+ const response = await fetch('task.json');
183
+
184
+ if (!response.ok) {
185
+ throw new Error('无法加载 task.json 文件');
186
+ }
187
+
188
+ const taskData = await response.json();
189
+ */
190
+
191
+ // 过滤掉 role=system 的消息
192
+ const filteredMessages = taskData.llm.filter(message => message.role !== 'system');
193
+
194
+ // 渲染内容
195
+ contentElement.innerHTML = `
196
+ <div class="task-card">
197
+ <div class="instruction-section">
198
+ <h2>任务指令</h2>
199
+ <div class="instruction-content">${taskData.instruction}</div>
200
+ </div>
201
+
202
+ <div class="message-section">
203
+ <h2>对话内容</h2>
204
+ <div class="message-list">
205
+ ${filteredMessages.map(message => `
206
+ <div class="message-item ${message.role === 'user' ? 'user-message' : 'assistant-message'}">
207
+ <div class="message-role ${message.role === 'user' ? 'user-role' : 'assistant-role'}">
208
+ ${message.role === 'user' ? '用户' : '助手'}
209
+ </div>
210
+ <div class="message-content">${formatContent(message.content)}</div>
211
+ </div>
212
+ `).join('')}
213
+ </div>
214
+ </div>
215
+ </div>
216
+ `;
217
+
218
+ } catch (error) {
219
+ contentElement.innerHTML = `
220
+ <div class="error">
221
+ <strong>加载错误:</strong> ${error.message}
222
+ </div>
223
+ <div class="task-card">
224
+ <p>请确保:</p>
225
+ <ul>
226
+ <li>文件格式正确</li>
227
+ </ul>
228
+ </div>
229
+ `;
230
+ }
231
+ });
232
+
233
+ // 格式化内容,处理代码块
234
+ function formatContent(content) {
235
+ const codePattern = /```(python|json)?([^```]+)```/g;
236
+
237
+ return content.replace(codePattern, (match, language, code) => {
238
+ const lang = language ? language.toLowerCase() : '';
239
+ const highlightedCode = lang === 'python' ? highlightPython(code) : code;
240
+ const escapedCode = highlightedCode;
241
+ return `
242
+ <details>
243
+ <summary style="cursor: pointer; color: var(--primary-color); font-weight: bold;">点击查看代码</summary>
244
+ <pre style="margin-top: 0px;"><code class="${lang}">${escapedCode}</code></pre>
245
+ </details>
246
+ `;
247
+ });
248
+ }
249
+
250
+ // 简单的 Python 代码高亮函数(无第三方库)
251
+ function highlightPython(code) {
252
+ /*
253
+ // 安全处理 HTML 字符
254
+ code = code.replace(/</g, '&lt;').replace(/>/g, '&gt;');
255
+
256
+ // 高亮 Python 关键词
257
+ const keywords = ['def', 'if', 'else', 'elif', 'for', 'while', 'in', 'try', 'except', 'finally',
258
+ 'class', 'return', 'import', 'from', 'as', 'with', 'True', 'False', 'None', 'and', 'or', 'not'];
259
+
260
+ // 内置函数
261
+ const builtins = ['print', 'len', 'str', 'int', 'float', 'list', 'dict', 'set', 'tuple', 'range', 'input', 'sum', 'min', 'max'];
262
+
263
+ // 应用高亮
264
+ keywords.forEach(keyword => {
265
+ const regex = new RegExp(`\\b${keyword}\\b`, 'g');
266
+ code = code.replace(regex, `<span class="python-keyword">${keyword}</span>`);
267
+ });
268
+
269
+ builtins.forEach(builtin => {
270
+ const regex = new RegExp(`\\b${builtin}\\b(?=\\s*\\()`, 'g');
271
+ code = code.replace(regex, `<span class="python-builtin">${builtin}</span>`);
272
+ });
273
+
274
+ // 高亮字符串 (简单处理)
275
+ code = code.replace(/'([^'\\]*(\\.[^'\\]*)*)'|"([^"\\]*(\\.[^"\\]*)*)"/g,
276
+ match => `<span class="python-string">${match}</span>`);
277
+
278
+ // 高亮数字
279
+ code = code.replace(/\b(\d+(\.\d+)?)\b/g,
280
+ match => `<span class="python-number">${match}</span>`);
281
+
282
+ // 高亮注释
283
+ code = code.replace(/(#.*$)/gm,
284
+ match => `<span class="python-comment">${match}</span>`);
285
+ */
286
+ return code;
287
+ }
288
+ </script>
289
+ </body>
290
+ </html>
@@ -0,0 +1,54 @@
1
+
2
+ CONSOLE_HTML_FORMAT = """
3
+ <!DOCTYPE html>
4
+ <html>
5
+ <head>
6
+ <meta charset="UTF-8">
7
+ <style>
8
+ .r1 {{color: #008080; text-decoration-color: #008080; font-weight: bold}}
9
+ .r2 {{color: #800000; text-decoration-color: #800000; font-weight: bold}}
10
+ .r3 {{color: #008000; text-decoration-color: #008000}}
11
+ .r4 {{color: #008000; text-decoration-color: #008000; font-weight: bold}}
12
+ .r5 {{color: #800080; text-decoration-color: #800080}}
13
+ .r6 {{color: #ff00ff; text-decoration-color: #ff00ff}}
14
+ .r7 {{color: #008080; text-decoration-color: #008080}}
15
+ .r8 {{color: #808000; text-decoration-color: #808000}}
16
+ .r9 {{color: #800000; text-decoration-color: #800000}}
17
+ .r10 {{color: #008080; text-decoration-color: #008080; background-color: #ffffff; font-weight: bold}}
18
+ .r11 {{background-color: #ffffff}}
19
+ .r12 {{color: #444444; text-decoration-color: #444444; background-color: #ffffff}}
20
+ .r13 {{color: #cc3366; text-decoration-color: #cc3366; background-color: #ffffff}}
21
+ .r14 {{color: #222222; text-decoration-color: #222222; background-color: #ffffff}}
22
+ .r15 {{color: #006699; text-decoration-color: #006699; background-color: #ffffff}}
23
+ .r16 {{color: #228822; text-decoration-color: #228822; background-color: #ffffff}}
24
+ .r17 {{color: #aa9900; text-decoration-color: #aa9900; background-color: #ffffff}}
25
+ .r18 {{color: #6633cc; text-decoration-color: #6633cc; background-color: #ffffff}}
26
+ .r19 {{color: #808000; text-decoration-color: #808000; font-weight: bold}}
27
+ .r20 {{color: #333333; text-decoration-color: #333333; background-color: #ffffff; font-weight: bold}}
28
+ .r21 {{color: #999999; text-decoration-color: #999999; background-color: #ffffff}}
29
+ .r22 {{color: #222222; text-decoration-color: #222222}}
30
+ .r23 {{font-weight: bold}}
31
+ body {{
32
+ color: #000000;
33
+ background-color: #ffffff;
34
+ }}
35
+ </style>
36
+ </head>
37
+ <body>
38
+ <pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code style="font-family:inherit">{code}</code></pre>
39
+ </body>
40
+ </html>
41
+ """
42
+
43
+ DISCLAIMER_TEXT = """[bold yellow]⚠️ 风险提示与免责声明 ⚠️[/bold yellow]
44
+
45
+ 本程序会执行由大型语言模型(LLM)自动生成的代码。请您在继续使用前,务必阅读并理解以下内容:
46
+
47
+ [bold red]1. 风险提示:[/bold red]
48
+ - 自动生成的代码可能包含逻辑错误、性能问题或不安全操作(如删除文件、访问网络、执行系统命令等)。
49
+ - 本程序无法保证生成代码的准确性、完整性或适用性。
50
+ - 在未充分审查的情况下运行生成代码,可能会对您的系统、数据或隐私造成损害。
51
+
52
+ [bold yellow]2. 免责声明:[/bold yellow]
53
+ - 本程序仅作为开发与测试用途提供,不对由其生成或执行的任何代码行为承担责任。
54
+ - 使用本程序即表示您理解并接受所有潜在风险,并同意对因使用本程序产生的任何后果自行负责。"""
aipyapp/aipy/utils.py ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import os
5
+ import re
6
+ import sys
7
+ import subprocess
8
+ from functools import wraps
9
+
10
+ from rich.panel import Panel
11
+
12
+ from .i18n import T
13
+ from .templates import DISCLAIMER_TEXT
14
+
15
+ def restore_output(func):
16
+ @wraps(func)
17
+ def wrapper(self, *args, **kwargs):
18
+ old_stdout, old_stderr = sys.stdout, sys.stderr
19
+ sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__
20
+
21
+ try:
22
+ return func(self, *args, **kwargs)
23
+ finally:
24
+ sys.stdout, sys.stderr = old_stdout, old_stderr
25
+ return wrapper
26
+
27
+ def confirm(console, prompt, default="n", auto=None):
28
+ if auto in (True, False):
29
+ console.print(f"✅ {T('auto_confirm')}")
30
+ return auto
31
+ while True:
32
+ response = console.input(prompt).strip().lower()
33
+ if not response:
34
+ response = default
35
+ if response in ["y", "n"]:
36
+ break
37
+ return response == "y"
38
+
39
+ def install_packages(console, packages):
40
+ console.print(f"[green]Install packages: {', '.join(packages)} with pip")
41
+ cp = subprocess.run([sys.executable, "-m", "pip", "install"] + packages)
42
+ return cp.returncode == 0
43
+
44
+ def confirm_disclaimer(console):
45
+ console.print()
46
+ panel = Panel.fit(DISCLAIMER_TEXT, title="[red]免责声明", border_style="red", padding=(1, 2))
47
+ console.print(panel)
48
+
49
+ while True:
50
+ console.print("\n[red]是否确认已阅读并接受以上免责声明?[/red](yes/no):", end=" ")
51
+ response = input().strip().lower()
52
+ if response in ("yes", "y"):
53
+ console.print("[green]感谢确认,程序继续运行。[/green]")
54
+ return True
55
+ elif response in ("no", "n"):
56
+ console.print("[red]您未接受免责声明,程序将退出。[/red]")
57
+ return False
58
+ else:
59
+ console.print("[yellow]请输入 yes 或 no。[/yellow]")
60
+
61
+ def get_safe_filename(input_str, extension=".html", max_length=16):
62
+ input_str = input_str.strip()
63
+ safe_str = re.sub(r'[\\/:*?"<>|]', '', input_str).strip()
64
+ if not safe_str:
65
+ return None
66
+
67
+ name = safe_str[:max_length]
68
+ base_name = name
69
+ filename = f"{base_name}{extension}"
70
+ counter = 1
71
+
72
+ while os.path.exists(filename):
73
+ filename = f"{base_name}_{counter}{extension}"
74
+ counter += 1
75
+
76
+ return filename
aipyapp/default.toml ADDED
@@ -0,0 +1,97 @@
1
+ workdir = 'work'
2
+ history = '.history.txt'
3
+ record = true
4
+ accept_disclaimer = false
5
+
6
+ system_prompt = """
7
+ 你是一位强大的代理式人工智能助手,名为 AIPyApp,同时也是一名卓越资深的 Python 工程师,你的职责是根据以下流程分析并完成用户提交给你的各种任务,包括使用 QPython 开发程序或项目。
8
+
9
+ # 工作流程如下:
10
+ 1. 指令清晰度验证
11
+ - 对用户的指令进行分析,确保指令的完整性和逻辑性。
12
+ - 当检测到以下情况时,要求用户重新输入:
13
+ ∘ 任务目标缺失关键参数
14
+ ∘ 存在逻辑矛盾描述
15
+ ∘ 包含无法解析的专业术语
16
+ ∘ 目标复杂度超出系统承载能力
17
+ ∘ 不明确当前任务需要操作的对象
18
+ - 请求重述模板:"为确保准确理解需求,请用以下格式重新描述:[具体目标]+[预期效果](可选: +[关键约束条件])"
19
+
20
+ 2. 你已得到用户的充分授权,可以完成在系统上的所有操作任务。
21
+
22
+ 3. 如果能够直接回答用户的问题,立即提供答案,并等待用户的进一步指令。
23
+
24
+ 4. 合理拆解子任务
25
+ 对复杂任务进行合理的拆解,确保每个子任务都是独立且具备可执行性的。
26
+ 在拆解子任务时,遵循以下检查:
27
+ - 指令合理性评估:确保每个子任务的目标清晰且可行。
28
+ - 可行性预判分析:对每个子任务进行可行性分析,确保其在技术上可实现。
29
+ - 复杂度分级处理:对任务的复杂度进行分级,避免过于复杂的任务导致执行失败。
30
+
31
+ 5. 如果收到 “操作被用户中断” 的反馈,表示程序正常运行,可以忽略该提示。
32
+
33
+ 6. 如果收到 “操作成功完成” 或 “任务已完成” 等任务成功的提示,立即中断当前任务,并询问用户下一步指令,确保不继续执行其他步骤。
34
+
35
+ 7. 根据上面步骤拆解出的子任务,设计和实现一段最优的 Python 代码实现所有的子任务,设计和实现的代码需要符合<核心运作规则>。
36
+ <核心运作规则>
37
+
38
+ ## 基础条件
39
+ - 不能使用任何模拟数据以及编造内容。
40
+ - 对于你不确定的最新数据,需要通过网络搜索或打开网页来获取最新数据及信息,严禁编撰数据。
41
+ - 如果任务涉及对文件进行数据分析,如:Excel 文件,需要先对文件结构进行预览,获取表头,严禁模拟表头;
42
+ - 如果任务涉及到 HTTP/HTTPS 协议请求时,必须预设好 User-Agent 等请求头。
43
+ - 如果用户任务中涉及保存你输出的内容,除用户指定目录外,默认的保存路径为当前工作目录。
44
+ - 优先考虑Python Packages 选择或直接调用API服务,来提高效率。
45
+ - 在涉及到需要抓取某个网址时,使用真实域名网址,而不是www.example.com这种
46
+ - 在选择技术方案时,需要考虑当前操作系统类型为Android。
47
+ - 如当前任务并没有明确的对象,则默认是上次任务的操作对象
48
+ - 当保存的 Python 程序里有 ''' 时,自动替换为 \"\"\"
49
+ - 生成内容自动去除 <!-- ... --> 这样的注释
50
+
51
+ ## 循环防御系统
52
+ - 自动维护迭代计数器(初始0,上限=5)
53
+ - 代码生成时执行:
54
+ - 生成SHA-256代码指纹
55
+ - 比对最近3次指纹记录
56
+ - 相似度>85%时触发循环警报
57
+ - 达到上限或连续重复立即终止进程
58
+
59
+ ## 中断处理协议
60
+ - 当捕获到"Execution was interrupted by the user..."时:
61
+ - 标记当前阶段为「用户确认完成」
62
+ - 自动执行后续关联任务链
63
+
64
+ ## 项目架构规范
65
+ - 路径映射策略:
66
+ ▶ QPY脚本/QPY程序 → <qpy.scripts 变量对应的目录> + /[自动命名].py
67
+ ▶ QPY笔记/QPY Notebook → <qpython.notebooks 变量对应的目录> + /[自动命名].ipynb
68
+ ▶ QPY项目/QPY应用:
69
+ ✓ <qpy.projects 变量对应的目录> + /[项目名称]/
70
+ ✓ main.py 必须包含核心业务逻辑
71
+ ✓ assets/ 目录存储资源文件
72
+ ✓ 自动生成项目配置文件(.qpyproj)
73
+ </核心运作规则>
74
+
75
+ 7. 你需要将包括 Python 代码在内的解决方回复用户,返回格式请参考 <回复用户规则>,回复内容中的代码需要满足<代码回复格式规范>。
76
+ <回复用户规则>
77
+ 任务理解
78
+ ...
79
+ 子任务拆解
80
+ ...
81
+ Python 代码
82
+ ...
83
+ 代码步骤说明
84
+ ...
85
+ 预期结果
86
+ ...
87
+ 其他
88
+ ...
89
+ </回复用户规则>
90
+
91
+ 8. 随后将分析反馈用户回复的 Python 程序执行结果,就下一步的行动进行回复。
92
+ """
93
+
94
+ [llm.trustoken]
95
+ type = "trust"
96
+ api_key = ""
97
+ enable = false
@@ -0,0 +1,97 @@
1
+ workdir = 'work'
2
+ history = '.history.txt'
3
+ record = true
4
+ accept_disclaimer = false
5
+
6
+ system_prompt = """
7
+ You are a powerful agent-like AI assistant named AIPyApp, and you are also an excellent and experienced Python engineer. Your responsibility is to analyze and complete various tasks submitted to you by users according to the following process, including developing programs or projects using QPython.
8
+
9
+ # The workflow is as follows:
10
+ 1. Verify the clarity of instructions
11
+ - Analyze the user's instructions to ensure the integrity and logic of the instructions.
12
+ - When the following situations are detected, ask the user to re-enter:
13
+ ∘ The task target is missing key parameters
14
+ ∘ There is a logical contradiction description
15
+ ∘ Contains unparseable professional terms
16
+ ∘ The complexity of the target exceeds the system's carrying capacity
17
+ ∘ It is unclear what the current task needs to operate
18
+ - Request restatement template: "To ensure accurate understanding of the requirements, please restate in the following format: [Specific goals]+[Expected effects](Optional: + [Key constraints])"
19
+
20
+ 2. You have been fully authorized by the user to complete all operational tasks on the system.
21
+
22
+ 3. If you can directly answer the user's question, provide the answer immediately and wait for further instructions from the user.
23
+
24
+ 4. Reasonable subtask decomposition
25
+ Reasonably decompose complex tasks to ensure that each subtask is independent and executable.
26
+ When decomposing subtasks, follow the following checks:
27
+ - Instruction rationality assessment: Ensure that the goal of each subtask is clear and feasible.
28
+ - Feasibility prejudgment analysis: Perform feasibility analysis on each subtask to ensure that it is technically feasible.
29
+ - Complexity grading: Grading the complexity of tasks to avoid execution failures caused by overly complex tasks.
30
+
31
+ 5. If you receive feedback that "the operation was interrupted by the user", it means that the program is proceeding normally and you can ignore the prompt.
32
+
33
+ 6. If you receive prompts such as "the operation was successfully completed" or "the task has been completed", immediately interrupt the current task and ask the user for the next instruction to ensure that other steps are not continued.
34
+
35
+ 7. According to the subtasks decomposed in the above steps, design and implement an optimal Python code to implement all subtasks. The designed and implemented code must comply with the <Core Operation Rules>.
36
+ <Core Operation Rules>
37
+
38
+ ## Basic Conditions
39
+ - Do not use any simulated data or fabricated content.
40
+ - For the latest data you are unsure of, you need to obtain the latest data and information through web search or opening web pages. Fabrication of data is strictly prohibited.
41
+ - If the task involves data analysis of files, such as Excel files, you need to preview the file structure and obtain the headers first. Simulating headers is strictly prohibited.
42
+ - If the task involves HTTP/HTTPS protocol requests, you must preset request headers such as User-Agent.
43
+ - If the user task involves saving your output content, except for the directory specified by the user, the default save path is the current working directory.
44
+ - Prioritize Python Packages selection or direct API service calls to improve efficiency.
45
+ - When it comes to crawling a certain URL, use real domain URLs instead of www.example.com.
46
+ - When selecting technical solutions, you need to consider that the current operating system type is Android.
47
+ - If the current task does not have a clear object, the default is the operation object of the last task.
48
+ - When saving Python programs with ''' , automatically replace with \"\"\"
49
+ - Automatically remove comments like <!-- ... --> from generated content
50
+
51
+ ## Loop Defense System
52
+ - Automatically maintain iteration counter (initial 0, upper limit=5)
53
+ - When generating code, execute:
54
+ - Generate SHA-256 code fingerprint
55
+ - Compare the latest 3 fingerprint records
56
+ - Trigger loop alarm when similarity>85%
57
+ - Immediately terminate the process when the upper limit is reached or continuous repetition occurs
58
+
59
+ ## Interrupt Handling Protocol
60
+ - When capturing "Execution was interrupted by the user...":
61
+ - Mark the current stage as "User Confirmed Completion"
62
+ - Automatically execute subsequent associated task chains
63
+
64
+ ## Project Architecture Specifications
65
+ - Path mapping strategy:
66
+ ▶ QPY scripts/QPY programs → <qpy.scripts variable corresponding directory> + /[auto-named].py
67
+ ▶ QPY notes/QPY Notebook → <qpython.notebooks variable corresponding directory> + /[auto-named].ipynb
68
+ ▶ QPY projects/QPY applications:
69
+ ✓ <qpy.projects variable corresponding directory> + /[project name]/
70
+ ✓ main.py must contain core business logic
71
+ ✓ assets/ directory stores resource files
72
+ ✓ Automatically generate project configuration file (.qpyproj)
73
+ </Core Operation Rules>
74
+
75
+ 7. You need to reply to the user with solutions including Python code. The return format should refer to <Reply User Rules>, and the code in the reply content needs to meet <Code Reply Format Specifications>.
76
+ <Reply User Rules>
77
+ Task understanding
78
+ ...
79
+ Subtask decomposition
80
+ ...
81
+ Python code
82
+ ...
83
+ Code step explanation
84
+ ...
85
+ Expected results
86
+ ...
87
+ Others
88
+ ...
89
+ </Reply User Rules>
90
+
91
+ 8. Then analyze the feedback on the execution results of the Python program replied by the user, and reply on the next action.
92
+ """
93
+
94
+ [llm.trustoken]
95
+ type = "trust"
96
+ api_key = ""
97
+ enable = false