Re: [PR] docs: improve `ai-prompt-decorator` plugin docs [apisix]

2026-04-14 Thread via GitHub


Yilialinn closed pull request #12917: docs: improve `ai-prompt-decorator` 
plugin docs
URL: https://github.com/apache/apisix/pull/12917


-- 
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]



Re: [PR] docs: improve `ai-prompt-decorator` plugin docs [apisix]

2026-04-03 Thread via GitHub


kayx23 commented on code in PR #12917:
URL: https://github.com/apache/apisix/pull/12917#discussion_r3032170738


##
docs/en/latest/plugins/ai-prompt-decorator.md:
##
@@ -27,83 +27,277 @@ description: This document contains information about the 
Apache APISIX ai-promp
 #
 -->
 
+
+  https://docs.api7.ai/hub/ai-prompt-decorator"; />
+
+
 ## Description
 
-The `ai-prompt-decorator` plugin simplifies access to LLM providers, such as 
OpenAI and Anthropic, and their models by appending or prepending prompts into 
the request.
+The `ai-prompt-decorator` Plugin simplifies access to LLM providers, such as 
OpenAI and Anthropic, and their models. It modifies user input prompts by 
prefixing and appending pre-engineered prompts to set contexts in content 
generation. This practice helps the model operate within desired guidelines 
during interactions.
 
 ## Plugin Attributes
 
 | **Field** | **Required**| **Type** | **Description** 
|
 | - | --- |  | 
--- |
-| `prepend` | Conditionally\* | Array| An array of prompt objects 
to be prepended  |
-| `prepend.role`| Yes | String   | Role of the message 
(`system`, `user`, `assistant`) |
-| `prepend.content` | Yes | String   | Content of the message. 
Minimum length: 1   |
-| `append`  | Conditionally\* | Array| An array of prompt objects 
to be appended   |
-| `append.role` | Yes | String   | Role of the message 
(`system`, `user`, `assistant`) |
-| `append.content`  | Yes | String   | Content of the message. 
Minimum length: 1   |
+| `prepend` | Conditionally\* | Array| An array of prompt objects 
to be prepended.  |
+| `prepend.role`| Yes | String   | Role of the message, such 
as `system`, `user`, or `assistant`. |
+| `prepend.content` | Yes | String   | Content of the message 
(prompt).  |
+| `append`  | Conditionally\* | Array| An array of prompt objects 
to be appended.   |
+| `append.role` | Yes | String   | Role of the message, such 
as `system`, `user`, or `assistant`. |
+| `append.content`  | Yes | String   | Content of the message 
(prompt).  |
 
 \* **Conditionally Required**: At least one of `prepend` or `append` must be 
provided.
 
-## Example usage
+## Example
 
