Skip to content

Commit 5fe36fb

Browse files
authored
fix: Remove underscore token usage. Improve documentation. (#667)
1 parent 3683f0a commit 5fe36fb

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

packages/sdk/server-ai/src/api/LDAIClient.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,50 @@ export interface LDAIClient {
1010
/**
1111
* Parses and interpolates a template string with the provided variables.
1212
*
13-
* @param template - The template string to be parsed and interpolated.
14-
* @param variables - An object containing the variables to be used for interpolation.
13+
* @param template The template string to be parsed and interpolated.
14+
* @param variables An object containing the variables to be used for interpolation.
1515
* @returns The interpolated string.
1616
*/
1717
interpolateTemplate(template: string, variables: Record<string, unknown>): string;
1818

1919
/**
20-
* Retrieves and processes a prompt template based on the provided key, LaunchDarkly context, and
21-
* variables.
20+
* Retrieves and processes an AI configuration based on the provided key, LaunchDarkly context,
21+
* and variables. This includes the model configuration and the processed prompts.
2222
*
23-
* @param key - A unique identifier for the prompt template. This key is used to fetch the correct
24-
* prompt from storage or configuration.
25-
* @param context - The LaunchDarkly context object that contains relevant information about the
26-
* current environment, user, or session. This context may influence how the prompt is processed
27-
* or personalized.
28-
* @param variables - A map of key-value pairs representing dynamic variables to be injected into
23+
* @param key The key of the AI configuration.
24+
* @param context The LaunchDarkly context object that contains relevant information about the
25+
* current environment, user, or session. This context may influence how the configuration is
26+
* processed or personalized.
27+
* @param variables A map of key-value pairs representing dynamic variables to be injected into
2928
* the prompt template. The keys correspond to placeholders within the template, and the values
3029
* are the corresponding replacements.
31-
* @param defaultValue - A fallback value to be used if the prompt template associated with the
32-
* key is not found or if any errors occur during processing.
30+
* @param defaultValue A fallback value containing model configuration and prompts. This will
31+
* be used if the configurationuration is not available from launchdarkly.
3332
*
34-
* @returns The processed prompt after all variables have been substituted in the stored prompt
35-
* template. If the prompt cannot be retrieved or processed, the `defaultValue` is returned.
33+
* @returns The AI configurationuration including a processed prompt after all variables have been
34+
* substituted in the stored prompt template. This will also include a `tracker` used to track
35+
* the state of the AI operation. If the configuration cannot be accessed from LaunchDarkly, then
36+
* the return value will include information from the defaultValue.
3637
*
3738
* @example
3839
* ```
3940
* const key = "welcome_prompt";
4041
* const context = {...};
4142
* const variables = {username: 'john'};
42-
* const defaultValue = {};
43+
* const defaultValue = {
44+
* enabled: false,
45+
* };
4346
*
4447
* const result = modelConfig(key, context, defaultValue, variables);
4548
* // Output:
4649
* {
47-
* modelId: "gpt-4o",
48-
* temperature: 0.2,
49-
* maxTokens: 4096,
50-
* userDefinedKey: "myValue",
50+
* enabled: true,
51+
* config: {
52+
* modelId: "gpt-4o",
53+
* temperature: 0.2,
54+
* maxTokens: 4096,
55+
* userDefinedKey: "myValue",
56+
* },
5157
* prompt: [
5258
* {
5359
* role: "system",
@@ -57,7 +63,8 @@ export interface LDAIClient {
5763
* role: "user",
5864
* content: "Explain how you're an amazing GPT."
5965
* }
60-
* ]
66+
* ],
67+
* tracker: ...
6168
* }
6269
* ```
6370
*/

packages/sdk/server-ai/src/api/metrics/UnderScoreTokenUsage.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './BedrockTokenUsage';
22
export * from './LDFeedbackKind';
33
export * from './LDTokenUsage';
4-
export * from './UnderScoreTokenUsage';

0 commit comments

Comments
 (0)