跳到主要内容

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.
您好,{{user_name}},今天是 {{date}}。请告诉我您的问题。

高级模式(点击“SWITCH TO ADVANCED MODE”)

在高级模式下,系统会自动加载与所选知识库相关的默认模板。在此基础上进行编辑可以帮助你更好地控制生成的内容。高级模式下,系统会显示如下的内部 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.

特点

  • 配置灵活。
  • 适用于复杂或定制化的任务。

🔔提示

高级模式与普通模式切换

  • 切换到高级模式时,标准模式中的设置将被保留。
  • 在高级模式下编辑的内容,切换到普通模式时,当前编辑的内容将丢失。