-Create a route with the `ai-prompt-decorator` plugin like so:
+The following example will be using OpenAI as the upstream service provider. 
Before proceeding, create an [OpenAI account](https://openai.com) and an [API 
key](https://openai.com/blog/openai-api). You can optionally save the key to an 
environment variable as such:
+
+```shell
+export OPENAI_API_KEY=
+```
+
+If you are working with other LLM providers, please refer to the provider's 
documentation to obtain an API key.
+
+### Prepend and Append Messages
+
+The following example demonstrates how to configure the `ai-prompt-decorator` 
Plugin to prepend a system message and append a user message to the user input 
message.
+
+
+
+
+
+Create a Route to the chat completion endpoint with pre-configured prompt 
templates as such:
 
 ```shell
 curl "http://127.0.0.1:9180/apisix/admin/routes/1"; -X PUT \
-  -H "X-API-KEY: ${ADMIN_API_KEY}" \
+  -H "X-API-KEY: ${admin_key}" \
   -d '{
 "uri": "/v1/chat/completions",
 "plugins": {
+  "ai-proxy": {
+"provider": "openai",
+"auth": {
+  "header": {
+"Authorization": "Bearer '"$OPENAI_API_KEY"'"
+  }
+}
+  },
   "ai-prompt-decorator": {
 "prepend":[
   {
 "role": "system",
-"content": "I have exams tomorrow so explain conceptually and 
briefly"
+"content": "Answer briefly and conceptually."
   }
 ],
 "append":[
   {
-"role": "system",
-"content": "End the response with an analogy."
+"role": "user",
+"content": "End the answer with a simple analogy."
   }
 ]
   }
-},
-"upstream": {
-  "type": "roundrobin",
-  "nodes": {
-"api.openai.com:443": 1
-  },
-  "pass_host": "node",
-  "scheme": "https"
 }
   }'
 ```
 
-Now send a request:
+
+
+
+
+Create a route with the `ai-proxy` and `ai-prompt-decorator` plugins 
configured as such:
+
+```yaml title="adc.yaml"
+services:
+  - name: prompt-decorator-service
+routes:
+  - name: prompt-decorator-route
+uris:
+  - /openai-chat
+methods:
+  - POST
+plugins:
+  ai-proxy:
+provider: openai
+auth:
+  header:
+Authorization: "Bearer ${admin_key}"

Review Comment:
   It should not be `${admin_key}`. This must have been mistakenly

Re: [PR] docs: improve `ai-prompt-decorator` plugin docs [apisix]

2026-01-23 Thread via GitHub


Copilot commented on code in PR #12917:
URL: https://github.com/apache/apisix/pull/12917#discussion_r2720458570


##
docs/zh/latest/plugins/ai-prompt-decorator.md:
##
@@ -5,7 +5,7 @@ keywords:
   - API 网关
   - Plugin
   - ai-prompt-decorator
-description: 本文档包含有关 Apache APISIX ai-prompt-decorator 插件的信息。
+description: ai-prompt-decorator 插件插件通过前缀和后缀附加预先设计的提示词来装饰用户向大语言模型提交的提示,从而简化 
API 操作和内容生成流程。

Review Comment:
   The description contains a duplicate word "插件插件" (plugin plugin). The first 
occurrence should be removed.
   ```suggestion
   description: ai-prompt-decorator 插件通过前缀和后缀附加预先设计的提示词来装饰用户向大语言模型提交的提示,从而简化 
API 操作和内容生成流程。
   ```



##
docs/zh/latest/plugins/ai-prompt-decorator.md:
##
@@ -27,83 +27,109 @@ description: 本文档包含有关 Apache APISIX ai-prompt-decorator 插件的
 #
 -->
 
+
+  https://docs.api7.ai/hub/ai-prompt-decorator"; />
+
+
 ## 描述
 
-`ai-prompt-decorator` 插件通过在请求中追加或前置提示,简化了对 LLM 提供商(如 OpenAI 和 
Anthropic)及其模型的访问。
+`ai-prompt-decorator` 插件简化了对 OpenAI、Anthropic 
等大语言模型提供商及其模型的访问。它通过在前缀和后缀附加预先设计的提示词来修饰用户输入的提示,从而为内容生成设置上下文。这种做法有助于模型在交互过程中按照期望的指导原则运行。
 
 ## 插件属性
 
-| **字段**  | **必选项**  | **类型** | **描述** 
|
+| **字段**  | **是否必填**  | **类型** | **描述**
 |
 | - | --- |  | 
 |
-| `prepend` | 条件必选\*  | Array| 要前置的提示对象数组  
   |
-| `prepend.role`| 是  | String   | 
消息的角色(`system`、`user`、`assistant`) |
-| `prepend.content` | 是  | String   | 消息的内容。最小长度:1 
 |
-| `append`  | 条件必选\*  | Array| 要追加的提示对象数组  
   |
-| `append.role` | 是  | String   | 
消息的角色(`system`、`user`、`assistant`) |
-| `append.content`  | 是  | String   | 消息的内容。最小长度:1 
 |
+| `prepend` | 条件性必填\*  | Array| 需要前置添加的提示对象数组。组。   
  |

Review Comment:
   There's a typo in the Chinese text. "组。" appears to be duplicated or 
incorrectly placed at the end of the sentence. The text should read 
"需要前置添加的提示对象数组。" without the extra "组。"
   ```suggestion
   | `prepend` | 条件性必填\*  | Array| 需要前置添加的提示对象数组。   
  |
   ```



-- 
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]