Skip to content

Commit bf01a0d

Browse files
committed
docs(preset-system): improve formatting and clarity of variable and function usage
Break down the description of variable interpolation and function calls into multiple paragraphs for better readability. Emphasize the requirement for quoting string literals in function arguments with examples.
1 parent 335565e commit bf01a0d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/guide/preset-system/write-preset.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ format_user_prompt: "用户{user}说: {prompt}"
120120

121121
### 变量与函数
122122

123-
ChatLuna 预设系统使用花括号 `{}` 进行变量插值和函数调用。变量会在渲染时被替换为对应的值,函数使用圆括号调用,多个参数用逗号分隔。需要特别注意的是,**字符串参数必须使用单引号或双引号包裹**,例如 `{concat('Hello', name)}` 中的 `'Hello'` 是字符串字面量需要加引号,而 `name` 是变量引用不需要加引号。完整的语法规则和控制流语句(条件判断、循环等)请参见 [渲染模板](template.md) 文档。
123+
ChatLuna 预设系统使用花括号 `{}` 进行变量插值和函数调用。
124+
125+
变量会在渲染时被替换为对应的值,函数使用圆括号调用,多个参数用逗号分隔。
126+
127+
需要特别注意的是,**字符串参数必须使用单引号或双引号包裹**,例如 `{concat('Hello', name)}` 中的 `'Hello'` 是字符串字面量需要加引号,而 `name` 是变量引用不需要加引号。
128+
129+
完整的语法规则和控制流语句(条件判断、循环等)请参见 [渲染模板](template.md) 文档。
124130

125131
```yaml
126132
# 应当这样做!字符串参数需要加引号
@@ -129,7 +135,9 @@ content: "{random('优秀', '良好', '及格')}"
129135
content: "{concat('用户', name, '说:', prompt)}"
130136
```
131137

132-
以下变量和函数可在预设系统中使用。其中部分变量(如 `sender`、`prompt`)仅在 ChatLuna 主插件的特定上下文中可用,主要用于处理对话相关的信息。
138+
以下变量和函数可在预设系统中使用。
139+
140+
其中部分变量(如 `sender`、`prompt`)仅在 ChatLuna 主插件的特定上下文中可用,主要用于处理对话相关的信息。
133141

134142
而其他变量和函数(如 `date`、`random`)则在所有支持 ChatLuna 渲染模板的场景中均可使用。
135143

0 commit comments

Comments
 (0)