Copilot commented on code in PR #12897: URL: https://github.com/apache/apisix/pull/12897#discussion_r2686867181
########## docs/zh/latest/plugins/ai-prompt-template.md: ########## @@ -27,27 +27,138 @@ description: 本文档包含有关 Apache APISIX ai-prompt-template 插件的信 # --> +<head> + <link rel="canonical" href="https://docs.api7.ai/hub/ai-prompt-template" /> +</head> + ## 描述 -`ai-prompt-template` 插件通过使用模板预定义请求格式,简化了对 LLM 提供商(如 OpenAI 和 Anthropic)及其模型的访问,只允许用户将自定义值传递到模板变量中。 +`ai-prompt-template` 插件简化了对 OpenAI、Anthropic 等大语言模型提供商及其模型的访问。它预先配置提示词模板,这些模板仅接受用户在指定的模板变量中输入,采用“填空”的方式。 ## 插件属性 -| **字段** | **必选项** | **类型** | **描述** | -| ------------------------------------- | ---------- | -------- | -------------------------------------------------------------------------------------------------------------------- | -| `templates` | 是 | Array | 模板对象数组 | -| `templates.name` | 是 | String | 模板的名称。 | -| `templates.template.model` | 是 | String | AI 模型的名称,例如 `gpt-4` 或 `gpt-3.5`。有关更多可用模型,请参阅您的 LLM 提供商 API 文档。 | -| `templates.template.messages.role` | 是 | String | 消息的角色(`system`、`user`、`assistant`) | -| `templates.template.messages.content` | 是 | String | 消息的内容。 | +| **字段** | **是否必填** | **类型** | **描述** | +| :--- | :--- | :--- | :--- | +| `templates` | 是 | Array | 模板对象数组。 | +| `templates.name` | 是 | String | 模板的名称。在请求路由时,请求中应包含与所配置模板相对应的模板名称。 | +| `templates.template` | 是 | Object | 模板规范。 | +| `templates.template.model` | 是 | String | AI 模型的名称,例如 `gpt-4` 或 `gpt-3.5`。更多可用模型请参阅 LLM 提供商的 API 文档。 | +| `templates.template.messages` | 是 | Array | 模板消息规范。 | +| `templates.template.messages.role` | 是 | String | 消息的角色,例如 `system`、`user` 或 `assistant`。 | +| `templates.template.messages.content` | 是 | String | 消息(提示词)的内容。 | ## 使用示例 -创建一个带有 `ai-prompt-template` 插件的路由,如下所示: +以下示例将使用 OpenAI 作为上游服务提供商。开始之前,请先创建一个 OpenAI 账户 和一个 API 密钥。你可以选择将密钥保存到环境变量中,如下所示: + +```shell +export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> # 替换为你的 API 密钥 Review Comment: The curl command example should specify the variable placeholder format more explicitly. The text instructs users to "替换为你的 API 密钥" (replace with your API key) but uses angle brackets in the command. For consistency with how environment variables are used elsewhere in the document (like `${admin_key}`), consider using a more explicit format or removing the comment since the export command already handles this. ```suggestion export OPENAI_API_KEY="your-openai-api-key" ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
