Parses and interpolates a template string with the provided variables.
The template string to be parsed and interpolated.
An object containing the variables to be used for interpolation.
The interpolated string.
Retrieves and processes a prompt template based on the provided key, LaunchDarkly context, and variables.
A unique identifier for the prompt template. This key is used to fetch the correct prompt from storage or configuration.
The LaunchDarkly context object that contains relevant information about the current environment, user, or session. This context may influence how the prompt is processed or personalized.
A fallback value to be used if the prompt template associated with the key is not found or if any errors occur during processing.
Optionalvariables: Record<string, unknown>A map of key-value pairs representing dynamic variables to be injected into the prompt template. The keys correspond to placeholders within the template, and the values are the corresponding replacements.
The processed prompt after all variables have been substituted in the stored prompt
template. If the prompt cannot be retrieved or processed, the defaultValue is returned.
const key = "welcome_prompt";
const context = {...};
const variables = {username: 'john'};
const defaultValue = {};
const result = modelConfig(key, context, defaultValue, variables);
// Output:
{
modelId: "gpt-4o",
temperature: 0.2,
maxTokens: 4096,
userDefinedKey: "myValue",
prompt: [
{
role: "system",
content: "You are an amazing GPT."
},
{
role: "user",
content: "Explain how you're an amazing GPT."
}
]
}
Interface for performing AI operations using LaunchDarkly.