Prompt 配置教程
Prompt 是一个核心模块,允许开发者通过输入提示(Prompt)来自定义 AI 的行为。高级模式下,系统会显示内部的 Prompt 模版,用户可以编辑模版使之更灵活地配置任务。
Prompt 的功能
Prompt 提供一个输入框,您可以通过编写指令来设定 AI 的行为,例如:
- 指导模型以某种语气或格式回答问题。
- 设定特定任务,如文案生成、问题解答、代码编写等。
- 定义模型可以使用的背景知识或语言风格。
系统模板
在选择知识库时,系统会自动加载与该知识库相关的默认 prompt
模板。模板中包含一些工具变量和可编辑的自定义变量。模板中的变量格式为 {{var}}
,知识库相关的变量为 {{#context#}}
。
变量说明
- 工具变量:用户选择工具并定义了输出变量,输出变量可以在
prompt
中使用。格式为{{tool_output}}
。 - 自定义变量:用户可以定义自己的变量,格式也是
{{user_input}}
。 - 知识库变量:当选择特定的知识库时,可以使用与知识库相关的变量,格式为
{{#context#}}
。
如何编写 Prompt
基础模式
基础模式提供一个简单的输入框,用户可以直接输入命令,定义 AI 的行为。例如:
特点
- 快速配置。
- 不需要复杂的格式。
- 适用于简单任务。
示例:
使用变量:
- 工具变量:例如
{{date}}
,可以在prompt
中显示当前日期。 - 自定义变量:例如
{{user_name}}
,可以根据需要定义并使用。
您好,{{user_name}},今天是 {{date}}。请告诉我您的问题。
使用知识库:
- 假设你选择了一个名为
Product Knowledge
的知识库,系统自动加载以下模板,并把你输入的Prompt自动放到模版最后面:
Use the following context as your learned knowledge, inside <context></context> XML tags.
<context>
{{#context#}}
</context>
When answer to user:
- If you don't know, just say that you don't know.
- If you don't know when you are not sure, ask for clarification.
Avoid mentioning that you obtained the information from the context.
And answer according to the language of the user's question.