multi-router.aidocs

Prompts

Prompt Type

Text and chat prompts: what each contains and how it joins a request.

Every prompt is either a text prompt or a chat prompt. The type decides what the prompt's content looks like and how the prompt combines with the caller's messages. A text prompt supplies the system message. A chat prompt supplies a short conversation, such as instructions followed by worked examples, that comes before the caller's messages.

Text promptChat prompt
ContentOne block of textAn array of system, user and assistant messages
Inline prompttype set to texttype set to chat
GitHub promptA .md fileA .json file
Joins the request asThe system messageMessages placed before the caller's messages
Prompt compositionAppliesNot applicable

Text prompts

A text prompt is a single block of instructions, written as plain text or Markdown, that becomes the system message of each request. Through the API its body is a JSON string; in a GitHub repository it is the full text of a .md file. When the caller also sends a system message, Prompt composition on the router decides whether the two are merged, the router's prompt replaces the caller's, or the caller's is used in place of the router's. See Prompt Binding.

prompts/support-triage.mdmarkdown
You are a support agent for {{product}}.

Classify the customer's message as billing, technical or account, then answer in {{language}}.
Keep answers under 120 words and link to the help center when an article covers the question.

Chat prompts

A chat prompt is an ordered array of messages, each with a role and content. It is used to give the model instructions together with example exchanges that show the expected answers, a technique known as few-shot prompting. Each request places the chat prompt's messages in front of the caller's messages. The caller's own system message, when it sends one, is replaced by the chat prompt.

prompts/refund-examples.jsonjson
[
  { "role": "system", "content": "Decide whether a refund request qualifies under the {{plan}} plan policy. Reply with APPROVE or DECLINE and one sentence." },
  { "role": "user", "content": "I cancelled 3 days after renewal and never used the service." },
  { "role": "assistant", "content": "APPROVE. Cancellations within 14 days of renewal with no usage qualify." },
  { "role": "user", "content": "I used the service all month and want a refund for the last week." },
  { "role": "assistant", "content": "DECLINE. Partial months of active use do not qualify." }
]

A request through a router bound to this prompt sends one new customer message:

Messages sent to the providerjson
[
  { "role": "system", "content": "Decide whether a refund request qualifies under the Business plan policy. Reply with APPROVE or DECLINE and one sentence." },
  { "role": "user", "content": "I cancelled 3 days after renewal and never used the service." },
  { "role": "assistant", "content": "APPROVE. Cancellations within 14 days of renewal with no usage qualify." },
  { "role": "user", "content": "I used the service all month and want a refund for the last week." },
  { "role": "assistant", "content": "DECLINE. Partial months of active use do not qualify." },
  { "role": "user", "content": "I was billed for a seat I removed last week." }
]

Chat rules

A chat prompt must form a valid start of a conversation, so that any caller message can follow it. The dashboard, the API and GitHub syncing all check these rules, and a prompt that breaks one is refused when it is saved or synced:

RuleDetail
RolesEach message has the role system, user or assistant, in any letter case.
System messageAt most one system message, and only as the first message.
First conversational messageThe first message after the system message has the role user.
AlternationUser and assistant messages alternate after that.
ContentEvery message has content with at least one character other than spaces.
LengthAt least 1 and at most 64 messages.
SizeAt most 128 KiB for an inline prompt, and 2 MiB for a GitHub file.

A chat prompt can consist of a single system message. Message content is either a string or an array of content parts, in the same shape as Chat Completions messages.

Choosing a type

A text prompt fits instructions that every request needs, and works with callers that send their own system message through Prompt composition. A chat prompt fits behavior that is easier to show than to describe, such as a classification format or a tone, and it sets the system message for every caller. The type of an inline prompt is fixed when it is created; to change type, create a new prompt and bind routers to it.

GitHub PromptPrompt Variables
Was this helpful?