Prompt Management
Message Placeholders in Chat Prompts
6 min
message placeholders allow you to insert a list of chat messages ( \[{role " ", content " "}] ) at specific positions within a chat prompt you can define multiple placeholders in a prompt and resolve them with different values at runtime message placeholders are also supported in the abv prompt playground docid\ oh ni83irwzhpyzt9nyma and prompt experiments docid\ q l3isqw0w dt6oprd85j 1\) create prompt with placeholders via ui create a placeholder in any prompt by using the add message placeholder button select a name for the placeholder that will be used to reference it in your application with python sdk from abvdev import get client abv = get client() abv create prompt( name="movie critic chat", type="chat", prompt=\[ { "role" "system", "content" "you are an {{criticlevel}} movie critic" }, { "type" "placeholder", "name" "chat history" }, { "role" "user", "content" "what should i watch next?" }, ], labels=\["production"], # directly promote to production ) js/ts sdk import { abvclient } from "@abvdev/client"; const abv = new abvclient(); await abv prompt create({ name "movie critic chat", type "chat", prompt \[ { role "system", content "you are an {{criticlevel}} movie critic" }, { type "placeholder", name "chat history" }, { role "user", content "what should i watch next?" }, ], labels \["production"], // directly promote to production }); 2\) resolve placeholders at runtime in the sdks, use the compile(variables, placeholders) method on a chatpromptclient to set the values to be filled in for the placeholders the filled in messages should be of the chatmessage format with a role and content property, but custom formats are also accepted as compile does not validate the format of the messages python sdk from abvdev import get client abv = get client() \# use prompt with placeholders in your application prompt = abv get prompt("movie critic chat") \# compile the variable and resolve the placeholder with a list of messages compiled prompt = prompt compile(criticlevel="expert", chat history=\[ {"role" "user", "content" "i love ron fricke movies like baraka"}, {"role" "user", "content" "also, the korean movie memories of a murderer"} ]) \# > compiled prompt = \[ \# { "role" "system", "content" "you are an expert movie critic" }, \# { "role" "user", "content" "i love ron fricke movies like baraka" }, \# { "role" "user", "content" "also, the korean movie memories of a murderer" }, \# { "role" "user", "content" "what should i watch next?" }, \# ] js/ts sdk import { abvclient } from "@abvdev/client"; const abv = new abvclient(); const prompt = await abv prompt get("movie critic chat", { type "chat", }); // compile the variable and resolve the placeholder with a list of messages const compiledprompt = prompt compile( // variables { criticlevel "expert" }, // placeholders { chat history \[ { role "user", content "i love ron fricke movies like baraka" }, { role "user", content "also, the korean movie memories of a murderer", }, ], } ); // > compiledprompt = \[ // { role "system", content "you are an expert movie critic" }, // { role "user", content "i love ron fricke movies like baraka" }, // { role "user", content "also, the korean movie memories of a murderer" }, // { role "user", content "what should i watch next?" }, // ]