Prompt
Prompt 是可重复使用的指令,可以在聊天过程中随时引用。它们作为重复性或复杂任务的上下文特别有用。
示例
以下是一些示例,可帮助您入门。
安全审查
安全最佳实践审查
@open - Review these files for the following security best practices:
- Does the architecture follow security-by-design principles?
- Are there potential security vulnerabilities in the system design?
- Is sensitive data handled appropriately throughout the lifecycle?
参考最佳实践指南
Redux 最佳实践审查
@https://redux.js.cn/style-guide/
@currentFile
Review this code for adherence to Redux best practices.
拉取常用文件用于任务
生成新的 TypeORM 实体
@src/db/dataSource.ts @src/db/entity/SampleEntity.ts
Use these files to generate a new TypeORM entity based on the following requirements:
在您的 Prompt 中包含上下文提供程序
许多上下文提供程序可以通过键入“@”后跟上下文提供程序的名称来引用。目前支持的列表是
@terminal
- 终端内容@currentFile
- 当前活动文件@open
- 所有打开的文件@os
- 操作系统信息@problems
- 语言服务器在活动文件中报告的问题@repo-map
- 仓库中的文件映射@tree
- 仓库结构的树状视图
或者您可以直接键入 URL 和文件路径
@https://github.com/continuedev/continue
- URL 内容@src/index.ts
- 文件内容 (仅限 VS Code)
所有引用都将作为上下文项附加,而不是直接内联注入。
本地 .prompt
文件
除了 Hub 上的 Prompt 块之外,您还可以在工作区顶层目录中的 .continue/prompts
文件夹中定义本地 .prompt
文件。这对于在推送至 Hub 之前快速迭代和测试 Prompt 非常有用。
快速开始
以下是设置 Prompt 文件的一个快速示例
- 在您的工作区顶层创建一个名为
.continue/prompts
的文件夹 - 向此文件夹添加一个名为
test.prompt
的文件。 - 将以下内容写入
test.prompt
并保存。
name: Current file prompt
description: A test prompt using the current file context provider
---
@currentFile
现在要使用此 Prompt,您可以打开聊天窗口,键入 /,选择该 Prompt,然后添加一些额外的文本,例如“审查代码中的任何问题”。
格式
该格式的灵感来源于 HumanLoop 的 .prompt 文件,并增加了用于引用文件、URL 和上下文提供程序的模板功能。
信息
此格式当前处于实验阶段,可能会有所更改
前导部分
“前导部分”是 ---
分隔符上方的内容,允许您指定模型参数。它使用 YAML 语法,目前支持以下参数
name
- 显示标题description
- 您将在下拉列表中看到的描述version
- 可以是“1”(用于旧版 Prompt 文件)或“2”(这是默认值,无需设置)
如果您不需要任何这些参数,可以省略前导部分,也不需要包含 ---
分隔符。