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


##########
docs/en/latest/plugins/ai-prompt-template.md:
##########
@@ -0,0 +1,102 @@
+---
+title: ai-prompt-template
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-prompt-template
+description: This document contains information about the Apache APISIX 
ai-prompt-template Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `ai-prompt-template` plugin simplifies access to AI providers and models 
by predefining the request format

Review Comment:
   ```suggestion
   The `ai-prompt-template` plugin simplifies access to LLM providers, such as 
OpenAI and Anthropic, and their models by predefining the request format
   ```



##########
docs/en/latest/plugins/ai-prompt-template.md:
##########
@@ -0,0 +1,102 @@
+---
+title: ai-prompt-template
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-prompt-template
+description: This document contains information about the Apache APISIX 
ai-prompt-template Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `ai-prompt-template` plugin simplifies access to AI providers and models 
by predefining the request format
+using a template and allowing users to pass only the values for template 
variables.
+
+## Plugin Attributes
+
+| **Field**                             | **Type** | **Description**           
                          | **Required** |
+| ------------------------------------- | -------- | 
--------------------------------------------------- | ------------ |
+| `templates`                           | Array    | An array of template 
objects                        | Yes          |
+| `templates.name`                      | String   | Name of the template.     
                          | Yes          |
+| `templates.template.model`            | String   | Model of the AI Model. 
Example: gpt-4, gpt-3.5      | Yes          |
+| `templates.template.messages.role`    | String   | Role of the message 
(`system`, `user`, `assistant`) | Yes          |
+| `templates.template.messages.content` | String   | Content of the message.   
                          | Yes          |
+
+## Example usage
+
+Create a route with the `ai-prompt-template` plugin like so:
+
+```shell
+curl "http://127.0.0.1:9180/apisix/admin/routes/1"; -X PUT \
+  -H "X-API-KEY: ${ADMIN_API_KEY}" \
+  -d '{
+    "uri": "/v1/chat/completions",
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "api.openai.com:443": 1
+      },
+      "scheme": "https",
+      "pass_host": "node"
+    },
+    "plugins": {
+      "ai-prompt-template": {
+        "templates": [
+          {
+            "name": "level of detail",
+            "template": {
+              "model": "gpt-4",
+              "messages": [
+                {
+                  "role": "user",
+                  "content": "Explain about {{ topic }} in {{ level }}."
+                }
+              ]
+            }
+          }
+        ]
+      }
+    }
+  }'
+```
+
+Now send a request:
+
+```shell
+curl http://127.0.0.1:9080/v1/chat/completions -i -XPOST  -H 'Content-Type: 
application/json' -d '{
+  "template_name": "level of detail,

Review Comment:
   ```suggestion
     "template_name": "level of detail",
   ```



##########
docs/en/latest/plugins/ai-prompt-template.md:
##########
@@ -0,0 +1,102 @@
+---
+title: ai-prompt-template
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-prompt-template
+description: This document contains information about the Apache APISIX 
ai-prompt-template Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `ai-prompt-template` plugin simplifies access to AI providers and models 
by predefining the request format
+using a template and allowing users to pass only the values for template 
variables.

Review Comment:
   ```suggestion
   using a template, which only allows users to pass customized values into 
