@launchdarkly/server-sdk-ai 0.9.9 → 0.10.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 +7 -0
- package/__tests__/LDAIClientImpl.test.ts +3 -0
- package/__tests__/LDAIConfigMapper.test.ts +159 -0
- package/__tests__/LDAIConfigTrackerImpl.test.ts +445 -0
- package/__tests__/TokenUsage.test.ts +43 -2
- package/dist/LDAIClientImpl.d.ts.map +1 -1
- package/dist/LDAIClientImpl.js +3 -1
- package/dist/LDAIClientImpl.js.map +1 -1
- package/dist/LDAIConfigMapper.d.ts +10 -0
- package/dist/LDAIConfigMapper.d.ts.map +1 -0
- package/dist/LDAIConfigMapper.js +54 -0
- package/dist/LDAIConfigMapper.js.map +1 -0
- package/dist/LDAIConfigTrackerImpl.d.ts +15 -0
- package/dist/LDAIConfigTrackerImpl.d.ts.map +1 -1
- package/dist/LDAIConfigTrackerImpl.js +51 -2
- package/dist/LDAIConfigTrackerImpl.js.map +1 -1
- package/dist/api/config/LDAIConfig.d.ts +16 -3
- package/dist/api/config/LDAIConfig.d.ts.map +1 -1
- package/dist/api/config/LDAIConfigTracker.d.ts +39 -0
- package/dist/api/config/LDAIConfigTracker.d.ts.map +1 -1
- package/dist/api/config/VercelAISDK.d.ts +18 -0
- package/dist/api/config/VercelAISDK.d.ts.map +1 -0
- package/dist/api/config/VercelAISDK.js +3 -0
- package/dist/api/config/VercelAISDK.js.map +1 -0
- package/dist/api/config/index.d.ts +1 -0
- package/dist/api/config/index.d.ts.map +1 -1
- package/dist/api/config/index.js +1 -0
- package/dist/api/config/index.js.map +1 -1
- package/dist/api/metrics/VercelAISDKTokenUsage.d.ts +7 -0
- package/dist/api/metrics/VercelAISDKTokenUsage.d.ts.map +1 -0
- package/dist/api/metrics/VercelAISDKTokenUsage.js +13 -0
- package/dist/api/metrics/VercelAISDKTokenUsage.js.map +1 -0
- package/dist/api/metrics/index.d.ts +2 -0
- package/dist/api/metrics/index.d.ts.map +1 -1
- package/dist/api/metrics/index.js +2 -0
- package/dist/api/metrics/index.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/enums/LDFeedbackKind.html +11 -6
- package/docs/functions/createBedrockTokenUsage.html +9 -4
- package/docs/functions/createOpenAiUsage.html +73 -0
- package/docs/functions/createVercelAISDKTokenUsage.html +73 -0
- package/docs/functions/initAi.html +9 -4
- package/docs/index.html +14 -4
- package/docs/interfaces/LDAIClient.html +10 -5
- package/docs/interfaces/LDAIConfig.html +53 -9
- package/docs/interfaces/LDAIConfigTracker.html +92 -15
- package/docs/interfaces/LDMessage.html +11 -6
- package/docs/interfaces/LDModelConfig.html +12 -7
- package/docs/interfaces/LDProviderConfig.html +11 -6
- package/docs/interfaces/LDTokenUsage.html +12 -7
- package/docs/interfaces/VercelAISDKConfig.html +149 -0
- package/docs/interfaces/VercelAISDKMapOptions.html +81 -0
- package/docs/types/LDAIDefaults.html +11 -6
- package/docs/types/VercelAISDKProvider.html +75 -0
- package/package.json +1 -1
- package/src/LDAIClientImpl.ts +21 -3
- package/src/LDAIConfigMapper.ts +64 -0
- package/src/LDAIConfigTrackerImpl.ts +73 -2
- package/src/api/config/LDAIConfig.ts +20 -3
- package/src/api/config/LDAIConfigTracker.ts +49 -0
- package/src/api/config/VercelAISDK.ts +20 -0
- package/src/api/config/index.ts +1 -0
- package/src/api/metrics/VercelAISDKTokenUsage.ts +13 -0
- package/src/api/metrics/index.ts +2 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>VercelAISDKMapOptions | @launchdarkly/server-sdk-ai - v0.10.0</title><meta name="description" content="Documentation for @launchdarkly/server-sdk-ai"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
|
+
<div class="tsd-toolbar-contents container">
|
|
3
|
+
<div class="table-cell" id="tsd-search" data-base="..">
|
|
4
|
+
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
5
|
+
<div class="field">
|
|
6
|
+
<div id="tsd-toolbar-links"></div></div>
|
|
7
|
+
<ul class="results">
|
|
8
|
+
<li class="state loading">Preparing search index...</li>
|
|
9
|
+
<li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@launchdarkly/server-sdk-ai - v0.10.0</a></div>
|
|
10
|
+
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
11
|
+
<div class="container container-main">
|
|
12
|
+
<div class="col-content">
|
|
13
|
+
<div class="tsd-page-title">
|
|
14
|
+
<ul class="tsd-breadcrumb">
|
|
15
|
+
<li><a href="../index.html">@launchdarkly/server-sdk-ai</a></li>
|
|
16
|
+
<li><a href="VercelAISDKMapOptions.html">VercelAISDKMapOptions</a></li></ul>
|
|
17
|
+
<h1>Interface VercelAISDKMapOptions</h1></div>
|
|
18
|
+
<section class="tsd-panel tsd-hierarchy">
|
|
19
|
+
<h4>Hierarchy</h4>
|
|
20
|
+
<ul class="tsd-hierarchy">
|
|
21
|
+
<li><span class="target">VercelAISDKMapOptions</span></li></ul></section><aside class="tsd-sources">
|
|
22
|
+
<ul>
|
|
23
|
+
<li>Defined in <a href="https://github.com/launchdarkly/js-core/blob/b0ca5ee/packages/sdk/server-ai/src/api/config/VercelAISDK.ts#L5">api/config/VercelAISDK.ts:5</a></li></ul></aside>
|
|
24
|
+
<section class="tsd-panel-group tsd-index-group">
|
|
25
|
+
<section class="tsd-panel tsd-index-panel">
|
|
26
|
+
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
|
|
27
|
+
<h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex=0><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M1.5 5.50969L8 11.6609L14.5 5.50969L12.5466 3.66086L8 7.96494L3.45341 3.66086L1.5 5.50969Z" fill="var(--color-text)"></path></svg> Index</h5></summary>
|
|
28
|
+
<div class="tsd-accordion-details">
|
|
29
|
+
<section class="tsd-index-section">
|
|
30
|
+
<h3 class="tsd-index-heading">Properties</h3>
|
|
31
|
+
<div class="tsd-index-list"><a href="VercelAISDKMapOptions.html#nonInterpolatedMessages" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-1024"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g></svg><span>non<wbr/>Interpolated<wbr/>Messages?</span></a>
|
|
32
|
+
</div></section></div></details></section></section>
|
|
33
|
+
<section class="tsd-panel-group tsd-member-group">
|
|
34
|
+
<h2>Properties</h2>
|
|
35
|
+
<section class="tsd-panel tsd-member"><a id="nonInterpolatedMessages" class="tsd-anchor"></a>
|
|
36
|
+
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagOptional">Optional</code> <span>non<wbr/>Interpolated<wbr/>Messages</span><a href="#nonInterpolatedMessages" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" id="icon-anchor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></g></svg></a></h3>
|
|
37
|
+
<div class="tsd-signature"><span class="tsd-kind-property">non<wbr/>Interpolated<wbr/>Messages</span><span class="tsd-signature-symbol">?:</span> <a href="LDMessage.html" class="tsd-signature-type tsd-kind-interface">LDMessage</a><span class="tsd-signature-symbol">[]</span></div><aside class="tsd-sources">
|
|
38
|
+
<ul>
|
|
39
|
+
<li>Defined in <a href="https://github.com/launchdarkly/js-core/blob/b0ca5ee/packages/sdk/server-ai/src/api/config/VercelAISDK.ts#L6">api/config/VercelAISDK.ts:6</a></li></ul></aside></section></section></div>
|
|
40
|
+
<div class="col-sidebar">
|
|
41
|
+
<div class="page-menu">
|
|
42
|
+
<div class="tsd-navigation settings">
|
|
43
|
+
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
|
|
44
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)" id="icon-chevronDown"></path></svg>Settings</h3></summary>
|
|
45
|
+
<div class="tsd-accordion-details">
|
|
46
|
+
<div class="tsd-filter-visibility">
|
|
47
|
+
<h4 class="uppercase">Member Visibility</h4><form>
|
|
48
|
+
<ul id="tsd-filter-options">
|
|
49
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
|
|
50
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li>
|
|
51
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
|
|
52
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
|
|
53
|
+
<div class="tsd-theme-toggle">
|
|
54
|
+
<h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
|
|
55
|
+
<details open class="tsd-index-accordion tsd-page-navigation"><summary class="tsd-accordion-summary">
|
|
56
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg>On This Page</h3></summary>
|
|
57
|
+
<div class="tsd-accordion-details">
|
|
58
|
+
<ul>
|
|
59
|
+
<li><a href="#nonInterpolatedMessages" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1024"></use></svg><span>non<wbr/>Interpolated<wbr/>Messages</span></a></li></ul></div></details></div>
|
|
60
|
+
<div class="site-menu">
|
|
61
|
+
<nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>@launchdarkly/server-<wbr/>sdk-<wbr/>ai -<wbr/> v0.10.0</span></a>
|
|
62
|
+
<ul class="tsd-small-nested-navigation">
|
|
63
|
+
<li><a href="../enums/LDFeedbackKind.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-8"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)"></path></g></svg><span>LDFeedback<wbr/>Kind</span></a></li>
|
|
64
|
+
<li><a href="LDAIClient.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-256"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)"></path></g></svg><span>LDAIClient</span></a></li>
|
|
65
|
+
<li><a href="LDAIConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDAIConfig</span></a></li>
|
|
66
|
+
<li><a href="LDAIConfigTracker.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDAIConfig<wbr/>Tracker</span></a></li>
|
|
67
|
+
<li><a href="LDMessage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDMessage</span></a></li>
|
|
68
|
+
<li><a href="LDModelConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDModel<wbr/>Config</span></a></li>
|
|
69
|
+
<li><a href="LDProviderConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDProvider<wbr/>Config</span></a></li>
|
|
70
|
+
<li><a href="LDTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDToken<wbr/>Usage</span></a></li>
|
|
71
|
+
<li><a href="VercelAISDKConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>VercelAISDKConfig</span></a></li>
|
|
72
|
+
<li><a href="VercelAISDKMapOptions.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>VercelAISDKMap<wbr/>Options</span></a></li>
|
|
73
|
+
<li><a href="../types/LDAIDefaults.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-2097152"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g></svg><span>LDAIDefaults</span></a></li>
|
|
74
|
+
<li><a href="../types/VercelAISDKProvider.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>VercelAISDKProvider</span></a></li>
|
|
75
|
+
<li><a href="../functions/createBedrockTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-64"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g></svg><span>create<wbr/>Bedrock<wbr/>Token<wbr/>Usage</span></a></li>
|
|
76
|
+
<li><a href="../functions/createOpenAiUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>Open<wbr/>Ai<wbr/>Usage</span></a></li>
|
|
77
|
+
<li><a href="../functions/createVercelAISDKTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>VercelAISDKToken<wbr/>Usage</span></a></li>
|
|
78
|
+
<li><a href="../functions/initAi.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>init<wbr/>Ai</span></a></li></ul></nav></div></div></div>
|
|
79
|
+
<div class="tsd-generator">
|
|
80
|
+
<p>Generated using <a href="https://typedoc.org/" rel="noopener" target="_blank">TypeDoc</a></p></div>
|
|
81
|
+
<div class="overlay"></div></body></html>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>LDAIDefaults | @launchdarkly/server-sdk-ai - v0.
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>LDAIDefaults | @launchdarkly/server-sdk-ai - v0.10.0</title><meta name="description" content="Documentation for @launchdarkly/server-sdk-ai"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
2
|
<div class="tsd-toolbar-contents container">
|
|
3
3
|
<div class="table-cell" id="tsd-search" data-base="..">
|
|
4
4
|
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div id="tsd-toolbar-links"></div></div>
|
|
7
7
|
<ul class="results">
|
|
8
8
|
<li class="state loading">Preparing search index...</li>
|
|
9
|
-
<li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@launchdarkly/server-sdk-ai - v0.
|
|
9
|
+
<li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@launchdarkly/server-sdk-ai - v0.10.0</a></div>
|
|
10
10
|
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
11
11
|
<div class="container container-main">
|
|
12
12
|
<div class="col-content">
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
<li><a href="../index.html">@launchdarkly/server-sdk-ai</a></li>
|
|
16
16
|
<li><a href="LDAIDefaults.html">LDAIDefaults</a></li></ul>
|
|
17
17
|
<h1>Type alias LDAIDefaults</h1></div>
|
|
18
|
-
<div class="tsd-signature"><span class="tsd-kind-type-alias">LDAIDefaults</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type ">Omit</span><span class="tsd-signature-symbol"><</span><a href="../interfaces/LDAIConfig.html" class="tsd-signature-type tsd-kind-interface">LDAIConfig</a><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">"tracker"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"enabled"</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> & </span><span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">enabled</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></div>
|
|
18
|
+
<div class="tsd-signature"><span class="tsd-kind-type-alias">LDAIDefaults</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type ">Omit</span><span class="tsd-signature-symbol"><</span><a href="../interfaces/LDAIConfig.html" class="tsd-signature-type tsd-kind-interface">LDAIConfig</a><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">"tracker"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"enabled"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"toVercelAISDK"</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> & </span><span class="tsd-signature-symbol">{ </span><br/><span> </span><span class="tsd-kind-property">enabled</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></div>
|
|
19
19
|
<div class="tsd-comment tsd-typography"><p>Default value for a <code>modelConfig</code>. This is the same as the LDAIConfig, but it does not include
|
|
20
|
-
a tracker and <code>enabled</code> is optional.</p>
|
|
20
|
+
a tracker or mapper, and <code>enabled</code> is optional.</p>
|
|
21
21
|
</div>
|
|
22
22
|
<div class="tsd-type-declaration">
|
|
23
23
|
<h4>Type declaration</h4>
|
|
@@ -30,7 +30,7 @@ a tracker and <code>enabled</code> is optional.</p>
|
|
|
30
30
|
<div class="tsd-comment tsd-typography"></div></li></ul></div>
|
|
31
31
|
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
|
|
32
32
|
<ul>
|
|
33
|
-
<li>Defined in <a href="https://github.com/launchdarkly/js-core/blob/
|
|
33
|
+
<li>Defined in <a href="https://github.com/launchdarkly/js-core/blob/b0ca5ee/packages/sdk/server-ai/src/api/config/LDAIConfig.ts#L94">api/config/LDAIConfig.ts:94</a></li></ul></aside></div>
|
|
34
34
|
<div class="col-sidebar">
|
|
35
35
|
<div class="page-menu">
|
|
36
36
|
<div class="tsd-navigation settings">
|
|
@@ -47,7 +47,7 @@ a tracker and <code>enabled</code> is optional.</p>
|
|
|
47
47
|
<div class="tsd-theme-toggle">
|
|
48
48
|
<h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
|
|
49
49
|
<div class="site-menu">
|
|
50
|
-
<nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>@launchdarkly/server-<wbr/>sdk-<wbr/>ai -<wbr/> v0.
|
|
50
|
+
<nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>@launchdarkly/server-<wbr/>sdk-<wbr/>ai -<wbr/> v0.10.0</span></a>
|
|
51
51
|
<ul class="tsd-small-nested-navigation">
|
|
52
52
|
<li><a href="../enums/LDFeedbackKind.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-8"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)"></path></g></svg><span>LDFeedback<wbr/>Kind</span></a></li>
|
|
53
53
|
<li><a href="../interfaces/LDAIClient.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-256"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)"></path></g></svg><span>LDAIClient</span></a></li>
|
|
@@ -57,8 +57,13 @@ a tracker and <code>enabled</code> is optional.</p>
|
|
|
57
57
|
<li><a href="../interfaces/LDModelConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDModel<wbr/>Config</span></a></li>
|
|
58
58
|
<li><a href="../interfaces/LDProviderConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDProvider<wbr/>Config</span></a></li>
|
|
59
59
|
<li><a href="../interfaces/LDTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDToken<wbr/>Usage</span></a></li>
|
|
60
|
+
<li><a href="../interfaces/VercelAISDKConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>VercelAISDKConfig</span></a></li>
|
|
61
|
+
<li><a href="../interfaces/VercelAISDKMapOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>VercelAISDKMap<wbr/>Options</span></a></li>
|
|
60
62
|
<li><a href="LDAIDefaults.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-2097152"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g></svg><span>LDAIDefaults</span></a></li>
|
|
63
|
+
<li><a href="VercelAISDKProvider.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>VercelAISDKProvider</span></a></li>
|
|
61
64
|
<li><a href="../functions/createBedrockTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-64"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g></svg><span>create<wbr/>Bedrock<wbr/>Token<wbr/>Usage</span></a></li>
|
|
65
|
+
<li><a href="../functions/createOpenAiUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>Open<wbr/>Ai<wbr/>Usage</span></a></li>
|
|
66
|
+
<li><a href="../functions/createVercelAISDKTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>VercelAISDKToken<wbr/>Usage</span></a></li>
|
|
62
67
|
<li><a href="../functions/initAi.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>init<wbr/>Ai</span></a></li></ul></nav></div></div></div>
|
|
63
68
|
<div class="tsd-generator">
|
|
64
69
|
<p>Generated using <a href="https://typedoc.org/" rel="noopener" target="_blank">TypeDoc</a></p></div>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>VercelAISDKProvider | @launchdarkly/server-sdk-ai - v0.10.0</title><meta name="description" content="Documentation for @launchdarkly/server-sdk-ai"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
|
+
<div class="tsd-toolbar-contents container">
|
|
3
|
+
<div class="table-cell" id="tsd-search" data-base="..">
|
|
4
|
+
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
5
|
+
<div class="field">
|
|
6
|
+
<div id="tsd-toolbar-links"></div></div>
|
|
7
|
+
<ul class="results">
|
|
8
|
+
<li class="state loading">Preparing search index...</li>
|
|
9
|
+
<li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@launchdarkly/server-sdk-ai - v0.10.0</a></div>
|
|
10
|
+
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
11
|
+
<div class="container container-main">
|
|
12
|
+
<div class="col-content">
|
|
13
|
+
<div class="tsd-page-title">
|
|
14
|
+
<ul class="tsd-breadcrumb">
|
|
15
|
+
<li><a href="../index.html">@launchdarkly/server-sdk-ai</a></li>
|
|
16
|
+
<li><a href="VercelAISDKProvider.html">VercelAISDKProvider</a></li></ul>
|
|
17
|
+
<h1>Type alias VercelAISDKProvider<TMod></h1></div>
|
|
18
|
+
<div class="tsd-signature"><span class="tsd-kind-type-alias">VercelAISDKProvider</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">TMod</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">modelName</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type tsd-kind-type-parameter">TMod</span><span class="tsd-signature-symbol">)</span></div>
|
|
19
|
+
<section class="tsd-panel">
|
|
20
|
+
<h4>Type Parameters</h4>
|
|
21
|
+
<ul class="tsd-type-parameter-list">
|
|
22
|
+
<li>
|
|
23
|
+
<h4><span class="tsd-kind-type-parameter">TMod</span></h4></li></ul></section>
|
|
24
|
+
<div class="tsd-type-declaration">
|
|
25
|
+
<h4>Type declaration</h4>
|
|
26
|
+
<ul class="tsd-parameters">
|
|
27
|
+
<li class="tsd-parameter-signature">
|
|
28
|
+
<ul class="tsd-signatures">
|
|
29
|
+
<li class="tsd-signature" id="__type.__type-1"><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">modelName</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type tsd-kind-type-parameter">TMod</span></li>
|
|
30
|
+
<li class="tsd-description">
|
|
31
|
+
<div class="tsd-parameters">
|
|
32
|
+
<h4 class="tsd-parameters-title">Parameters</h4>
|
|
33
|
+
<ul class="tsd-parameter-list">
|
|
34
|
+
<li>
|
|
35
|
+
<h5><span class="tsd-kind-parameter">modelName</span>: <span class="tsd-signature-type">string</span></h5></li></ul></div>
|
|
36
|
+
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type tsd-kind-type-parameter">TMod</span></h4></li></ul></li></ul></div><aside class="tsd-sources">
|
|
37
|
+
<ul>
|
|
38
|
+
<li>Defined in <a href="https://github.com/launchdarkly/js-core/blob/b0ca5ee/packages/sdk/server-ai/src/api/config/VercelAISDK.ts#L3">api/config/VercelAISDK.ts:3</a></li></ul></aside></div>
|
|
39
|
+
<div class="col-sidebar">
|
|
40
|
+
<div class="page-menu">
|
|
41
|
+
<div class="tsd-navigation settings">
|
|
42
|
+
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
|
|
43
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)" id="icon-chevronDown"></path></svg>Settings</h3></summary>
|
|
44
|
+
<div class="tsd-accordion-details">
|
|
45
|
+
<div class="tsd-filter-visibility">
|
|
46
|
+
<h4 class="uppercase">Member Visibility</h4><form>
|
|
47
|
+
<ul id="tsd-filter-options">
|
|
48
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
|
|
49
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li>
|
|
50
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
|
|
51
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
|
|
52
|
+
<div class="tsd-theme-toggle">
|
|
53
|
+
<h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
|
|
54
|
+
<div class="site-menu">
|
|
55
|
+
<nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>@launchdarkly/server-<wbr/>sdk-<wbr/>ai -<wbr/> v0.10.0</span></a>
|
|
56
|
+
<ul class="tsd-small-nested-navigation">
|
|
57
|
+
<li><a href="../enums/LDFeedbackKind.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-8"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)"></path></g></svg><span>LDFeedback<wbr/>Kind</span></a></li>
|
|
58
|
+
<li><a href="../interfaces/LDAIClient.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-256"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)"></path></g></svg><span>LDAIClient</span></a></li>
|
|
59
|
+
<li><a href="../interfaces/LDAIConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDAIConfig</span></a></li>
|
|
60
|
+
<li><a href="../interfaces/LDAIConfigTracker.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDAIConfig<wbr/>Tracker</span></a></li>
|
|
61
|
+
<li><a href="../interfaces/LDMessage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDMessage</span></a></li>
|
|
62
|
+
<li><a href="../interfaces/LDModelConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDModel<wbr/>Config</span></a></li>
|
|
63
|
+
<li><a href="../interfaces/LDProviderConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDProvider<wbr/>Config</span></a></li>
|
|
64
|
+
<li><a href="../interfaces/LDTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>LDToken<wbr/>Usage</span></a></li>
|
|
65
|
+
<li><a href="../interfaces/VercelAISDKConfig.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>VercelAISDKConfig</span></a></li>
|
|
66
|
+
<li><a href="../interfaces/VercelAISDKMapOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>VercelAISDKMap<wbr/>Options</span></a></li>
|
|
67
|
+
<li><a href="LDAIDefaults.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-2097152"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g></svg><span>LDAIDefaults</span></a></li>
|
|
68
|
+
<li><a href="VercelAISDKProvider.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>VercelAISDKProvider</span></a></li>
|
|
69
|
+
<li><a href="../functions/createBedrockTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-64"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g></svg><span>create<wbr/>Bedrock<wbr/>Token<wbr/>Usage</span></a></li>
|
|
70
|
+
<li><a href="../functions/createOpenAiUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>Open<wbr/>Ai<wbr/>Usage</span></a></li>
|
|
71
|
+
<li><a href="../functions/createVercelAISDKTokenUsage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>VercelAISDKToken<wbr/>Usage</span></a></li>
|
|
72
|
+
<li><a href="../functions/initAi.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>init<wbr/>Ai</span></a></li></ul></nav></div></div></div>
|
|
73
|
+
<div class="tsd-generator">
|
|
74
|
+
<p>Generated using <a href="https://typedoc.org/" rel="noopener" target="_blank">TypeDoc</a></p></div>
|
|
75
|
+
<div class="overlay"></div></body></html>
|
package/package.json
CHANGED
package/src/LDAIClientImpl.ts
CHANGED
|
@@ -2,8 +2,18 @@ import * as Mustache from 'mustache';
|
|
|
2
2
|
|
|
3
3
|
import { LDContext } from '@launchdarkly/js-server-sdk-common';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
LDAIConfig,
|
|
7
|
+
LDAIDefaults,
|
|
8
|
+
LDMessage,
|
|
9
|
+
LDModelConfig,
|
|
10
|
+
LDProviderConfig,
|
|
11
|
+
VercelAISDKConfig,
|
|
12
|
+
VercelAISDKMapOptions,
|
|
13
|
+
VercelAISDKProvider,
|
|
14
|
+
} from './api/config';
|
|
6
15
|
import { LDAIClient } from './api/LDAIClient';
|
|
16
|
+
import { LDAIConfigMapper } from './LDAIConfigMapper';
|
|
7
17
|
import { LDAIConfigTrackerImpl } from './LDAIConfigTrackerImpl';
|
|
8
18
|
import { LDClientMin } from './LDClientMin';
|
|
9
19
|
|
|
@@ -52,7 +62,7 @@ export class LDAIClientImpl implements LDAIClient {
|
|
|
52
62
|
);
|
|
53
63
|
// eslint-disable-next-line no-underscore-dangle
|
|
54
64
|
const enabled = !!value._ldMeta?.enabled;
|
|
55
|
-
const config: LDAIConfig = {
|
|
65
|
+
const config: Omit<LDAIConfig, 'toVercelAISDK'> = {
|
|
56
66
|
tracker,
|
|
57
67
|
enabled,
|
|
58
68
|
};
|
|
@@ -73,6 +83,14 @@ export class LDAIClientImpl implements LDAIClient {
|
|
|
73
83
|
}));
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
|
|
86
|
+
const mapper = new LDAIConfigMapper(config.model, config.provider, config.messages);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
...config,
|
|
90
|
+
toVercelAISDK: <TMod>(
|
|
91
|
+
provider: VercelAISDKProvider<TMod> | Record<string, VercelAISDKProvider<TMod>>,
|
|
92
|
+
options?: VercelAISDKMapOptions | undefined,
|
|
93
|
+
): VercelAISDKConfig<TMod> => mapper.toVercelAISDK(provider, options),
|
|
94
|
+
};
|
|
77
95
|
}
|
|
78
96
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LDMessage,
|
|
3
|
+
LDModelConfig,
|
|
4
|
+
LDProviderConfig,
|
|
5
|
+
VercelAISDKConfig,
|
|
6
|
+
VercelAISDKMapOptions,
|
|
7
|
+
VercelAISDKProvider,
|
|
8
|
+
} from './api/config';
|
|
9
|
+
|
|
10
|
+
export class LDAIConfigMapper {
|
|
11
|
+
constructor(
|
|
12
|
+
private _model?: LDModelConfig | undefined,
|
|
13
|
+
private _provider?: LDProviderConfig | undefined,
|
|
14
|
+
private _messages?: LDMessage[] | undefined,
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
private _findParameter<T>(...paramNames: string[]): T | undefined {
|
|
18
|
+
for (let i = 0; i < paramNames.length; i += 1) {
|
|
19
|
+
const paramName = paramNames[i];
|
|
20
|
+
if (this._model?.parameters?.[paramName] !== undefined) {
|
|
21
|
+
return this._model?.parameters?.[paramName] as T;
|
|
22
|
+
}
|
|
23
|
+
if (this._model?.custom?.[paramName] !== undefined) {
|
|
24
|
+
return this._model?.custom?.[paramName] as T;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
toVercelAISDK<TMod>(
|
|
31
|
+
provider: VercelAISDKProvider<TMod> | Record<string, VercelAISDKProvider<TMod>>,
|
|
32
|
+
options?: VercelAISDKMapOptions | undefined,
|
|
33
|
+
): VercelAISDKConfig<TMod> {
|
|
34
|
+
let model: TMod | undefined;
|
|
35
|
+
if (typeof provider === 'function') {
|
|
36
|
+
model = provider(this._model?.name ?? '');
|
|
37
|
+
} else {
|
|
38
|
+
model = provider[this._provider?.name ?? '']?.(this._model?.name ?? '');
|
|
39
|
+
}
|
|
40
|
+
if (!model) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
'Vercel AI SDK model cannot be determined from the supplied provider parameter.',
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let messages: LDMessage[] | undefined;
|
|
47
|
+
if (this._messages || options?.nonInterpolatedMessages) {
|
|
48
|
+
messages = [...(this._messages ?? []), ...(options?.nonInterpolatedMessages ?? [])];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
model,
|
|
53
|
+
messages,
|
|
54
|
+
maxTokens: this._findParameter('max_tokens', 'maxTokens'),
|
|
55
|
+
temperature: this._findParameter('temperature'),
|
|
56
|
+
topP: this._findParameter('top_p', 'topP'),
|
|
57
|
+
topK: this._findParameter('top_k', 'topK'),
|
|
58
|
+
presencePenalty: this._findParameter('presence_penalty', 'presencePenalty'),
|
|
59
|
+
frequencyPenalty: this._findParameter('frequency_penalty', 'frequencyPenalty'),
|
|
60
|
+
stopSequences: this._findParameter('stop', 'stop_sequences', 'stopSequences'),
|
|
61
|
+
seed: this._findParameter('seed'),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -2,8 +2,13 @@ import { LDContext } from '@launchdarkly/js-server-sdk-common';
|
|
|
2
2
|
|
|
3
3
|
import { LDAIConfigTracker } from './api/config';
|
|
4
4
|
import { LDAIMetricSummary } from './api/config/LDAIConfigTracker';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
createBedrockTokenUsage,
|
|
7
|
+
createOpenAiUsage,
|
|
8
|
+
createVercelAISDKTokenUsage,
|
|
9
|
+
LDFeedbackKind,
|
|
10
|
+
LDTokenUsage,
|
|
11
|
+
} from './api/metrics';
|
|
7
12
|
import { LDClientMin } from './LDClientMin';
|
|
8
13
|
|
|
9
14
|
export class LDAIConfigTrackerImpl implements LDAIConfigTracker {
|
|
@@ -121,6 +126,72 @@ export class LDAIConfigTrackerImpl implements LDAIConfigTracker {
|
|
|
121
126
|
return res;
|
|
122
127
|
}
|
|
123
128
|
|
|
129
|
+
async trackVercelAISDKGenerateTextMetrics<
|
|
130
|
+
TRes extends {
|
|
131
|
+
usage?: {
|
|
132
|
+
totalTokens?: number;
|
|
133
|
+
promptTokens?: number;
|
|
134
|
+
completionTokens?: number;
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
>(func: () => Promise<TRes>): Promise<TRes> {
|
|
138
|
+
try {
|
|
139
|
+
const result = await this.trackDurationOf(func);
|
|
140
|
+
this.trackSuccess();
|
|
141
|
+
if (result.usage) {
|
|
142
|
+
this.trackTokens(createVercelAISDKTokenUsage(result.usage));
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
} catch (err) {
|
|
146
|
+
this.trackError();
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
trackVercelAISDKStreamTextMetrics<
|
|
152
|
+
TRes extends {
|
|
153
|
+
finishReason?: Promise<string>;
|
|
154
|
+
usage?: Promise<{
|
|
155
|
+
totalTokens?: number;
|
|
156
|
+
promptTokens?: number;
|
|
157
|
+
completionTokens?: number;
|
|
158
|
+
}>;
|
|
159
|
+
},
|
|
160
|
+
>(func: () => TRes): TRes {
|
|
161
|
+
const startTime = Date.now();
|
|
162
|
+
try {
|
|
163
|
+
const result = func();
|
|
164
|
+
result.finishReason
|
|
165
|
+
?.then(async (finishReason) => {
|
|
166
|
+
const endTime = Date.now();
|
|
167
|
+
this.trackDuration(endTime - startTime);
|
|
168
|
+
if (finishReason === 'error') {
|
|
169
|
+
this.trackError();
|
|
170
|
+
} else {
|
|
171
|
+
this.trackSuccess();
|
|
172
|
+
if (result.usage) {
|
|
173
|
+
try {
|
|
174
|
+
this.trackTokens(createVercelAISDKTokenUsage(await result.usage));
|
|
175
|
+
} catch {
|
|
176
|
+
// Intentionally squashing this error
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
.catch(() => {
|
|
182
|
+
const endTime = Date.now();
|
|
183
|
+
this.trackDuration(endTime - startTime);
|
|
184
|
+
this.trackError();
|
|
185
|
+
});
|
|
186
|
+
return result;
|
|
187
|
+
} catch (err) {
|
|
188
|
+
const endTime = Date.now();
|
|
189
|
+
this.trackDuration(endTime - startTime);
|
|
190
|
+
this.trackError();
|
|
191
|
+
throw err;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
124
195
|
trackTokens(tokens: LDTokenUsage): void {
|
|
125
196
|
this._trackedMetrics.tokens = tokens;
|
|
126
197
|
const trackData = this._getTrackData();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LDAIConfigTracker } from './LDAIConfigTracker';
|
|
2
|
+
import { VercelAISDKConfig, VercelAISDKMapOptions, VercelAISDKProvider } from './VercelAISDK';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Configuration related to the model.
|
|
@@ -22,7 +23,7 @@ export interface LDModelConfig {
|
|
|
22
23
|
|
|
23
24
|
export interface LDProviderConfig {
|
|
24
25
|
/**
|
|
25
|
-
* The
|
|
26
|
+
* The name of the provider.
|
|
26
27
|
*/
|
|
27
28
|
name: string;
|
|
28
29
|
}
|
|
@@ -68,13 +69,29 @@ export interface LDAIConfig {
|
|
|
68
69
|
* Whether the configuration is enabled.
|
|
69
70
|
*/
|
|
70
71
|
enabled: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Maps this AI config to a format usable direcly in Vercel AI SDK generateText()
|
|
75
|
+
* and streamText() methods.
|
|
76
|
+
*
|
|
77
|
+
* WARNING: this method can throw an exception if a Vercel AI SDK model cannot be determined.
|
|
78
|
+
*
|
|
79
|
+
* @param provider A Vercel AI SDK Provider or a map of provider names to Vercel AI SDK Providers.
|
|
80
|
+
* @param options Optional mapping options.
|
|
81
|
+
* @returns A configuration directly usable in Vercel AI SDK generateText() and streamText()
|
|
82
|
+
* @throws {Error} if a Vercel AI SDK model cannot be determined from the given provider parameter.
|
|
83
|
+
*/
|
|
84
|
+
toVercelAISDK: <TMod>(
|
|
85
|
+
provider: VercelAISDKProvider<TMod> | Record<string, VercelAISDKProvider<TMod>>,
|
|
86
|
+
options?: VercelAISDKMapOptions | undefined,
|
|
87
|
+
) => VercelAISDKConfig<TMod>;
|
|
71
88
|
}
|
|
72
89
|
|
|
73
90
|
/**
|
|
74
91
|
* Default value for a `modelConfig`. This is the same as the LDAIConfig, but it does not include
|
|
75
|
-
* a tracker and `enabled` is optional.
|
|
92
|
+
* a tracker or mapper, and `enabled` is optional.
|
|
76
93
|
*/
|
|
77
|
-
export type LDAIDefaults = Omit<LDAIConfig, 'tracker' | 'enabled'> & {
|
|
94
|
+
export type LDAIDefaults = Omit<LDAIConfig, 'tracker' | 'enabled' | 'toVercelAISDK'> & {
|
|
78
95
|
/**
|
|
79
96
|
* Whether the configuration is enabled.
|
|
80
97
|
*
|
|
@@ -133,6 +133,55 @@ export interface LDAIConfigTracker {
|
|
|
133
133
|
res: TRes,
|
|
134
134
|
): TRes;
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Track a Vercel AI SDK generateText operation.
|
|
138
|
+
*
|
|
139
|
+
* This function will track the duration of the operation, the token usage, and the success or error status.
|
|
140
|
+
*
|
|
141
|
+
* If the provided function throws, then this method will also throw.
|
|
142
|
+
* In the case the provided function throws, this function will record the duration and an error.
|
|
143
|
+
* A failed operation will not have any token usage data.
|
|
144
|
+
*
|
|
145
|
+
* @param func Function which executes the operation.
|
|
146
|
+
* @returns The result of the operation.
|
|
147
|
+
*/
|
|
148
|
+
trackVercelAISDKGenerateTextMetrics<
|
|
149
|
+
TRes extends {
|
|
150
|
+
usage?: {
|
|
151
|
+
totalTokens?: number;
|
|
152
|
+
promptTokens?: number;
|
|
153
|
+
completionTokens?: number;
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
>(
|
|
157
|
+
func: () => Promise<TRes>,
|
|
158
|
+
): Promise<TRes>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Track a Vercel AI SDK streamText operation.
|
|
162
|
+
*
|
|
163
|
+
* This function will track the duration of the operation, the token usage, and the success or error status.
|
|
164
|
+
*
|
|
165
|
+
* If the provided function throws, then this method will also throw.
|
|
166
|
+
* In the case the provided function throws, this function will record the duration and an error.
|
|
167
|
+
* A failed operation will not have any token usage data.
|
|
168
|
+
*
|
|
169
|
+
* @param func Function which executes the operation.
|
|
170
|
+
* @returns The result of the operation.
|
|
171
|
+
*/
|
|
172
|
+
trackVercelAISDKStreamTextMetrics<
|
|
173
|
+
TRes extends {
|
|
174
|
+
finishReason?: Promise<string>;
|
|
175
|
+
usage?: Promise<{
|
|
176
|
+
totalTokens?: number;
|
|
177
|
+
promptTokens?: number;
|
|
178
|
+
completionTokens?: number;
|
|
179
|
+
}>;
|
|
180
|
+
},
|
|
181
|
+
>(
|
|
182
|
+
func: () => TRes,
|
|
183
|
+
): TRes;
|
|
184
|
+
|
|
136
185
|
/**
|
|
137
186
|
* Get a summary of the tracked metrics.
|
|
138
187
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type LDMessage } from './LDAIConfig';
|
|
2
|
+
|
|
3
|
+
export type VercelAISDKProvider<TMod> = (modelName: string) => TMod;
|
|
4
|
+
|
|
5
|
+
export interface VercelAISDKMapOptions {
|
|
6
|
+
nonInterpolatedMessages?: LDMessage[] | undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface VercelAISDKConfig<TMod> {
|
|
10
|
+
model: TMod;
|
|
11
|
+
messages?: LDMessage[] | undefined;
|
|
12
|
+
maxTokens?: number | undefined;
|
|
13
|
+
temperature?: number | undefined;
|
|
14
|
+
topP?: number | undefined;
|
|
15
|
+
topK?: number | undefined;
|
|
16
|
+
presencePenalty?: number | undefined;
|
|
17
|
+
frequencyPenalty?: number | undefined;
|
|
18
|
+
stopSequences?: string[] | undefined;
|
|
19
|
+
seed?: number | undefined;
|
|
20
|
+
}
|