Optional
inputOptional
outputOptional
totalInitialize a new AI client. This client will be used to perform any AI operations.
+The base LaunchDarkly client.
+A new AI client.
+This is the API reference for the LaunchDarkly AI SDK for Server-Side JavaScript.
+In typical usage, you will call initAi once at startup time to obtain an instance of +LDAIClient, which provides access to all of the SDK's functionality.
+Interface for performing AI operations using LaunchDarkly.
+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 an AI configuration based on the provided key, LaunchDarkly context, +and variables. This includes the model configuration and the processed prompts.
+The key of the AI configuration.
+The LaunchDarkly context object that contains relevant information about the +current environment, user, or session. This context may influence how the configuration is +processed or personalized.
+A fallback value containing model configuration and prompts. This will +be used if the configurationuration is not available from launchdarkly.
+Optional
variables: 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 AI configurationuration including a processed prompt after all variables have been
+substituted in the stored prompt template. This will also include a tracker
used to track
+the state of the AI operation. If the configuration cannot be accessed from LaunchDarkly, then
+the return value will include information from the defaultValue.
const key = "welcome_prompt";
const context = {...};
const variables = {username: 'john'};
const defaultValue = {
enabled: false,
};
const result = modelConfig(key, context, defaultValue, variables);
// Output:
{
enabled: true,
config: {
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."
}
],
tracker: ...
}
+
+
+The LDAIConfigTracker is used to track various details about AI operations.
+Track sentiment about the generation.
+Feedback about the generation.
+Track information about token usage.
+Token usage information.
+Interface for default model configuration.
+Configuration which affects generation.
+Configuration related to the model.
+And additional model specific information.
+Information about token usage.
+
Feedback about the generated content.
+