ADC

Prompt management

A prompt is the input provided to a Large Language Model (LLM). The prompt guides how the model must respond to user’s queries. It can include instructions, questions, context, examples, or constraints, and directly influences the quality, tone, accuracy, and safety of the model’s output. Well-structured prompts are essential for building predictable and reliable AI-powered systems. Prompts can be classified into two categories:

  • System Prompt: It defines model behavior, role, and boundaries and is used to set rules to govern the tone, expertise, formatting, and safety of the response generated by the Model. A system prompt is controlled by the application/platform, not visible to users.

  • User Prompt: It is the input from the end user and captures the intent of the user such as a question, command, or request. It varies depending on the interaction and focuses on what the user wants to do. The user prompt is interpreted by the model within the rules defined in the system prompt.

Configure a prompt template to modify the system prompt

NetScaler AI Gateway enables streamlined prompt management by defining default prompts or modification of the client prompts as they traverse the gateway. This simplifies and optimizes the user experience while ensuring enforcement of organizational governance policies.

  1. Create a policy expression and specify the prompt that must be added.

    add policy expression <Expression name> <Policy Expression>
    <!--NeedCopy-->
    

    Example:

    add policy expression AppendPromptText q{"I am trained till \"10-28-2025\""}
    <!--NeedCopy-->
    
  2. Create a rewrite action to specify where the text specified in Step-1 has to be added in the prompt sent by the client.

    add rewrite action <Action name > <Action Type ><Target Expression>
    <!--NeedCopy-->
    

    Example: To Insert After:

    add rewrite action PromptAppend insert_after "HTTP.REQ.BODY(10000).XPATH_JSON_WITH_MARKUP(xp%//messages/Val[1]/content/text()%).UNQUOTE(\'\"\')" append_prompt_text.JSON_SAFE
    <!--NeedCopy-->
    

    To Insert Before:

    add rewrite action PromptPrepend insert_before "HTTP.REQ.BODY(10000).XPATH_JSON_WITH_MARKUP(xp%//messages/Val[1]/content/text()%).UNQUOTE(\'\"\')" append_prompt_text.JSON_SAFE
    <!--NeedCopy-->
    
  3. Bind the responder policy to the load balancing virtual server.

    bind lb vserver <vserverName> -policyName <policyName> -priority <positiveInteger> -type <REQUEST|RESPONSE> NEXT
    <!--NeedCopy-->
    

    Example:

    bind lbvserver  AzureOpenAIGPT5 AppendPromptText –priority 100 –type REQUEST NEXT
    <!--NeedCopy-->
    
Prompt management