template variables.
   ```



##########
docs/en/latest/plugins/ai-prompt-template.md:
##########
@@ -0,0 +1,102 @@
+---
+title: ai-prompt-template
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-prompt-template
+description: This document contains information about the Apache APISIX 
ai-prompt-template Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `ai-prompt-template` plugin simplifies access to AI providers and models 
by predefining the request format
+using a template and allowing users to pass only the values for template 
variables.
+
+## Plugin Attributes

Review Comment:
   Move this col to the front?
   
   <img width="953" alt="image" 
src="https://github.com/user-attachments/assets/c249ee70-12cf-4627-88f4-8c6e1ceab901";>
   



##########
docs/en/latest/plugins/ai-prompt-template.md:
##########
@@ -0,0 +1,102 @@
+---
+title: ai-prompt-template
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-prompt-template
+description: This document contains information about the Apache APISIX 
ai-prompt-template Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `ai-prompt-template` plugin simplifies access to AI providers and models 
by predefining the request format
+using a template and allowing users to pass only the values for template 
variables.
+
+## Plugin Attributes
+
+| **Field**                             | **Type** | **Description**           
                          | **Required** |
+| ------------------------------------- | -------- | 
--------------------------------------------------- | ------------ |
+| `templates`                           | Array    | An array of template 
objects                        | Yes          |
+| `templates.name`                      | String   | Name of the template.     
                          | Yes          |
+| `templates.template.model`            | String   | Model of the AI Model. 
Example: gpt-4, gpt-3.5      | Yes          |
+| `templates.template.messages.role`    | String   | Role of the message 
(`system`, `user`, `assistant`) | Yes          |
+| `templates.template.messages.content` | String   | Content of the message.   
                          | Yes          |
+
+## Example usage
+
+Create a route with the `ai-prompt-template` plugin like so:
+
+```shell
+curl "http://127.0.0.1:9180/apisix/admin/routes/1"; -X PUT \
+  -H "X-API-KEY: ${ADMIN_API_KEY}" \
+  -d '{
+    "uri": "/v1/chat/completions",
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "api.openai.com:443": 1
+      },
+      "scheme": "https",
+      "pass_host": "node"
+    },
+    "plugins": {
+      "ai-prompt-template": {
+        "templates": [
+          {
+            "name": "level of detail",
+            "template": {
+              "model": "gpt-4",

Review Comment:
   ```suggestion
                 "model": "gpt-4o",
   ```



##########
docs/en/latest/plugins/ai-prompt-template.md:
##########
@@ -0,0 +1,102 @@
+---
+title: ai-prompt-template
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-prompt-template
+description: This document contains information about the Apache APISIX 
ai-prompt-template Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `ai-prompt-template` plugin simplifies access to AI providers and models 
by predefining the request format
+using a template and allowing users to pass only the values for template 
variables.
+
+## Plugin Attributes
+
+| **Field**                             | **Type** | **Description**           
                          | **Required** |
+| ------------------------------------- | -------- | 
--------------------------------------------------- | ------------ |
+| `templates`                           | Array    | An array of template 
objects                        | Yes          |
+| `templates.name`                      | String   | Name of the template.     
                          | Yes          |
+| `templates.template.model`            | String   | Model of the AI Model. 
Example: gpt-4, gpt-3.5      | Yes          |

Review Comment:
   ```suggestion
   | `templates.template.model`            | String   | Model of the AI Model, 
for example `gpt-4o` or `gpt-3.5-turbo`. See your LLM provider API 
documentation for more model information.    | Yes          |
   ```



##########
docs/en/latest/plugins/ai-prompt-template.md:
##########
@@ -0,0 +1,102 @@
+---
+title: ai-prompt-template
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-prompt-template
+description: This document contains information about the Apache APISIX 
ai-prompt-template Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `ai-prompt-template` plugin simplifies access to AI providers and models 
by predefining the request format
+using a template and allowing users to pass only the values for template 
variables.
+
+## Plugin Attributes
+
+| **Field**                             | **Type** | **Description**           
                          | **Required** |
+| ------------------------------------- | -------- | 
--------------------------------------------------- | ------------ |
+| `templates`                           | Array    | An array of template 
objects                        | Yes          |
+| `templates.name`                      | String   | Name of the template.     
                          | Yes          |
+| `templates.template.model`            | String   | Model of the AI Model. 
Example: gpt-4, gpt-3.5      | Yes          |
+| `templates.template.messages.role`    | String   | Role of the message 
(`system`, `user`, `assistant`) | Yes          |

Review Comment:
   ```suggestion
   | `templates.template.messages.role`    | String   | Role of the message, 
such as `system`, `user`, or `assistant`. | Yes          |
   ```



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

Reply via email to