Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
现状分析
当前 coze-loop 已经有了基础的模板系统:
前端实现:
后端实现:
{{ variable }}
格式的模板语法功能增强方案
第一阶段:后端 Jinja2 引擎升级
1. 引入专业 Jinja2 引擎
backend/modules/prompt/domain/entity/prompt_detail.go
中新增 Jinja2 模板类型支持TemplateType
枚举,添加TemplateTypeJinja2
2. 增强模板处理能力
{% if condition %}...{% endif %}
{% for item in items %}...{% endfor %}
{{ variable|filter_name }}
{{ function_name(args) }}
3. 安全性增强
第二阶段:前端编辑器增强
1. 语法高亮升级
jinja.tsx
中添加对控制结构、过滤器、函数的高亮支持2. 智能补全功能
3. 实时预览
第三阶段:高级功能实现
1. 模板函数库
2. 模板调试工具
3. 模板复用机制
实施技术方案
后端技术栈选择:
前端技术栈增强:
API 设计:
POST /api/prompts/validate-template
POST /api/prompts/preview-template
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
zh(optional):
(Optional) Which issue(s) this PR fixes: