ai-prompt-decorator
Prepends or appends messages to the prompt sent to the LLM.
ai-prompt-decoratorPriority 1070What it does
ai-prompt-decorator adds fixed messages to the chat request a client sends on a route, before the request goes on. Messages under Prepend come before the client's own, those under Append after them, each with a role and a content.
The client sends only its own question, and what receives the request gets your messages with it. In the example that is the route's own backend, which echoes the system prompt back.
When to use it
- A support assistant for the orders API that must keep to orders, shipments and refunds, whatever the client asks.
- One instruction on length or tone, for example answers in at most three sentences, kept at the gateway instead of in every client.
- A request added after the client's messages, for example a short summary at the end of every answer.
- Several clients, a mobile app and a partner portal for example, that share one model and must all get the same instructions.
Not for building the whole prompt from a named template — see ai-prompt-template (Builds the prompt from a template and the request's variables), refusing prompts that carry words or patterns you name — see ai-prompt-guard (Allows or denies prompts that match configured patterns) or changing the path or headers of a request — see proxy-rewrite (Rewrites the request URI, method, host and headers before proxying).
Set it up
Put a system prompt in front of every conversation
Fill Prepend as in the JSON below.
{
"prepend": [
{
"role": "system",
"content": "You are the support assistant for the orders API. Answer only questions about orders, shipments and refunds."
}
]
}
Things to know
- Prepend — In the example a client sends only
Where is my order?, and the backend echoes the request it received with the system prompt in it,You are the support assistant for the orders API. - Prepend — A list that is there but empty satisfies the requirement and adds nothing to the prompt.
- Role — A role is
system,userorassistant, andtoolis refused when you save. - Content — A message with empty content is refused when you save.
- Request body limit — Every request through this object has its body read and decoded as JSON, whatever it is: one with no body at all, and one that is not JSON, are both refused with 400.
- AdviceKeep the instructions short, in one system message under Prepend.
Settings
The fields as the console shows them, section by section.
prependarrayRequired unless Append is setMessages put before the client's messages, each with a role and content, such as a system instruction.
prepend[].contentstringRequiredprepend[].rolestringRequiredappendarrayRequired unless Prepend is setappend[].contentstringRequiredappend[].rolestringRequiredmax_req_body_sizeintegerdefault 67108864The largest request body in bytes that is read, where a larger one is refused with 400.