ai-prompt
The ai-prompt plug-in prepends or appends prompts to large language model (LLM) requests.
Running attributes
Plug-in execution stage: default stage. Plug-in execution priority: 450.
Configuration description
|
Field |
Data type |
Required |
Default value |
Description |
|
|
array of message object |
optional |
- |
Messages prepended to the initial input. |
|
|
array of message object |
optional |
- |
Messages appended to the initial input. |
A message object contains the following parameters.
|
Field |
Data type |
Required |
Default value |
Description |
|
|
string |
Yes |
- |
The message role, such as |
|
|
string |
Yes |
- |
The message text. |
Sample configuration:
prepend:
- role: system
content: "Answer the question in English."
append:
- role: user
content: "Each time you answer a question, try to ask a rhetorical question."
Request with the preceding configuration:
curl http://localhost/test \
-H "content-type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Who are you?"
}
]
}
Processed request after the plug-in runs:
curl http://localhost/test \
-H "content-type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
content: "Answer the question in English."
},
{
"role": "user",
"content": "Who are you?"
},
{
"role": "user",
content: "Each time you answer a question, try to ask a rhetorical question."
}
]
}
Include user geographic locations with the ai-prompt and geo-ip plug-ins
To include user geographic locations in LLM requests, enable both the geo-ip plug-in and the ai-prompt plug-in. The geo-ip plug-in must have a higher priority than the ai-prompt plug-in in the same processing stage so that it resolves the user's location from the IP address before the prompt is assembled. For example, in the default phase, the geo-ip plug-in priority is 1000 and the ai-prompt plug-in priority is 500.
Sample geo-ip plug-in configuration:
ipProtocal: "ipv4"
Sample ai-prompt plug-in configuration:
prepend:
- role: system
content: "The current geographic location of the user is: country:${geo-country}, province:${geo-province}, city:${geo-city}"
append:
- role: user
content: "Each time you answer a question, try to ask a rhetorical question."
Request with the preceding configurations:
curl http://localhost/test \
-H "content-type: application/json" \
-H "x-forwarded-for: 87.254.207.100,4.5.6.7" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "What is the weather like today?"
}
]
}'
Processed request after both plug-ins run:
curl http://localhost/test \
-H "content-type: application/json" \
-H "x-forwarded-for: 87.254.207.100,4.5.6.7" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
content: "The current geographic location of the user is: country: China, province: Beijing, city: Beijing"
},
{
"role": "user",
"content": "What is the weather like today?"
},
{
"role": "user",
content: "Each time you answer a question, try to ask a rhetorical question."
}
]
}'