@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.
Files changed (36) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/__tests__/LDAIClientImpl.test.ts +39 -43
  3. package/__tests__/LDAIConfigTrackerImpl.test.ts +39 -3
  4. package/dist/LDAIClientImpl.d.ts +2 -2
  5. package/dist/LDAIClientImpl.d.ts.map +1 -1
  6. package/dist/LDAIClientImpl.js +7 -4
  7. package/dist/LDAIClientImpl.js.map +1 -1
  8. package/dist/LDAIConfigTrackerImpl.d.ts +8 -2
  9. package/dist/LDAIConfigTrackerImpl.d.ts.map +1 -1
  10. package/dist/LDAIConfigTrackerImpl.js +13 -2
  11. package/dist/LDAIConfigTrackerImpl.js.map +1 -1
  12. package/dist/api/LDAIClient.d.ts +1 -9
  13. package/dist/api/LDAIClient.d.ts.map +1 -1
  14. package/dist/api/config/LDAIConfig.d.ts +18 -9
  15. package/dist/api/config/LDAIConfig.d.ts.map +1 -1
  16. package/dist/api/config/LDAIConfigTracker.d.ts +29 -2
  17. package/dist/api/config/LDAIConfigTracker.d.ts.map +1 -1
  18. package/docs/assets/search.js +1 -1
  19. package/docs/enums/LDFeedbackKind.html +7 -6
  20. package/docs/functions/createBedrockTokenUsage.html +5 -4
  21. package/docs/functions/initAi.html +5 -4
  22. package/docs/index.html +6 -4
  23. package/docs/interfaces/LDAIClient.html +11 -35
  24. package/docs/interfaces/LDAIConfig.html +25 -14
  25. package/docs/interfaces/LDAIConfigTracker.html +35 -21
  26. package/docs/interfaces/LDMessage.html +7 -6
  27. package/docs/interfaces/LDModelConfig.html +36 -29
  28. package/docs/interfaces/LDProviderConfig.html +79 -0
  29. package/docs/interfaces/LDTokenUsage.html +8 -7
  30. package/docs/types/LDAIDefaults.html +5 -4
  31. package/package.json +1 -1
  32. package/src/LDAIClientImpl.ts +11 -7
  33. package/src/LDAIConfigTrackerImpl.ts +16 -2
  34. package/src/api/LDAIClient.ts +1 -10
  35. package/src/api/config/LDAIConfig.ts +15 -9
  36. 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
- modelId: string;
10
+ name: string;
11
11
 
12
12
  /**
13
- * Tuning parameter for randomness versus determinism. Exact effect will be determined by the
14
- * model.
13
+ * Model specific parameters.
15
14
  */
16
- temperature?: number;
15
+ parameters?: { [index: string]: unknown };
17
16
 
18
17
  /**
19
- * The maximum number of tokens.
18
+ * Additional user-specified parameters.
20
19
  */
21
- maxTokens?: number;
20
+ custom?: { [index: string]: unknown };
21
+ }
22
22
 
23
+ export interface LDProviderConfig {
23
24
  /**
24
- * And additional model specific information.
25
+ * The ID of the provider.
25
26
  */
26
- [index: string]: unknown;
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
- prompt?: LDMessage[];
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
- trackOpenAI<
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
- trackBedrockConverse<
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
  }