The ai-transformer plug-in calls a large language model (LLM) to modify the header and body of a request or response in the request or response phase.
Running attributes
Plug-in execution stage: Authorization: Plug-in execution priority: 410
Configuration description
Field | Data type | Required | Default value | Description |
| bool | Yes | - | Specifies whether to enable conversion in the request phase. |
| string | Yes | - | The prompt used for conversion in the request phase. |
| string | Yes | - | Specifies whether to enable conversion in the response phase. |
| string | Yes | - | The prompt used for conversion in the response phase. |
| string | Yes | - | The service name of the Domain Name System (DNS) type. Only Qwen is supported. |
| string | Yes | - | The domain name of the LLM service. |
| string | Yes | - | The API key of the Alibaba Cloud DashScope service. |
Configuration examples
request:
enable: false
prompt: "If the request path starts with /httpbin, remove the /httpbin prefix. If the request path does not start with /httpbin, do not modify the request path."
response:
enable: true
prompt: "Modify the HTTP response based on the following requirements: 1. Change content-type to application/json. 2. Convert the body from XML to JSON. 3. Remove content-length."
provider:
serviceName: qwen
domain: dashscope.aliyuncs.com
apiKey: xxxxxxxxxxxxxAccess the /xml interface of the original HTTPBin application. Response:
<?xml version='1.0' encoding='us-ascii'?>
<!-- A SAMPLE set of slides -->
<slideshow
title="Sample Slide Show"
date="Date of publication"
author="Yours Truly"
>
<!-- TITLE SLIDE -->
<slide type="all">
<title>Wake up to WonderWidgets!</title>
</slide>
<!-- OVERVIEW -->
<slide type="all">
<title>Overview</title>
<item>Why <em>WonderWidgets</em> are great</item>
<item/>
<item>Who <em>buys</em> WonderWidgets</item>
</slide>
</slideshow>Use the preceding configuration to access the /xml interface of the HTTPBin application by using a Cloud-native API Gateway instance. The following sample code shows the response:
{
"slideshow": {
"title": "Sample Slide Show",
"date": "Date of publication",
"author": "Yours Truly",
"slides": [
{
"type": "all",
"title": "Wake up to WonderWidgets!"
},
{
"type": "all",
"title": "Overview",
"items": [
"Why <em>WonderWidgets</em> are great",
"",
"Who <em>buys</em> WonderWidgets"
]
}
]
}
}