@launchdarkly/server-sdk-ai 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/__tests__/LDAIClientImpl.test.ts +39 -43
- package/__tests__/LDAIConfigTrackerImpl.test.ts +39 -3
- package/dist/LDAIClientImpl.d.ts +2 -2
- package/dist/LDAIClientImpl.d.ts.map +1 -1
- package/dist/LDAIClientImpl.js +7 -4
- package/dist/LDAIClientImpl.js.map +1 -1
- package/dist/LDAIConfigTrackerImpl.d.ts +8 -2
- package/dist/LDAIConfigTrackerImpl.d.ts.map +1 -1
- package/dist/LDAIConfigTrackerImpl.js +13 -2
- package/dist/LDAIConfigTrackerImpl.js.map +1 -1
- package/dist/api/LDAIClient.d.ts +1 -9
- package/dist/api/LDAIClient.d.ts.map +1 -1
- package/dist/api/config/LDAIConfig.d.ts +18 -9
- package/dist/api/config/LDAIConfig.d.ts.map +1 -1
- package/dist/api/config/LDAIConfigTracker.d.ts +29 -2
- package/dist/api/config/LDAIConfigTracker.d.ts.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/enums/LDFeedbackKind.html +7 -6
- package/docs/functions/createBedrockTokenUsage.html +5 -4
- package/docs/functions/initAi.html +5 -4
- package/docs/index.html +6 -4
- package/docs/interfaces/LDAIClient.html +11 -35
- package/docs/interfaces/LDAIConfig.html +25 -14
- package/docs/interfaces/LDAIConfigTracker.html +35 -21
- package/docs/interfaces/LDMessage.html +7 -6
- package/docs/interfaces/LDModelConfig.html +36 -29
- package/docs/interfaces/LDProviderConfig.html +79 -0
- package/docs/interfaces/LDTokenUsage.html +8 -7
- package/docs/types/LDAIDefaults.html +5 -4
- package/package.json +1 -1
- package/src/LDAIClientImpl.ts +11 -7
- package/src/LDAIConfigTrackerImpl.ts +16 -2
- package/src/api/LDAIClient.ts +1 -10
- package/src/api/config/LDAIConfig.ts +15 -9
- package/src/api/config/LDAIConfigTracker.ts +32 -2
|
@@ -7,23 +7,24 @@ export interface LDModelConfig {
|
|
|
7
7
|
/**
|
|
8
8
|
* The ID of the model.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
name: string;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* model.
|
|
13
|
+
* Model specific parameters.
|
|
15
14
|
*/
|
|
16
|
-
|
|
15
|
+
parameters?: { [index: string]: unknown };
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* Additional user-specified parameters.
|
|
20
19
|
*/
|
|
21
|
-
|
|
20
|
+
custom?: { [index: string]: unknown };
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
+
export interface LDProviderConfig {
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* The ID of the provider.
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
name: string;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -51,7 +52,12 @@ export interface LDAIConfig {
|
|
|
51
52
|
/**
|
|
52
53
|
* Optional prompt data.
|
|
53
54
|
*/
|
|
54
|
-
|
|
55
|
+
messages?: LDMessage[];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Optional configuration for the provider.
|
|
59
|
+
*/
|
|
60
|
+
provider?: LDProviderConfig;
|
|
55
61
|
|
|
56
62
|
/**
|
|
57
63
|
* A tracker which can be used to generate analytics.
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { LDFeedbackKind, LDTokenUsage } from '../metrics';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Metrics which have been tracked.
|
|
5
|
+
*/
|
|
6
|
+
export interface LDAIMetricSummary {
|
|
7
|
+
/**
|
|
8
|
+
* The duration of generation.
|
|
9
|
+
*/
|
|
10
|
+
durationMs?: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Information about token usage.
|
|
14
|
+
*/
|
|
15
|
+
tokens?: LDTokenUsage;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Was generation successful.
|
|
19
|
+
*/
|
|
20
|
+
success?: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Any sentiment about the generation.
|
|
24
|
+
*/
|
|
25
|
+
feedback?: { kind: LDFeedbackKind };
|
|
26
|
+
}
|
|
27
|
+
|
|
3
28
|
/**
|
|
4
29
|
* The LDAIConfigTracker is used to track various details about AI operations.
|
|
5
30
|
*/
|
|
@@ -45,7 +70,7 @@ export interface LDAIConfigTracker {
|
|
|
45
70
|
* @param func Function which executes the operation.
|
|
46
71
|
* @returns The result of the operation.
|
|
47
72
|
*/
|
|
48
|
-
|
|
73
|
+
trackOpenAIMetrics<
|
|
49
74
|
TRes extends {
|
|
50
75
|
usage?: {
|
|
51
76
|
total_tokens?: number;
|
|
@@ -63,7 +88,7 @@ export interface LDAIConfigTracker {
|
|
|
63
88
|
* @param res The result of the Bedrock operation.
|
|
64
89
|
* @returns The input operation.
|
|
65
90
|
*/
|
|
66
|
-
|
|
91
|
+
trackBedrockConverseMetrics<
|
|
67
92
|
TRes extends {
|
|
68
93
|
$metadata: { httpStatusCode?: number };
|
|
69
94
|
metrics?: { latencyMs?: number };
|
|
@@ -76,4 +101,9 @@ export interface LDAIConfigTracker {
|
|
|
76
101
|
>(
|
|
77
102
|
res: TRes,
|
|
78
103
|
): TRes;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get a summary of the tracked metrics.
|
|
107
|
+
*/
|
|
108
|
+
getSummary(): LDAIMetricSummary;
|
|
79
109
|
}
|