@burtson-labs/bandit-engine 2.0.8
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/LICENSE +43 -0
- package/README.md +1235 -0
- package/dist/aiProviderStore-YWJHSWFA.mjs +9 -0
- package/dist/aiProviderStore-YWJHSWFA.mjs.map +1 -0
- package/dist/chat-QXB526NZ.mjs +11 -0
- package/dist/chat-QXB526NZ.mjs.map +1 -0
- package/dist/chunk-AVC6IZJQ.mjs +2157 -0
- package/dist/chunk-AVC6IZJQ.mjs.map +1 -0
- package/dist/chunk-BIPELT57.mjs +24183 -0
- package/dist/chunk-BIPELT57.mjs.map +1 -0
- package/dist/chunk-BJTO5JO5.mjs +11 -0
- package/dist/chunk-BJTO5JO5.mjs.map +1 -0
- package/dist/chunk-IXIM7BNO.mjs +39 -0
- package/dist/chunk-IXIM7BNO.mjs.map +1 -0
- package/dist/chunk-KCI46M23.mjs +106 -0
- package/dist/chunk-KCI46M23.mjs.map +1 -0
- package/dist/chunk-WYS5CZVG.mjs +843 -0
- package/dist/chunk-WYS5CZVG.mjs.map +1 -0
- package/dist/cli/cli.js +1808 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/index.d.mts +1636 -0
- package/dist/index.d.ts +1636 -0
- package/dist/index.js +40601 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +12477 -0
- package/dist/index.mjs.map +1 -0
- package/dist/memoryUtils-33TZKHSQ.mjs +223 -0
- package/dist/memoryUtils-33TZKHSQ.mjs.map +1 -0
- package/dist/modelStore-Y3LZWRQC.mjs +9 -0
- package/dist/modelStore-Y3LZWRQC.mjs.map +1 -0
- package/dist/shared/custom-element.js +73 -0
- package/dist/shared/custom-element.js.map +1 -0
- package/dist/shared/custom-element.mjs +8 -0
- package/dist/shared/custom-element.mjs.map +1 -0
- package/docs/00_intro.md +26 -0
- package/docs/01_quickstart.md +54 -0
- package/docs/02_gateway_api.md +64 -0
- package/docs/03_provider_integration.md +38 -0
- package/docs/04_local_dev.md +43 -0
- package/docs/05_cli_quickstart.md +89 -0
- package/docs/05_contributing.md +33 -0
- package/docs/06_busl_licensing.md +25 -0
- package/docs/README.md +9 -0
- package/docs/api_reference/.nojekyll +1 -0
- package/docs/api_reference/assets/highlight.css +141 -0
- package/docs/api_reference/assets/icons.js +18 -0
- package/docs/api_reference/assets/icons.svg +1 -0
- package/docs/api_reference/assets/main.js +60 -0
- package/docs/api_reference/assets/navigation.js +1 -0
- package/docs/api_reference/assets/search.js +1 -0
- package/docs/api_reference/assets/style.css +1493 -0
- package/docs/api_reference/classes/DebugLogger.html +29 -0
- package/docs/api_reference/classes/FeatureFlagService.html +28 -0
- package/docs/api_reference/classes/NotificationService.html +21 -0
- package/docs/api_reference/classes/StreamingTTSClient.html +19 -0
- package/docs/api_reference/classes/VectorDatabaseService.html +63 -0
- package/docs/api_reference/classes/VectorMigrationService.html +27 -0
- package/docs/api_reference/classes/VoiceService.html +4 -0
- package/docs/api_reference/enums/TTSState.html +6 -0
- package/docs/api_reference/functions/Chat.html +1 -0
- package/docs/api_reference/functions/ChatModal.html +29 -0
- package/docs/api_reference/functions/ChatProvider.html +29 -0
- package/docs/api_reference/functions/FeatureFlagProvider.html +30 -0
- package/docs/api_reference/functions/FeedbackButton.html +29 -0
- package/docs/api_reference/functions/FeedbackModal.html +29 -0
- package/docs/api_reference/functions/Management.html +1 -0
- package/docs/api_reference/functions/NotificationProvider.html +29 -0
- package/docs/api_reference/functions/SubscriptionExpiredGuard.html +31 -0
- package/docs/api_reference/functions/SubscriptionExpiredModal.html +31 -0
- package/docs/api_reference/functions/defineCustomElement.html +1 -0
- package/docs/api_reference/functions/getCriticalConfig.html +1 -0
- package/docs/api_reference/functions/getFeatureMatrix.html +1 -0
- package/docs/api_reference/functions/getStreamingTTSClient.html +1 -0
- package/docs/api_reference/functions/getSystemConstants.html +1 -0
- package/docs/api_reference/functions/getTTSState.html +1 -0
- package/docs/api_reference/functions/handleHttpError.html +2 -0
- package/docs/api_reference/functions/handleSubscriptionUpgrade.html +1 -0
- package/docs/api_reference/functions/handleValidationError.html +2 -0
- package/docs/api_reference/functions/initializeCoreSystem.html +1 -0
- package/docs/api_reference/functions/pauseTTS.html +1 -0
- package/docs/api_reference/functions/previewTierUpgrade.html +1 -0
- package/docs/api_reference/functions/resumeTTS.html +1 -0
- package/docs/api_reference/functions/showInfoNotification.html +2 -0
- package/docs/api_reference/functions/showSuccessNotification.html +2 -0
- package/docs/api_reference/functions/speakWithStreaming.html +1 -0
- package/docs/api_reference/functions/stopTTS.html +1 -0
- package/docs/api_reference/functions/syncSubscriptionWithAPI.html +1 -0
- package/docs/api_reference/functions/updateSubscriptionTier.html +2 -0
- package/docs/api_reference/functions/useFeatureFlag.html +2 -0
- package/docs/api_reference/functions/useFeatureVisibility.html +2 -0
- package/docs/api_reference/functions/useFeatures.html +2 -0
- package/docs/api_reference/functions/useGatewayHealth.html +1 -0
- package/docs/api_reference/functions/useGatewayMemory.html +1 -0
- package/docs/api_reference/functions/useGatewayModels.html +1 -0
- package/docs/api_reference/functions/useGlobalTTS.html +2 -0
- package/docs/api_reference/functions/useNotification.html +1 -0
- package/docs/api_reference/functions/useNotificationService.html +6 -0
- package/docs/api_reference/functions/useTTS.html +2 -0
- package/docs/api_reference/functions/useVectorStore.html +13 -0
- package/docs/api_reference/functions/useVoiceStore.html +8 -0
- package/docs/api_reference/functions/useVoices.html +3 -0
- package/docs/api_reference/functions/validateEnvironment.html +1 -0
- package/docs/api_reference/functions/validateSystemIntegrity.html +1 -0
- package/docs/api_reference/index.html +756 -0
- package/docs/api_reference/interfaces/AIChatRequest.html +8 -0
- package/docs/api_reference/interfaces/AIChatResponse.html +3 -0
- package/docs/api_reference/interfaces/AIGenerateRequest.html +5 -0
- package/docs/api_reference/interfaces/AIGenerateResponse.html +3 -0
- package/docs/api_reference/interfaces/AIMessage.html +4 -0
- package/docs/api_reference/interfaces/AIModel.html +6 -0
- package/docs/api_reference/interfaces/AIProviderConfig.html +9 -0
- package/docs/api_reference/interfaces/ChatConfig.html +5 -0
- package/docs/api_reference/interfaces/CreateMemoryOptions.html +7 -0
- package/docs/api_reference/interfaces/FeatureEvaluation.html +14 -0
- package/docs/api_reference/interfaces/FeatureFlagConfig.html +18 -0
- package/docs/api_reference/interfaces/FeatureFlagContextValue.html +16 -0
- package/docs/api_reference/interfaces/FeatureFlagProviderProps.html +4 -0
- package/docs/api_reference/interfaces/FeedbackButtonProps.html +19 -0
- package/docs/api_reference/interfaces/FeedbackCategories.html +6 -0
- package/docs/api_reference/interfaces/FeedbackModalProps.html +4 -0
- package/docs/api_reference/interfaces/FeedbackPriorities.html +5 -0
- package/docs/api_reference/interfaces/FeedbackRequest.html +12 -0
- package/docs/api_reference/interfaces/FeedbackResponse.html +7 -0
- package/docs/api_reference/interfaces/FileUploadResult.html +4 -0
- package/docs/api_reference/interfaces/GatewayChatRequest.html +12 -0
- package/docs/api_reference/interfaces/GatewayChatResponse.html +7 -0
- package/docs/api_reference/interfaces/GatewayContract.html +4 -0
- package/docs/api_reference/interfaces/GatewayGenerateRequest.html +8 -0
- package/docs/api_reference/interfaces/GatewayGenerateResponse.html +12 -0
- package/docs/api_reference/interfaces/GatewayHealthResponse.html +5 -0
- package/docs/api_reference/interfaces/GatewayMemoryRecord.html +7 -0
- package/docs/api_reference/interfaces/GatewayMemoryResponse.html +4 -0
- package/docs/api_reference/interfaces/GatewayMessage.html +5 -0
- package/docs/api_reference/interfaces/GatewayMessageContent.html +4 -0
- package/docs/api_reference/interfaces/GatewayModel.html +9 -0
- package/docs/api_reference/interfaces/GatewayModelsResponse.html +2 -0
- package/docs/api_reference/interfaces/MemorySearchFilters.html +5 -0
- package/docs/api_reference/interfaces/MigrationProgress.html +6 -0
- package/docs/api_reference/interfaces/MigrationStatus.html +7 -0
- package/docs/api_reference/interfaces/NotificationConfig.html +5 -0
- package/docs/api_reference/interfaces/NotificationContextType.html +6 -0
- package/docs/api_reference/interfaces/NotificationProviderProps.html +4 -0
- package/docs/api_reference/interfaces/PackageSettings.html +11 -0
- package/docs/api_reference/interfaces/SearchOptions.html +6 -0
- package/docs/api_reference/interfaces/SearchResult.html +5 -0
- package/docs/api_reference/interfaces/SubscriptionExpiredGuardProps.html +7 -0
- package/docs/api_reference/interfaces/SubscriptionExpiredModalProps.html +6 -0
- package/docs/api_reference/interfaces/TTSOptions.html +5 -0
- package/docs/api_reference/interfaces/TTSProgress.html +6 -0
- package/docs/api_reference/interfaces/TrialUsage.html +6 -0
- package/docs/api_reference/interfaces/UploadRequest.html +9 -0
- package/docs/api_reference/interfaces/UseTTSReturn.html +14 -0
- package/docs/api_reference/interfaces/VectorDocument.html +11 -0
- package/docs/api_reference/interfaces/VectorMemory.html +12 -0
- package/docs/api_reference/interfaces/VectorMemoryMetadata.html +7 -0
- package/docs/api_reference/interfaces/VectorStoreStatus.html +7 -0
- package/docs/api_reference/interfaces/VoiceModelsResponse.html +4 -0
- package/docs/api_reference/interfaces/VoiceState.html +12 -0
- package/docs/api_reference/media/02_gateway_api.md +64 -0
- package/docs/api_reference/media/05_cli_quickstart.md +89 -0
- package/docs/api_reference/media/LICENSE +43 -0
- package/docs/api_reference/media/PRE-PUSH-CHECKLIST.md +10 -0
- package/docs/api_reference/media/PROTECTION-NOTICE.md +60 -0
- package/docs/api_reference/media/PROTECTION-README.md +41 -0
- package/docs/api_reference/media/README-1.md +23 -0
- package/docs/api_reference/media/README.md +9 -0
- package/docs/api_reference/modules.html +123 -0
- package/docs/api_reference/types/FeatureKey.html +2 -0
- package/docs/api_reference/types/FeatureMatrix.html +2 -0
- package/docs/api_reference/types/GatewayQueryOptions.html +1 -0
- package/docs/api_reference/types/LogContext.html +14 -0
- package/docs/api_reference/types/SubscriptionTier.html +2 -0
- package/docs/api_reference/variables/DEFAULT_TIER_FEATURES.html +2 -0
- package/docs/api_reference/variables/FeatureFlagContext.html +1 -0
- package/docs/api_reference/variables/OSS_DEFAULT_FEATURES.html +2 -0
- package/docs/api_reference/variables/SYSTEM_FLAGS.html +1 -0
- package/docs/api_reference/variables/authenticationService.html +1 -0
- package/docs/api_reference/variables/debugLogger-1.html +1 -0
- package/docs/api_reference/variables/featureFlagService-1.html +2 -0
- package/docs/api_reference/variables/notificationService-1.html +1 -0
- package/docs/api_reference/variables/vectorDatabaseService-1.html +1 -0
- package/docs/api_reference/variables/vectorMigrationService-1.html +1 -0
- package/docs/api_reference/variables/voiceService-1.html +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@burtson-labs/bandit-engine</title><meta name="description" content="Documentation for @burtson-labs/bandit-engine"/><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/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base="."><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"><use href="assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">@burtson-labs/bandit-engine</a></div><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"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h1>@burtson-labs/bandit-engine</h1></div><div class="tsd-panel tsd-typography"><p><a href="https://burtson.ai"><img src="https://cdn.burtson.ai/logos/burtson-labs-logo-alt.png" alt="Burtson Labs Logo" width="140" /></a></p>
|
|
2
|
+
<p><a href="https://www.npmjs.com/package/@burtson-labs/bandit-engine" target="_blank" class="external"><img src="https://img.shields.io/npm/v/%40burtson-labs%2Fbandit-engine" alt="npm version"></a>
|
|
3
|
+
<a href="https://www.typescriptlang.org/" target="_blank" class="external"><img src="https://img.shields.io/badge/TypeScript-5.x-3178c6?logo=typescript&logoColor=white" alt="TypeScript"></a>
|
|
4
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-BUSL--1.1-red" alt="License: BUSL-1.1"></a></p>
|
|
5
|
+
<blockquote>
|
|
6
|
+
<p><strong>Welcome to the Bandit Engine – an AI chat interface toolkit from Burtson Labs.</strong>
|
|
7
|
+
Designed for devs who move fast, think sharp, and want full control over their AI chat UX. Plug it in, power it up, and bend AI to your brand's will.</p>
|
|
8
|
+
</blockquote>
|
|
9
|
+
<p>📚 Looking for docs? Start with the <a href="media/README.md">documentation index</a> or jump straight to the <a href="media/02_gateway_api.md">gateway contract</a>.</p>
|
|
10
|
+
<p>🧪 Want to kick the tires? Clone the <a href="media/README-1.md">Node.js gateway example</a> for a ready-to-run backend.</p>
|
|
11
|
+
<a id="md:⚡-cli-quick-start" class="tsd-anchor"></a><h2 class="tsd-anchor-link">⚡ CLI Quick Start<a href="#md:⚡-cli-quick-start" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Want a working playground instantly? Scaffold a Bandit app and gateway in one command:</p>
|
|
12
|
+
<pre><code class="bash"><span class="hl-0">npx</span><span class="hl-1"> </span><span class="hl-2">@burtson-labs/bandit-engine</span><span class="hl-1"> </span><span class="hl-2">create</span><span class="hl-1"> </span><span class="hl-2">my-bandit-app</span>
|
|
13
|
+
</code><button type="button">Copy</button></pre>
|
|
14
|
+
|
|
15
|
+
<p><img src="https://cdn.burtson.ai/images/cli-quickstart.jpg" alt="Bandit CLI quickstart walkthrough"></p>
|
|
16
|
+
<p>What you get out of the box:</p>
|
|
17
|
+
<ul>
|
|
18
|
+
<li>Vite + React project wired with <code>Chat</code>, <code>ChatModal</code>, and <code>ChatProvider</code></li>
|
|
19
|
+
<li>Express gateway that proxies OpenAI or Ollama behind <code>/api</code></li>
|
|
20
|
+
<li>Branding + persona config in <code>public/config.json</code>, ready for your logo or prompts</li>
|
|
21
|
+
</ul>
|
|
22
|
+
<p>Customize the output with options such as:</p>
|
|
23
|
+
<ul>
|
|
24
|
+
<li><code>--branding-text "Bandit Support"</code> to set the assistant display name</li>
|
|
25
|
+
<li><code>--frontend-port 5190</code> to change the Vite dev server port</li>
|
|
26
|
+
<li><code>--gateway-port 9090</code> to run the sample gateway on an alternate port</li>
|
|
27
|
+
<li><code>--yes</code> / <code>--skip-prompts</code> to accept defaults non-interactively</li>
|
|
28
|
+
<li><code>--force</code> to overwrite a non-empty directory</li>
|
|
29
|
+
</ul>
|
|
30
|
+
<blockquote>
|
|
31
|
+
<p>🗝️ The generated project includes an <code>.npmrc</code> that targets <code>https://npm.pkg.github.com/</code> and expects a <code>GITHUB_NPM_TOKEN</code> environment variable. Run <code>npm login --registry=https://npm.pkg.github.com --scope=@burtson-labs</code> (or export <code>GITHUB_NPM_TOKEN</code>) before installing dependencies.</p>
|
|
32
|
+
</blockquote>
|
|
33
|
+
<p>Check out the <a href="media/05_cli_quickstart.md">CLI quick start guide</a> for the full walkthrough, option matrix, and project anatomy.</p>
|
|
34
|
+
<a id="md:cli-options" class="tsd-anchor"></a><h3 class="tsd-anchor-link">CLI Options<a href="#md:cli-options" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><table>
|
|
35
|
+
<thead>
|
|
36
|
+
<tr>
|
|
37
|
+
<th>Flag</th>
|
|
38
|
+
<th>Description</th>
|
|
39
|
+
<th>Example</th>
|
|
40
|
+
</tr>
|
|
41
|
+
</thead>
|
|
42
|
+
<tbody>
|
|
43
|
+
<tr>
|
|
44
|
+
<td><code>--branding-text <text></code></td>
|
|
45
|
+
<td>Set the assistant name shown in the UI.</td>
|
|
46
|
+
<td><code>--branding-text "Bandit Support"</code></td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td><code>--frontend-port <port></code></td>
|
|
50
|
+
<td>Change the Vite dev server port (default <code>5183</code>).</td>
|
|
51
|
+
<td><code>--frontend-port 5190</code></td>
|
|
52
|
+
</tr>
|
|
53
|
+
<tr>
|
|
54
|
+
<td><code>--gateway-port <port></code></td>
|
|
55
|
+
<td>Change the sample gateway port (default <code>8080</code>).</td>
|
|
56
|
+
<td><code>--gateway-port 9090</code></td>
|
|
57
|
+
</tr>
|
|
58
|
+
<tr>
|
|
59
|
+
<td><code>--yes</code>, <code>--skip-prompts</code></td>
|
|
60
|
+
<td>Accept defaults without interactive questions.</td>
|
|
61
|
+
<td><code>--yes</code></td>
|
|
62
|
+
</tr>
|
|
63
|
+
<tr>
|
|
64
|
+
<td><code>--force</code></td>
|
|
65
|
+
<td>Overwrite the target directory if it already exists.</td>
|
|
66
|
+
<td><code>--force</code></td>
|
|
67
|
+
</tr>
|
|
68
|
+
</tbody>
|
|
69
|
+
</table>
|
|
70
|
+
<p>The CLI prints next steps (install, copy <code>.env</code>, run dev server) once scaffolding completes, so you can copy-paste and ship immediately.</p>
|
|
71
|
+
<a id="md:🛠️-getting-started--plug--play-ai" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🛠️ Getting Started – Plug & Play AI<a href="#md:🛠️-getting-started--plug--play-ai" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><ol>
|
|
72
|
+
<li><strong>Add a config.json</strong> to your public folder (or host it on a CDN) and point <code>brandingConfigUrl</code> at it:</li>
|
|
73
|
+
</ol>
|
|
74
|
+
<p><em>Host it locally in <code>/public</code> or serve it from a CDN and reference it via <code>brandingConfigUrl</code>.</em></p>
|
|
75
|
+
<pre><code class="json"><span class="hl-1">{</span><br/><span class="hl-1"> </span><span class="hl-3">"theme"</span><span class="hl-1">: </span><span class="hl-2">"bandit-dark"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"branding"</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-3">"brandingText"</span><span class="hl-1">: </span><span class="hl-2">"Bandit Chat Premium Beta"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"logoBase64"</span><span class="hl-1">: </span><span class="hl-2">""</span><br/><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-3">"models"</span><span class="hl-1">: [</span><br/><span class="hl-1"> { </span><span class="hl-3">"name"</span><span class="hl-1">: </span><span class="hl-2">"Bandit-Core"</span><span class="hl-1">, </span><span class="hl-3">"description"</span><span class="hl-1">: </span><span class="hl-2">"General purpose model"</span><span class="hl-1"> },</span><br/><span class="hl-1"> { </span><span class="hl-3">"name"</span><span class="hl-1">: </span><span class="hl-2">"Bandit-Muse"</span><span class="hl-1">, </span><span class="hl-3">"description"</span><span class="hl-1">: </span><span class="hl-2">"Creative writing model"</span><span class="hl-1"> }</span><br/><span class="hl-1"> ]</span><br/><span class="hl-1">}</span>
|
|
76
|
+
</code><button type="button">Copy</button></pre>
|
|
77
|
+
|
|
78
|
+
<p>No bloated setup. No magic strings. Just drop in your <code>config.json</code>, hook up a few props, and let your AI speak for itself.</p>
|
|
79
|
+
<ol start="2">
|
|
80
|
+
<li><strong>Wrap your entire app with <code>ChatProvider</code> to enable Bandit features globally:</strong></li>
|
|
81
|
+
</ol>
|
|
82
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> </span><span class="hl-5">React</span><span class="hl-1"> </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">"react"</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> </span><span class="hl-5">ReactDOM</span><span class="hl-1"> </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">"react-dom/client"</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> </span><span class="hl-5">App</span><span class="hl-1"> </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">"./App"</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">CssBaseline</span><span class="hl-1">, </span><span class="hl-5">ThemeProvider</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">"@mui/material"</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">banditDarkTheme</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">"./theme/banditTheme"</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">AppInitializer</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">"./app-initializer"</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">ChatProvider</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">"@burtson-labs/bandit-engine"</span><span class="hl-1">;</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">chatPackageSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-8">// New Gateway Provider Configuration (Recommended)</span><br/><span class="hl-1"> </span><span class="hl-5">aiProvider:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-5">type:</span><span class="hl-1"> </span><span class="hl-2">"gateway"</span><span class="hl-1"> </span><span class="hl-4">as</span><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">gatewayUrl:</span><span class="hl-1"> </span><span class="hl-4">import</span><span class="hl-1">.</span><span class="hl-5">meta</span><span class="hl-1">.</span><span class="hl-5">env</span><span class="hl-1">.</span><span class="hl-7">VITE_GATEWAY_API_URL</span><span class="hl-1">!,</span><br/><span class="hl-1"> </span><span class="hl-5">provider:</span><span class="hl-1"> </span><span class="hl-2">"openai"</span><span class="hl-1"> </span><span class="hl-8">// Backend: openai, azure-openai, anthropic, ollama</span><br/><span class="hl-1"> },</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Legacy Ollama Configuration (Still Supported)</span><br/><span class="hl-1"> </span><span class="hl-8">// ollamaUrl: import.meta.env.VITE_OLLAMA_URL!,</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Model Configuration</span><br/><span class="hl-1"> </span><span class="hl-5">defaultModel:</span><span class="hl-1"> </span><span class="hl-4">import</span><span class="hl-1">.</span><span class="hl-5">meta</span><span class="hl-1">.</span><span class="hl-5">env</span><span class="hl-1">.</span><span class="hl-7">VITE_DEFAULT_MODEL</span><span class="hl-1">!,</span><br/><span class="hl-1"> </span><span class="hl-5">fallbackModel:</span><span class="hl-1"> </span><span class="hl-4">import</span><span class="hl-1">.</span><span class="hl-5">meta</span><span class="hl-1">.</span><span class="hl-5">env</span><span class="hl-1">.</span><span class="hl-7">VITE_FALLBACK_MODEL</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-5">gatewayApiUrl:</span><span class="hl-1"> </span><span class="hl-4">import</span><span class="hl-1">.</span><span class="hl-5">meta</span><span class="hl-1">.</span><span class="hl-5">env</span><span class="hl-1">.</span><span class="hl-7">VITE_GATEWAY_API_URL</span><span class="hl-1">!,</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Branding and optional overrides</span><br/><span class="hl-1"> </span><span class="hl-5">brandingConfigUrl:</span><span class="hl-1"> </span><span class="hl-2">"/config.json"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-8">// s3ApiUrl: import.meta.env.VITE_S3_API_URL,</span><br/><span class="hl-1"> </span><span class="hl-8">// homeUrl: "https://yourapp.com",</span><br/><span class="hl-1"> </span><span class="hl-8">// feedbackEmail: "feedback@yourapp.com",</span><br/><span class="hl-1">};</span><br/><br/><span class="hl-5">ReactDOM</span><span class="hl-1">.</span><span class="hl-0">createRoot</span><span class="hl-1">(</span><span class="hl-5">document</span><span class="hl-1">.</span><span class="hl-0">getElementById</span><span class="hl-1">(</span><span class="hl-2">"root"</span><span class="hl-1">)!).</span><span class="hl-0">render</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">React.StrictMode</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">ThemeProvider</span><span class="hl-1"> </span><span class="hl-11">theme</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-5">banditDarkTheme</span><span class="hl-6">}</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">CssBaseline</span><span class="hl-1"> </span><span class="hl-9">/></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">AppInitializer</span><span class="hl-1"> </span><span class="hl-9">/></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">ChatProvider</span><span class="hl-1"> </span><span class="hl-11">packageSettings</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-5">chatPackageSettings</span><span class="hl-6">}</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">App</span><span class="hl-1"> </span><span class="hl-9">/></span><br/><span class="hl-1"> </span><span class="hl-9"></</span><span class="hl-10">ChatProvider</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"></</span><span class="hl-10">ThemeProvider</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"></</span><span class="hl-10">React.StrictMode</span><span class="hl-9">></span><br/><span class="hl-1">);</span>
|
|
83
|
+
</code><button type="button">Copy</button></pre>
|
|
84
|
+
|
|
85
|
+
<blockquote>
|
|
86
|
+
<p>🚀 Within minutes, you'll have a fully functional chat interface that can read, speak, and reason – all brandable, themeable, and extensible.</p>
|
|
87
|
+
</blockquote>
|
|
88
|
+
<a id="md:🔄-quick-provider-setup" class="tsd-anchor"></a><h3 class="tsd-anchor-link">🔄 Quick Provider Setup<a href="#md:🔄-quick-provider-setup" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p><strong>Option 1: Gateway Provider (Recommended)</strong></p>
|
|
89
|
+
<pre><code class="tsx"><span class="hl-8">// Most secure - API keys stay on your backend</span><br/><span class="hl-8">// Your gateway can be built in ANY language: Node.js, Python, .NET, Java, PHP, Go, etc.</span><br/><span class="hl-12">aiProvider</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-12">type</span><span class="hl-1">: </span><span class="hl-2">"gateway"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-12">gatewayUrl</span><span class="hl-1">: </span><span class="hl-2">"https://your-api-gateway.com"</span><span class="hl-1">, </span><span class="hl-8">// Your backend API</span><br/><span class="hl-1"> </span><span class="hl-12">provider</span><span class="hl-1">: </span><span class="hl-2">"openai"</span><span class="hl-1"> </span><span class="hl-8">// Specify which AI provider to use</span><br/><span class="hl-1">}</span>
|
|
90
|
+
</code><button type="button">Copy</button></pre>
|
|
91
|
+
|
|
92
|
+
<p><strong>Option 2: Direct Provider (Development)</strong></p>
|
|
93
|
+
<pre><code class="tsx"><span class="hl-8">// Quick start - API keys in frontend (not for production)</span><br/><span class="hl-12">aiProvider</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-12">type</span><span class="hl-1">: </span><span class="hl-2">"ollama"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-12">baseUrl</span><span class="hl-1">: </span><span class="hl-2">"http://localhost:11434"</span><br/><span class="hl-1">}</span>
|
|
94
|
+
</code><button type="button">Copy</button></pre>
|
|
95
|
+
|
|
96
|
+
<p><strong>Gateway Requirements:</strong> Your backend needs to implement these endpoints:</p>
|
|
97
|
+
<ul>
|
|
98
|
+
<li><code>GET /api/health</code> - Health check</li>
|
|
99
|
+
<li><code>POST /api/chat/completions</code> - Chat completions</li>
|
|
100
|
+
<li><code>POST /api/generate</code> - Text generation</li>
|
|
101
|
+
<li><code>POST /api/tts</code> - Text-to-Speech (optional, for voice features)</li>
|
|
102
|
+
<li><code>GET /api/tts/available-models</code> - TTS model listing (optional)</li>
|
|
103
|
+
<li><code>POST /api/stt</code> - Speech-to-Text (optional, for voice input)</li>
|
|
104
|
+
</ul>
|
|
105
|
+
<blockquote>
|
|
106
|
+
<p><strong>⚠️ Important:</strong> The Bandit Engine automatically routes to provider-specific endpoints:</p>
|
|
107
|
+
<ul>
|
|
108
|
+
<li><strong>Ollama</strong> → <code>/api/ollama/chat</code> (native Ollama format)</li>
|
|
109
|
+
<li><strong>OpenAI/Azure/Anthropic</strong> → <code>/api/{provider}/chat/completions</code> (OpenAI format)</li>
|
|
110
|
+
<li><strong>TTS/STT</strong> → Technology-agnostic endpoints that work with any backend implementation</li>
|
|
111
|
+
</ul>
|
|
112
|
+
</blockquote>
|
|
113
|
+
<a id="md:ollama-env-setup" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Ollama .env Setup<a href="#md:ollama-env-setup" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>To run the quickstart purely against an Ollama daemon:</p>
|
|
114
|
+
<ol>
|
|
115
|
+
<li>
|
|
116
|
+
<p>Install (or build) the models you want to expose, e.g.:</p>
|
|
117
|
+
<pre><code class="bash"><span class="hl-0">ollama</span><span class="hl-1"> </span><span class="hl-2">pull</span><span class="hl-1"> </span><span class="hl-2">llava:latest</span><br/><span class="hl-0">ollama</span><span class="hl-1"> </span><span class="hl-2">pull</span><span class="hl-1"> </span><span class="hl-2">gemma2:9b-instruct</span>
|
|
118
|
+
</code><button type="button">Copy</button></pre>
|
|
119
|
+
|
|
120
|
+
</li>
|
|
121
|
+
<li>
|
|
122
|
+
<p>Edit the generated <code>.env</code> and point both the frontend and gateway at Ollama:</p>
|
|
123
|
+
<pre><code class="ini"># Frontend
|
|
124
|
+
VITE_GATEWAY_PROVIDER=ollama
|
|
125
|
+
VITE_DEFAULT_MODEL=llava:latest # any model installed on your Ollama box
|
|
126
|
+
VITE_FALLBACK_MODEL=gemma2:9b-instruct # optional, but handy for text-only fallbacks
|
|
127
|
+
|
|
128
|
+
# Gateway / server
|
|
129
|
+
OLLAMA_URL=http://localhost:11434 # or the remote daemon address
|
|
130
|
+
</code><button type="button">Copy</button></pre>
|
|
131
|
+
|
|
132
|
+
<p>Set <code>VITE_DEFAULT_MODEL</code> / <code>VITE_FALLBACK_MODEL</code> to the exact Ollama model tags you have available (<code>gemma</code>, <code>llava</code>, <code>moondream</code>, or your own custom builds). Bandit automatically detects multimodal Ollama models, so setting <code>llava</code>, <code>moondream</code>, or other vision-capable variants enables image understanding with no extra code.</p>
|
|
133
|
+
</li>
|
|
134
|
+
</ol>
|
|
135
|
+
<a id="md:🎤-voice-services-ttsstt" class="tsd-anchor"></a><h3 class="tsd-anchor-link">🎤 Voice Services (TTS/STT)<a href="#md:🎤-voice-services-ttsstt" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The Bandit Engine supports Text-to-Speech (TTS) and Speech-to-Text (STT) through your gateway API. These services are <strong>technology-agnostic</strong> - you can implement them using any backend technology:</p>
|
|
136
|
+
<p><strong>TTS Endpoint (<code>POST /api/tts</code>)</strong></p>
|
|
137
|
+
<ul>
|
|
138
|
+
<li><strong>Input</strong>: <code>{ text: string, voice?: string, speed?: number }</code></li>
|
|
139
|
+
<li><strong>Output</strong>: Audio file (MP3, WAV, etc.) or streaming audio</li>
|
|
140
|
+
<li><strong>Compatible with</strong>: OpenAI TTS, Azure Speech, Google Cloud TTS, AWS Polly, local TTS servers, or custom implementations</li>
|
|
141
|
+
</ul>
|
|
142
|
+
<p><strong>STT Endpoint (<code>POST /api/stt</code>)</strong></p>
|
|
143
|
+
<ul>
|
|
144
|
+
<li><strong>Input</strong>: Audio file upload (multipart/form-data)</li>
|
|
145
|
+
<li><strong>Output</strong>: <code>{ text: string }</code> or <code>{ transcription: string }</code></li>
|
|
146
|
+
<li><strong>Compatible with</strong>: OpenAI Whisper, Azure Speech, Google Speech, AWS Transcribe, local Whisper servers, or custom implementations</li>
|
|
147
|
+
</ul>
|
|
148
|
+
<p><strong>Service Discovery (<code>GET /api/tts/available-models</code>)</strong></p>
|
|
149
|
+
<ul>
|
|
150
|
+
<li><strong>Output</strong>: <code>{ models: string[], defaultModel: string, fallbackModel: string }</code></li>
|
|
151
|
+
<li>Used for automatic service availability detection and voice model selection</li>
|
|
152
|
+
</ul>
|
|
153
|
+
<p>See the <a href="media/02_gateway_api.md">Gateway API Contract</a> for complete implementation examples in multiple languages.</p>
|
|
154
|
+
<p>Use the Management interface to switch providers anytime or migrate from direct to gateway setup.</p>
|
|
155
|
+
<ol start="3">
|
|
156
|
+
<li><strong>Development</strong></li>
|
|
157
|
+
</ol>
|
|
158
|
+
<ul>
|
|
159
|
+
<li>Use <code>npm link</code> or a monorepo workspace to test locally before publishing.</li>
|
|
160
|
+
<li>Build with <code>tsup</code>.</li>
|
|
161
|
+
</ul>
|
|
162
|
+
<hr>
|
|
163
|
+
<a id="md:🧩-consuming-the-components" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🧩 Consuming the Components<a href="#md:🧩-consuming-the-components" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Once you've wrapped your app with <code>ChatProvider</code>, you can selectively integrate Bandit's components as needed:</p>
|
|
164
|
+
<ul>
|
|
165
|
+
<li><code><Chat /></code>: The main chat interface, designed to be used on a dedicated page or embedded into your product.</li>
|
|
166
|
+
<li><code><Management /></code>: A full-featured admin and model configuration UI. This should not be on the same page as <code><Chat /></code>. Use this to allow authenticated users to manage themes, models, and embedded knowledge.</li>
|
|
167
|
+
<li><code><ChatModal /></code>: A flexible, mobile-friendly modal that can be launched anywhere in your app for quick AI interactions. Features include:
|
|
168
|
+
<ul>
|
|
169
|
+
<li><strong>Chat Control Center</strong>: Built-in conversation management, voice model switching, and memory controls</li>
|
|
170
|
+
<li><strong>Context Switching</strong>: Toggle between local session and saved conversation history</li>
|
|
171
|
+
<li><strong>Voice Integration</strong>: Voice model selection with real-time preview (when TTS is configured)</li>
|
|
172
|
+
<li><strong>Navigation</strong>: Seamless transition from modal to full chat interface</li>
|
|
173
|
+
<li><strong>Auto-theming</strong>: Automatically uses the theme configured in the Management interface</li>
|
|
174
|
+
</ul>
|
|
175
|
+
</li>
|
|
176
|
+
</ul>
|
|
177
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">Chat</span><span class="hl-1">, </span><span class="hl-5">Management</span><span class="hl-1">, </span><span class="hl-5">ChatModal</span><span class="hl-1">, </span><span class="hl-5">ChatProvider</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">useState</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'react'</span><span class="hl-1">;</span><br/><br/><span class="hl-6">function</span><span class="hl-1"> </span><span class="hl-0">YourPage</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> [</span><span class="hl-7">isModalOpen</span><span class="hl-1">, </span><span class="hl-7">setIsModalOpen</span><span class="hl-1">] = </span><span class="hl-0">useState</span><span class="hl-1">(</span><span class="hl-6">false</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-4">return</span><span class="hl-1"> (</span><br/><span class="hl-1"> </span><span class="hl-9"><></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">Chat</span><span class="hl-1"> </span><span class="hl-9">/></span><br/><span class="hl-1"> </span><span class="hl-6">{</span><span class="hl-8">/* Use <Management /> on a separate admin route with access controls */</span><span class="hl-6">}</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-6">{</span><span class="hl-8">/* Trigger the AI modal anywhere in your app */</span><span class="hl-6">}</span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">button</span><span class="hl-1"> </span><span class="hl-11">onClick</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-14">() </span><span class="hl-6">=></span><span class="hl-14"> </span><span class="hl-0">setIsModalOpen</span><span class="hl-14">(</span><span class="hl-6">true</span><span class="hl-14">)</span><span class="hl-6">}</span><span class="hl-9">></span><br/><span class="hl-1"> Ask AI</span><br/><span class="hl-1"> </span><span class="hl-9"></</span><span class="hl-13">button</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">ChatModal</span><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-11">open</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-5">isModalOpen</span><span class="hl-6">}</span><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-11">onClose</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-14">() </span><span class="hl-6">=></span><span class="hl-14"> </span><span class="hl-0">setIsModalOpen</span><span class="hl-14">(</span><span class="hl-6">false</span><span class="hl-14">)</span><span class="hl-6">}</span><br/><span class="hl-1"> </span><span class="hl-9">/></span><br/><span class="hl-1"> </span><span class="hl-9"></></span><br/><span class="hl-1"> );</span><br/><span class="hl-1">}</span>
|
|
178
|
+
</code><button type="button">Copy</button></pre>
|
|
179
|
+
|
|
180
|
+
<a id="md:🛠️-utility-functions--hooks" class="tsd-anchor"></a><h3 class="tsd-anchor-link">🛠️ Utility Functions & Hooks<a href="#md:🛠️-utility-functions--hooks" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Bandit Engine exports several utility functions for advanced use cases:</p>
|
|
181
|
+
<a id="md:debug-logger" class="tsd-anchor"></a><h4 class="tsd-anchor-link">Debug Logger<a href="#md:debug-logger" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><p>Replace console statements with structured logging:</p>
|
|
182
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">debugLogger</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-5">debugLogger</span><span class="hl-1">.</span><span class="hl-0">info</span><span class="hl-1">(</span><span class="hl-2">'Chat session started'</span><span class="hl-1">);</span><br/><span class="hl-5">debugLogger</span><span class="hl-1">.</span><span class="hl-0">warn</span><span class="hl-1">(</span><span class="hl-2">'Fallback model selected'</span><span class="hl-1">);</span><br/><span class="hl-5">debugLogger</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">(</span><span class="hl-2">'Connection failed'</span><span class="hl-1">, { </span><span class="hl-5">error:</span><span class="hl-1"> </span><span class="hl-5">details</span><span class="hl-1"> });</span>
|
|
183
|
+
</code><button type="button">Copy</button></pre>
|
|
184
|
+
|
|
185
|
+
<a id="md:ai-prompt-utilities" class="tsd-anchor"></a><h4 class="tsd-anchor-link">AI Prompt Utilities<a href="#md:ai-prompt-utilities" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><p>Access the same prompt functions used internally:</p>
|
|
186
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><br/><span class="hl-1"> </span><span class="hl-5">generateConversationStarters</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">detectMessageMood</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">detectUserInterestAndExcitement</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">summarizeDocument</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">determineRelevantDocuments</span><span class="hl-1"> </span><br/><span class="hl-1">} </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">// Generate conversation starters</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">starters</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">generateConversationStarters</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-5">limit:</span><span class="hl-1"> </span><span class="hl-15">5</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">topicOfInterest:</span><span class="hl-1"> </span><span class="hl-2">"technology, coding, AI"</span><br/><span class="hl-1">});</span><br/><br/><span class="hl-8">// Detect user mood for adaptive responses</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">mood</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">detectMessageMood</span><span class="hl-1">(</span><span class="hl-2">"I'm so excited about this project!"</span><span class="hl-1">);</span><br/><span class="hl-8">// Returns: "high" | "neutral" | "low"</span>
|
|
187
|
+
</code><button type="button">Copy</button></pre>
|
|
188
|
+
|
|
189
|
+
<a id="md:datetime-context" class="tsd-anchor"></a><h4 class="tsd-anchor-link">Date/Time Context<a href="#md:datetime-context" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><p>All AI interactions automatically include current date/time context to improve relevance and accuracy of responses.</p>
|
|
190
|
+
<blockquote>
|
|
191
|
+
<p>⚠️ <strong>Important:</strong> Each component (<code><Chat /></code>, <code><Management /></code>, <code><ChatModal /></code>) <strong>must</strong> be wrapped in a <code>ChatProvider</code> to function correctly.<br>
|
|
192
|
+
In React, you can wrap your app once at the root.<br>
|
|
193
|
+
In Angular or Vue, you may need to wrap each usage with a <code><bandit-chat-provider></code> tag and pass settings each time until full reactive context is supported.</p>
|
|
194
|
+
</blockquote>
|
|
195
|
+
<hr>
|
|
196
|
+
<a id="md:🎛️-chat-control-center-chatmodal-feature" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🎛️ Chat Control Center (ChatModal Feature)<a href="#md:🎛️-chat-control-center-chatmodal-feature" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>The <code><ChatModal /></code> includes a comprehensive Chat Control Center that provides advanced session management:</p>
|
|
197
|
+
<a id="md:🔧-core-features" class="tsd-anchor"></a><h3 class="tsd-anchor-link">🔧 Core Features<a href="#md:🔧-core-features" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
198
|
+
<li><strong>Session vs. Conversation Context</strong>: Toggle between local modal session and persistent conversation history</li>
|
|
199
|
+
<li><strong>Voice Model Selection</strong>: Real-time voice switching with preview greetings (requires TTS gateway configuration)</li>
|
|
200
|
+
<li><strong>Memory Management</strong>: View and manage AI personal memory entries</li>
|
|
201
|
+
<li><strong>Conversation Navigation</strong>: Seamless transition from modal to full chat interface</li>
|
|
202
|
+
<li><strong>Manual Refresh</strong>: Force reload of conversations and voice models for troubleshooting</li>
|
|
203
|
+
</ul>
|
|
204
|
+
<a id="md:🎤-voice-integration" class="tsd-anchor"></a><h3 class="tsd-anchor-link">🎤 Voice Integration<a href="#md:🎤-voice-integration" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>When your gateway API includes TTS endpoints, the Chat Control Center provides:</p>
|
|
205
|
+
<ul>
|
|
206
|
+
<li><strong>Voice Selection Dropdown</strong>: Choose from available voice models (e.g., Mark, Amy, Kathleen, Lessac, Ryan)</li>
|
|
207
|
+
<li><strong>Real-time Preview</strong>: Hear voice greetings when switching models</li>
|
|
208
|
+
<li><strong>Consistent Formatting</strong>: Voice names display as proper titles (e.g., "Mark" instead of "en_US-mark-premium")</li>
|
|
209
|
+
<li><strong>Availability Detection</strong>: Automatic detection and fallback when voice services are unavailable</li>
|
|
210
|
+
</ul>
|
|
211
|
+
<a id="md:🔄-context-switching" class="tsd-anchor"></a><h3 class="tsd-anchor-link">🔄 Context Switching<a href="#md:🔄-context-switching" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
212
|
+
<li><strong>Local Session</strong>: Quick interactions within the modal scope</li>
|
|
213
|
+
<li><strong>Main Conversation</strong>: Access full conversation history with automatic navigation to <code>/chat</code> route</li>
|
|
214
|
+
<li><strong>Smart Conversation Selection</strong>: Automatically loads most recent conversation when switching contexts</li>
|
|
215
|
+
</ul>
|
|
216
|
+
<a id="md:💾-memory-features" class="tsd-anchor"></a><h3 class="tsd-anchor-link">💾 Memory Features<a href="#md:💾-memory-features" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
217
|
+
<li><strong>Personal Memory Display</strong>: View AI's stored personal information about the user</li>
|
|
218
|
+
<li><strong>Memory Entry Count</strong>: Real-time count of stored memory entries</li>
|
|
219
|
+
<li><strong>Memory Management Modal</strong>: Full CRUD operations for memory entries</li>
|
|
220
|
+
</ul>
|
|
221
|
+
<p><strong>Example Usage:</strong></p>
|
|
222
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">ChatModal</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-6">function</span><span class="hl-1"> </span><span class="hl-0">App</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> [</span><span class="hl-7">modalOpen</span><span class="hl-1">, </span><span class="hl-7">setModalOpen</span><span class="hl-1">] = </span><span class="hl-0">useState</span><span class="hl-1">(</span><span class="hl-6">false</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-4">return</span><span class="hl-1"> (</span><br/><span class="hl-1"> </span><span class="hl-9"><></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">button</span><span class="hl-1"> </span><span class="hl-11">onClick</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-14">() </span><span class="hl-6">=></span><span class="hl-14"> </span><span class="hl-0">setModalOpen</span><span class="hl-14">(</span><span class="hl-6">true</span><span class="hl-14">)</span><span class="hl-6">}</span><span class="hl-9">></span><br/><span class="hl-1"> Open AI Assistant</span><br/><span class="hl-1"> </span><span class="hl-9"></</span><span class="hl-13">button</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">ChatModal</span><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-11">open</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-5">modalOpen</span><span class="hl-6">}</span><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-11">onClose</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-14">() </span><span class="hl-6">=></span><span class="hl-14"> </span><span class="hl-0">setModalOpen</span><span class="hl-14">(</span><span class="hl-6">false</span><span class="hl-14">)</span><span class="hl-6">}</span><br/><span class="hl-1"> </span><span class="hl-8">// Chat Control Center is automatically included</span><br/><span class="hl-1"> </span><span class="hl-9">/></span><br/><span class="hl-1"> </span><span class="hl-9"></></span><br/><span class="hl-1"> );</span><br/><span class="hl-1">}</span>
|
|
223
|
+
</code><button type="button">Copy</button></pre>
|
|
224
|
+
|
|
225
|
+
<a id="md:📧-feedback-system" class="tsd-anchor"></a><h3 class="tsd-anchor-link">📧 Feedback System<a href="#md:📧-feedback-system" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The Bandit Engine includes a comprehensive feedback system that can be configured and customized for your application.</p>
|
|
226
|
+
<p><strong>Configuration:</strong></p>
|
|
227
|
+
<pre><code class="tsx"><span class="hl-8">// Package Settings - Configure feedback email</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">chatPackageSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-8">// ... other settings</span><br/><span class="hl-1"> </span><span class="hl-5">feedbackEmail:</span><span class="hl-1"> </span><span class="hl-2">"feedback@yourcompany.com"</span><span class="hl-1">, </span><span class="hl-8">// Optional: custom feedback email</span><br/><span class="hl-1">};</span><br/><br/><span class="hl-8">// Preferences - Enable/disable feedback in management UI</span><br/><span class="hl-8">// Users can toggle feedback button on/off in preferences</span>
|
|
228
|
+
</code><button type="button">Copy</button></pre>
|
|
229
|
+
|
|
230
|
+
<p><strong>Standalone Usage:</strong></p>
|
|
231
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">FeedbackButton</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">// Floating FAB button (default)</span><br/><span class="hl-9"><</span><span class="hl-10">FeedbackButton</span><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-11">feedbackEmail</span><span class="hl-1">=</span><span class="hl-2">"support@myapp.com"</span><span class="hl-1"> </span><span class="hl-8">// Optional: override default</span><br/><span class="hl-1"> </span><span class="hl-11">size</span><span class="hl-1">=</span><span class="hl-2">"small"</span><span class="hl-1"> </span><span class="hl-8">// small | medium | large</span><br/><span class="hl-1"> </span><span class="hl-11">position</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-14">{ </span><span class="hl-5">bottom:</span><span class="hl-14"> </span><span class="hl-15">24</span><span class="hl-14">, </span><span class="hl-5">right:</span><span class="hl-14"> </span><span class="hl-15">24</span><span class="hl-14"> }</span><span class="hl-6">}</span><span class="hl-1"> </span><span class="hl-8">// Custom positioning</span><br/><span class="hl-9">/></span><br/><br/><span class="hl-8">// Inline button</span><br/><span class="hl-9"><</span><span class="hl-10">FeedbackButton</span><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-11">inline</span><span class="hl-1">=</span><span class="hl-6">{true}</span><br/><span class="hl-1"> </span><span class="hl-11">buttonText</span><span class="hl-1">=</span><span class="hl-2">"Send Feedback"</span><br/><span class="hl-1"> </span><span class="hl-11">size</span><span class="hl-1">=</span><span class="hl-2">"medium"</span><br/><span class="hl-9">/></span>
|
|
232
|
+
</code><button type="button">Copy</button></pre>
|
|
233
|
+
|
|
234
|
+
<p><strong>Features:</strong></p>
|
|
235
|
+
<ul>
|
|
236
|
+
<li>📱 <strong>Responsive Design</strong>: Automatic floating FAB on desktop, inline button on mobile</li>
|
|
237
|
+
<li>🎨 <strong>Category System</strong>: Bug reports, feature requests, general feedback</li>
|
|
238
|
+
<li>📊 <strong>Priority Levels</strong>: Low, medium, high, critical</li>
|
|
239
|
+
<li>😤 <strong>Annoyance Slider</strong>: Measure user frustration (1-5 scale)</li>
|
|
240
|
+
<li>📎 <strong>Single Image Support</strong>: Automatic clipboard integration</li>
|
|
241
|
+
<li>📧 <strong>Email Fallback</strong>: Generates mailto URLs when API unavailable</li>
|
|
242
|
+
<li>⚙️ <strong>User Preferences</strong>: Can be enabled/disabled in management UI</li>
|
|
243
|
+
</ul>
|
|
244
|
+
<p><strong>Auto-Integration:</strong></p>
|
|
245
|
+
<ul>
|
|
246
|
+
<li>Desktop: Floating feedback button (when <code>preferences.feedbackEnabled</code> is true)</li>
|
|
247
|
+
<li>Mobile: Integrated into chat input controls</li>
|
|
248
|
+
<li>Preferences: Toggle available in management interface</li>
|
|
249
|
+
</ul>
|
|
250
|
+
<hr>
|
|
251
|
+
<a id="md:⚙️-angular-integration-experimental" class="tsd-anchor"></a><h2 class="tsd-anchor-link">⚙️ Angular Integration (Experimental)<a href="#md:⚙️-angular-integration-experimental" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>To use Bandit Engine in an Angular project:</p>
|
|
252
|
+
<ol>
|
|
253
|
+
<li>Install the package:</li>
|
|
254
|
+
</ol>
|
|
255
|
+
<pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-2">@burtson-labs/bandit-engine</span>
|
|
256
|
+
</code><button type="button">Copy</button></pre>
|
|
257
|
+
|
|
258
|
+
<ol start="2">
|
|
259
|
+
<li><strong>Usage:</strong></li>
|
|
260
|
+
</ol>
|
|
261
|
+
<pre><code class="ts"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">Chat</span><span class="hl-1">, </span><span class="hl-5">Management</span><span class="hl-1">, </span><span class="hl-5">ChatModal</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">defineCustomElement</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-chat'</span><span class="hl-1">, </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-5">Chat</span><span class="hl-1">));</span><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-management'</span><span class="hl-1">, </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-5">Management</span><span class="hl-1">));</span><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-modal'</span><span class="hl-1">, </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-5">ChatModal</span><span class="hl-1">));</span>
|
|
262
|
+
</code><button type="button">Copy</button></pre>
|
|
263
|
+
|
|
264
|
+
<p>These components can now be used in your templates inside a <code><bandit-chat-provider></code> block.</p>
|
|
265
|
+
<p>Usage in HTML:</p>
|
|
266
|
+
<pre><code class="html"><span class="hl-9"><</span><span class="hl-13">bandit-chat-provider</span><br/><span class="hl-1"> </span><span class="hl-11">packageSettings</span><span class="hl-1">=</span><span class="hl-16">'{"ollamaUrl":"https://your-ollama-url.com","defaultModel":"Bandit-Core","brandingConfigUrl":"https://cdn.burtson.ai/configs/default-config.json"}'</span><br/><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">bandit-chat</span><span class="hl-9">></</span><span class="hl-13">bandit-chat</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">bandit-management</span><span class="hl-9">></</span><span class="hl-13">bandit-management</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">bandit-modal</span><span class="hl-9">></</span><span class="hl-13">bandit-modal</span><span class="hl-9">></span><br/><span class="hl-9"></</span><span class="hl-13">bandit-chat-provider</span><span class="hl-9">></span>
|
|
267
|
+
</code><button type="button">Copy</button></pre>
|
|
268
|
+
|
|
269
|
+
<p>Note: You only need to define the elements you intend to use. Don't mount all components on the same page. Use <code><bandit-management></code> for secure admin routes and <code><bandit-modal></code> for contextual triggers.</p>
|
|
270
|
+
<hr>
|
|
271
|
+
<a id="md:⚙️-vuejs-integration-experimental" class="tsd-anchor"></a><h2 class="tsd-anchor-link">⚙️ Vue.js Integration (Experimental)<a href="#md:⚙️-vuejs-integration-experimental" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>To use Bandit Engine in a Vue 3 project:</p>
|
|
272
|
+
<ol>
|
|
273
|
+
<li>Install the package:</li>
|
|
274
|
+
</ol>
|
|
275
|
+
<pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-2">@burtson-labs/bandit-engine</span>
|
|
276
|
+
</code><button type="button">Copy</button></pre>
|
|
277
|
+
|
|
278
|
+
<ol start="2">
|
|
279
|
+
<li><strong>Usage:</strong></li>
|
|
280
|
+
</ol>
|
|
281
|
+
<pre><code class="ts"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">Chat</span><span class="hl-1">, </span><span class="hl-5">Management</span><span class="hl-1">, </span><span class="hl-5">ChatModal</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">defineCustomElement</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-chat'</span><span class="hl-1">, </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-5">Chat</span><span class="hl-1">));</span><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-management'</span><span class="hl-1">, </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-5">Management</span><span class="hl-1">));</span><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-modal'</span><span class="hl-1">, </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-5">ChatModal</span><span class="hl-1">));</span>
|
|
282
|
+
</code><button type="button">Copy</button></pre>
|
|
283
|
+
|
|
284
|
+
<p>These components can now be used in your templates inside a <code><bandit-chat-provider></code> block.</p>
|
|
285
|
+
<p>Usage in HTML:</p>
|
|
286
|
+
<pre><code class="html"><span class="hl-9"><</span><span class="hl-13">bandit-chat-provider</span><br/><span class="hl-1"> </span><span class="hl-11">packageSettings</span><span class="hl-1">=</span><span class="hl-16">'{"ollamaUrl":"https://your-ollama-url.com","defaultModel":"Bandit-Core","brandingConfigUrl":"https://cdn.burtson.ai/configs/default-config.json"}'</span><br/><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">bandit-chat</span><span class="hl-9">></</span><span class="hl-13">bandit-chat</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">bandit-management</span><span class="hl-9">></</span><span class="hl-13">bandit-management</span><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-13">bandit-modal</span><span class="hl-9">></</span><span class="hl-13">bandit-modal</span><span class="hl-9">></span><br/><span class="hl-9"></</span><span class="hl-13">bandit-chat-provider</span><span class="hl-9">></span>
|
|
287
|
+
</code><button type="button">Copy</button></pre>
|
|
288
|
+
|
|
289
|
+
<p>Note: You only need to define the elements you intend to use. Don't mount all components on the same page. Use <code><bandit-management></code> for secure admin routes and <code><bandit-modal></code> for contextual triggers.</p>
|
|
290
|
+
<blockquote>
|
|
291
|
+
<p><code>defineCustomElement</code> allows usage in Vue and Angular apps via native Web Components, making Bandit fully framework-agnostic.</p>
|
|
292
|
+
</blockquote>
|
|
293
|
+
<blockquote>
|
|
294
|
+
<p>🔄 Similar to Angular, when using <code><Management /></code> or <code><ChatModal /></code>, wrap each one with a <code><bandit-chat-provider></code> to ensure proper context injection.</p>
|
|
295
|
+
</blockquote>
|
|
296
|
+
<blockquote>
|
|
297
|
+
<p>Make sure <code>packageSettings</code> is passed as a serialized JSON string when using with HTML-based custom elements.</p>
|
|
298
|
+
</blockquote>
|
|
299
|
+
<blockquote>
|
|
300
|
+
<p>Note: Ensure React and ReactDOM are correctly bundled and available to your Vue project. You may need additional tooling or wrappers to handle lifecycle and rendering behavior between frameworks. Full Vue support is on our roadmap.</p>
|
|
301
|
+
</blockquote>
|
|
302
|
+
<hr>
|
|
303
|
+
<a id="md:📦-custom-element-support" class="tsd-anchor"></a><h2 class="tsd-anchor-link">📦 Custom Element Support<a href="#md:📦-custom-element-support" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>To use Bandit components (<code>Chat</code>, <code>Management</code>, <code>ChatModal</code>) in any modern JS framework (Angular, Vue, Svelte, etc.), you can register them as native custom elements:</p>
|
|
304
|
+
<pre><code class="ts"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">defineCustomElement</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">BanditModal</span><span class="hl-1"> = </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-2">'ChatModal'</span><span class="hl-1">);</span><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-modal'</span><span class="hl-1">, </span><span class="hl-5">BanditModal</span><span class="hl-1">);</span>
|
|
305
|
+
</code><button type="button">Copy</button></pre>
|
|
306
|
+
|
|
307
|
+
<p>Wrap it in <code><bandit-chat-provider></code> and you’re ready to go. Ideal for environments where React isn’t used directly.</p>
|
|
308
|
+
<blockquote>
|
|
309
|
+
<p>🧠 <strong>Note for Non-React Users:</strong><br>
|
|
310
|
+
When using Bandit components as custom elements (e.g., in Angular, Vue, or static HTML), make sure the compiled custom elements script is loaded before usage. You can do this by importing or referencing it in your HTML or entry file. This ensures the custom elements are defined before being rendered.</p>
|
|
311
|
+
</blockquote>
|
|
312
|
+
<p>To create custom elements, you must import the React components and pass them to <code>defineCustomElement</code>. For example:</p>
|
|
313
|
+
<pre><code class="ts"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">ChatModal</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">defineCustomElement</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><span class="hl-5">customElements</span><span class="hl-1">.</span><span class="hl-0">define</span><span class="hl-1">(</span><span class="hl-2">'bandit-modal'</span><span class="hl-1">, </span><span class="hl-0">defineCustomElement</span><span class="hl-1">(</span><span class="hl-5">ChatModal</span><span class="hl-1">));</span>
|
|
314
|
+
</code><button type="button">Copy</button></pre>
|
|
315
|
+
|
|
316
|
+
<hr>
|
|
317
|
+
<a id="md:📸-live-preview" class="tsd-anchor"></a><h2 class="tsd-anchor-link">📸 Live Preview<a href="#md:📸-live-preview" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Here are some screenshots of Bandit Chat in action:</p>
|
|
318
|
+
<p><strong>Chat Demo – Your AI-powered UI</strong></p>
|
|
319
|
+
<p align="center">
|
|
320
|
+
<img src="./public/images/chat-demo.jpg" alt="Bandit chat session showing multi-turn conversation with inline actions" width="600" />
|
|
321
|
+
</p>
|
|
322
|
+
<p><strong>Conversation Drawer & Project Context</strong></p>
|
|
323
|
+
<p align="center">
|
|
324
|
+
<img src="./public/images/chat-demo-2.jpg" alt="Chat drawer open with projects list and answered question" width="600" />
|
|
325
|
+
</p>
|
|
326
|
+
<p><strong>Chat Modal – Quick Assist Anywhere</strong></p>
|
|
327
|
+
<p align="center">
|
|
328
|
+
<img src="./public/images/chat-modal.jpg" alt="Chat modal with control center options and message composer" width="600" />
|
|
329
|
+
</p>
|
|
330
|
+
<p><strong>Management – Branding Controls</strong></p>
|
|
331
|
+
<p align="center">
|
|
332
|
+
<img src="./public/images/mgmt-branding.jpg" alt="Management interface branding tab showing logo and color options" width="600" />
|
|
333
|
+
</p>
|
|
334
|
+
<p><strong>Management – Personas</strong></p>
|
|
335
|
+
<p align="center">
|
|
336
|
+
<img src="./public/images/mgmt-personalities.jpg" alt="Management interface personas tab with configurable AI personalities" width="600" />
|
|
337
|
+
</p>
|
|
338
|
+
<p><strong>Management – Preferences</strong></p>
|
|
339
|
+
<p align="center">
|
|
340
|
+
<img src="./public/images/mgmt-preferences.jpg" alt="Management interface preferences tab with feature toggles" width="600" />
|
|
341
|
+
</p>
|
|
342
|
+
<ol start="4">
|
|
343
|
+
<li><strong>🌐 CDN-Based Config (Optional)</strong></li>
|
|
344
|
+
</ol>
|
|
345
|
+
<p>To streamline configuration, you can host your <code>config.json</code> (and related assets like model presets or branding) via your own CDN or edge cache.</p>
|
|
346
|
+
<p>Update the <code>brandingConfigUrl</code> like this:</p>
|
|
347
|
+
<pre><code class="tsx"><span class="hl-9"><</span><span class="hl-10">ChatProvider</span><br/><span class="hl-1"> </span><span class="hl-11">packageSettings</span><span class="hl-1">=</span><span class="hl-6">{</span><span class="hl-14">{</span><br/><span class="hl-14"> </span><span class="hl-1">...</span><span class="hl-5">chatPackageSettings</span><span class="hl-14">,</span><br/><span class="hl-14"> </span><span class="hl-5">brandingConfigUrl:</span><span class="hl-14"> </span><span class="hl-2">"https://cdn.burtson.ai/configs/default-config.json"</span><br/><span class="hl-14"> }</span><span class="hl-6">}</span><br/><span class="hl-9">></span><br/><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">App</span><span class="hl-1"> </span><span class="hl-9">/></span><br/><span class="hl-9"></</span><span class="hl-10">ChatProvider</span><span class="hl-9">></span>
|
|
348
|
+
</code><button type="button">Copy</button></pre>
|
|
349
|
+
|
|
350
|
+
<p>This enables remote control of Bandit appearance, available models, and more — without redeploying your frontend.</p>
|
|
351
|
+
<blockquote>
|
|
352
|
+
<p>ℹ️ Note: All CDN assets such as logos, avatars, config, and workers are available at <code>https://cdn.burtson.ai/</code>. You may override these by hosting your own versions and pointing <code>packageSettings</code> to the appropriate URLs.</p>
|
|
353
|
+
</blockquote>
|
|
354
|
+
<hr>
|
|
355
|
+
<a id="md:⚙️-configuration-options" class="tsd-anchor"></a><h2 class="tsd-anchor-link">⚙️ Configuration Options<a href="#md:⚙️-configuration-options" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><ul>
|
|
356
|
+
<li><code>defaultModel</code>: Primary chat model (string; required)</li>
|
|
357
|
+
<li><code>fallbackModel</code>: Optional fallback model if the default is unavailable</li>
|
|
358
|
+
<li><code>gatewayApiUrl</code>: Gateway API base URL for AI, TTS, STT, and MCP</li>
|
|
359
|
+
<li><code>aiProvider</code>: Provider configuration object (recommended for new installs)</li>
|
|
360
|
+
<li><code>ollamaUrl</code>: Legacy Ollama base URL (deprecated, prefer <code>aiProvider</code>)</li>
|
|
361
|
+
<li><code>s3ApiUrl</code>: Optional file storage API base URL (defaults to <code>gatewayApiUrl</code>)</li>
|
|
362
|
+
<li><code>brandingConfigUrl</code>: Hosted branding JSON used to hydrate UI theming</li>
|
|
363
|
+
<li><code>homeUrl</code>: Optional URL for the home button in management UI</li>
|
|
364
|
+
<li><code>feedbackEmail</code>: Optional email address for feedback submissions</li>
|
|
365
|
+
<li><code>featureFlags</code>: Optional feature flag configuration (see examples below)</li>
|
|
366
|
+
</ul>
|
|
367
|
+
<a id="md:🤖-ai-provider-system" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🤖 AI Provider System<a href="#md:🤖-ai-provider-system" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Bandit Engine features a unified, gateway-based AI provider architecture that supports multiple AI services through a secure backend:</p>
|
|
368
|
+
<a id="md:supported-providers" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Supported Providers<a href="#md:supported-providers" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
369
|
+
<li><strong>🌟 Gateway Provider</strong> (Recommended): Routes all requests through your secure .NET 9 backend</li>
|
|
370
|
+
<li><strong>Ollama</strong>: Self-hosted models and Ollama-compatible endpoints</li>
|
|
371
|
+
<li><strong>OpenAI</strong>: GPT models via OpenAI API</li>
|
|
372
|
+
<li><strong>Azure OpenAI</strong>: Azure-hosted OpenAI models</li>
|
|
373
|
+
<li><strong>Anthropic</strong>: Claude models via Anthropic API</li>
|
|
374
|
+
</ul>
|
|
375
|
+
<a id="md:gateway-provider-recommended" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Gateway Provider (Recommended)<a href="#md:gateway-provider-recommended" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The gateway provider offers the most secure and scalable approach by routing all requests through your backend API:</p>
|
|
376
|
+
<pre><code class="tsx"><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">chatPackageSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-8">// Gateway provider configuration</span><br/><span class="hl-1"> </span><span class="hl-5">aiProvider:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-5">type:</span><span class="hl-1"> </span><span class="hl-2">"gateway"</span><span class="hl-1"> </span><span class="hl-4">as</span><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">gatewayUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-gateway-api.example.com"</span><span class="hl-1">, </span><br/><span class="hl-1"> </span><span class="hl-5">provider:</span><span class="hl-1"> </span><span class="hl-2">"openai"</span><span class="hl-1"> </span><span class="hl-8">// Backend provider: openai, azure-openai, anthropic, ollama</span><br/><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-8">// ... other settings</span><br/><span class="hl-1">};</span>
|
|
377
|
+
</code><button type="button">Copy</button></pre>
|
|
378
|
+
|
|
379
|
+
<p><strong>Benefits:</strong></p>
|
|
380
|
+
<ul>
|
|
381
|
+
<li>🔒 <strong>Security</strong>: API keys stay on your server</li>
|
|
382
|
+
<li>📊 <strong>Monitoring</strong>: Request logging and usage analytics</li>
|
|
383
|
+
<li>🚦 <strong>Rate Limiting</strong>: Built-in throttling and quotas</li>
|
|
384
|
+
<li>🔄 <strong>Provider Switching</strong>: Change backends without frontend updates</li>
|
|
385
|
+
<li>🛡️ <strong>Authentication</strong>: Unified auth across all AI services</li>
|
|
386
|
+
</ul>
|
|
387
|
+
<p><strong>Gateway Requirements:</strong>
|
|
388
|
+
Your gateway API can be built with any technology (Node.js, Python, .NET, Java, etc.) as long as it implements:</p>
|
|
389
|
+
<ul>
|
|
390
|
+
<li><code>GET /api/health</code> - Health check endpoint</li>
|
|
391
|
+
<li><code>POST /api/chat/completions</code> - Chat completions with provider in request body</li>
|
|
392
|
+
<li><code>POST /api/generate</code> - Text generation with provider in request body</li>
|
|
393
|
+
</ul>
|
|
394
|
+
<a id="md:legacy-direct-providers" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Legacy Direct Providers<a href="#md:legacy-direct-providers" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Direct providers are still supported but marked as deprecated for production use:</p>
|
|
395
|
+
<pre><code class="tsx"><span class="hl-8">// ⚠️ Deprecated: Direct OpenAI (exposes API keys)</span><br/><span class="hl-12">aiProvider</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-12">type</span><span class="hl-1">: </span><span class="hl-2">"openai"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-12">apiKey</span><span class="hl-1">: </span><span class="hl-2">"sk-..."</span><span class="hl-1">, </span><span class="hl-8">// Exposed in frontend</span><br/><span class="hl-1"> </span><span class="hl-12">baseUrl</span><span class="hl-1">: </span><span class="hl-2">"https://api.openai.com/v1"</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-8">// ⚠️ Deprecated: Direct Ollama (no auth/monitoring) </span><br/><span class="hl-12">aiProvider</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-12">type</span><span class="hl-1">: </span><span class="hl-2">"ollama"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-12">baseUrl</span><span class="hl-1">: </span><span class="hl-2">"http://localhost:11434"</span><br/><span class="hl-1">}</span>
|
|
396
|
+
</code><button type="button">Copy</button></pre>
|
|
397
|
+
|
|
398
|
+
<a id="md:migration-to-gateway" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Migration to Gateway<a href="#md:migration-to-gateway" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ol>
|
|
399
|
+
<li><strong>Deploy Gateway Backend</strong>: Set up your .NET 9 gateway service</li>
|
|
400
|
+
<li><strong>Update Configuration</strong>: Switch from direct to gateway provider</li>
|
|
401
|
+
<li><strong>Test Connection</strong>: Use the Management interface to validate</li>
|
|
402
|
+
<li><strong>Update API Keys</strong>: Move keys from frontend to backend config</li>
|
|
403
|
+
</ol>
|
|
404
|
+
<p>See <code>GATEWAY_MIGRATION_GUIDE.md</code> for detailed migration steps.</p>
|
|
405
|
+
<a id="md:imagemultimodal-support" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Image/Multimodal Support<a href="#md:imagemultimodal-support" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The Bandit Engine provides comprehensive image support across all AI providers through the gateway architecture:</p>
|
|
406
|
+
<p><strong>Supported Providers & Models:</strong></p>
|
|
407
|
+
<ul>
|
|
408
|
+
<li><strong>Ollama</strong>: <code>llava</code>, <code>llava:13b</code>, <code>bakllava</code>, <code>llava-phi3</code></li>
|
|
409
|
+
<li><strong>OpenAI</strong>: <code>gpt-4-vision-preview</code>, <code>gpt-4o</code>, <code>gpt-4o-mini</code></li>
|
|
410
|
+
<li><strong>Azure OpenAI</strong>: <code>gpt-4-vision-preview</code> (deployed models)</li>
|
|
411
|
+
<li><strong>Anthropic</strong>: <code>claude-3-opus</code>, <code>claude-3-sonnet</code>, <code>claude-3-haiku</code></li>
|
|
412
|
+
</ul>
|
|
413
|
+
<p><strong>Key Features:</strong></p>
|
|
414
|
+
<ul>
|
|
415
|
+
<li>🖼️ <strong>Universal Image Input</strong>: Drop, paste, or upload images directly in chat</li>
|
|
416
|
+
<li>🔄 <strong>Provider-Specific Formatting</strong>: Automatic conversion to each provider's image format</li>
|
|
417
|
+
<li>📱 <strong>Multi-Image Support</strong>: Send multiple images in a single message</li>
|
|
418
|
+
<li>🎯 <strong>Vision Models</strong>: Seamless integration with multimodal AI models</li>
|
|
419
|
+
</ul>
|
|
420
|
+
<p><strong>Usage Example:</strong></p>
|
|
421
|
+
<pre><code class="tsx"><span class="hl-8">// Images are automatically handled by the chat interface</span><br/><span class="hl-8">// Users can:</span><br/><span class="hl-8">// 1. Drag & drop images into the chat input</span><br/><span class="hl-8">// 2. Paste images from clipboard (Ctrl+V / Cmd+V) </span><br/><span class="hl-8">// 3. Use the attach button to select image files</span><br/><span class="hl-8">// 4. Ask questions about the images naturally</span><br/><br/><span class="hl-8">// The gateway provider automatically formats images correctly:</span><br/><span class="hl-8">// - Ollama: base64 arrays in message.images</span><br/><span class="hl-8">// - OpenAI/Azure/Anthropic: structured content with image_url objects</span>
|
|
422
|
+
</code><button type="button">Copy</button></pre>
|
|
423
|
+
|
|
424
|
+
<p><strong>Backend Requirements:</strong>
|
|
425
|
+
Your gateway API should accept images in the standardized format sent by the Bandit Engine and forward them appropriately to each provider. No transformation needed - the frontend handles provider-specific formatting.</p>
|
|
426
|
+
<pre><code class="javascript"><span class="hl-8">// Example: Gateway forwards images as-is to each provider</span><br/><span class="hl-5">app</span><span class="hl-1">.</span><span class="hl-0">post</span><span class="hl-1">(</span><span class="hl-2">'/api/chat/completions'</span><span class="hl-1">, </span><span class="hl-6">async</span><span class="hl-1"> (</span><span class="hl-5">req</span><span class="hl-1">, </span><span class="hl-5">res</span><span class="hl-1">) </span><span class="hl-6">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> { </span><span class="hl-7">provider</span><span class="hl-1">, </span><span class="hl-7">messages</span><span class="hl-1">, ...</span><span class="hl-7">options</span><span class="hl-1"> } = </span><span class="hl-5">req</span><span class="hl-1">.</span><span class="hl-5">body</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Messages already contain properly formatted images</span><br/><span class="hl-1"> </span><span class="hl-8">// Forward directly to the target provider API</span><br/><span class="hl-1"> </span><span class="hl-4">switch</span><span class="hl-1"> (</span><span class="hl-5">provider</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">case</span><span class="hl-1"> </span><span class="hl-2">'ollama'</span><span class="hl-1">:</span><br/><span class="hl-1"> </span><span class="hl-8">// messages[].images format (base64 arrays)</span><br/><span class="hl-1"> </span><span class="hl-4">return</span><span class="hl-1"> </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-5">ollamaClient</span><span class="hl-1">.</span><span class="hl-0">chat</span><span class="hl-1">({ </span><span class="hl-5">messages</span><span class="hl-1">, ...</span><span class="hl-5">options</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-4">case</span><span class="hl-1"> </span><span class="hl-2">'openai'</span><span class="hl-1">: </span><br/><span class="hl-1"> </span><span class="hl-8">// messages[].content[].image_url format (structured)</span><br/><span class="hl-1"> </span><span class="hl-4">return</span><span class="hl-1"> </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-5">openaiClient</span><span class="hl-1">.</span><span class="hl-5">chat</span><span class="hl-1">.</span><span class="hl-5">completions</span><span class="hl-1">.</span><span class="hl-0">create</span><span class="hl-1">({ </span><span class="hl-5">messages</span><span class="hl-1">, ...</span><span class="hl-5">options</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-4">default</span><span class="hl-1">:</span><br/><span class="hl-1"> </span><span class="hl-4">throw</span><span class="hl-1"> </span><span class="hl-6">new</span><span class="hl-1"> </span><span class="hl-0">Error</span><span class="hl-1">(</span><span class="hl-2">`Unsupported provider: </span><span class="hl-6">${</span><span class="hl-5">provider</span><span class="hl-6">}</span><span class="hl-2">`</span><span class="hl-1">);</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span>
|
|
427
|
+
</code><button type="button">Copy</button></pre>
|
|
428
|
+
|
|
429
|
+
<a id="md:using-the-ai-provider" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Using the AI Provider<a href="#md:using-the-ai-provider" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>All chat interactions use the unified provider system regardless of backend:</p>
|
|
430
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">useAIProvider</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-6">function</span><span class="hl-1"> </span><span class="hl-0">MyComponent</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> { </span><span class="hl-7">generateResponse</span><span class="hl-1">, </span><span class="hl-7">isLoading</span><span class="hl-1"> } = </span><span class="hl-0">useAIProvider</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-0">handleChat</span><span class="hl-1"> = </span><span class="hl-6">async</span><span class="hl-1"> (</span><span class="hl-5">message</span><span class="hl-1">: </span><span class="hl-10">string</span><span class="hl-1">) </span><span class="hl-6">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">response</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">generateResponse</span><span class="hl-1">(</span><span class="hl-5">message</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-5">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-5">response</span><span class="hl-1">);</span><br/><span class="hl-1"> };</span><br/><span class="hl-1">}</span>
|
|
431
|
+
</code><button type="button">Copy</button></pre>
|
|
432
|
+
|
|
433
|
+
<a id="md:🔧-model-context-protocol-mcp-integration" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🔧 Model Context Protocol (MCP) Integration<a href="#md:🔧-model-context-protocol-mcp-integration" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Bandit Engine now supports <strong>Model Context Protocol (MCP)</strong> for extending AI capabilities with external tools and services:</p>
|
|
434
|
+
<a id="md:mcp-features" class="tsd-anchor"></a><h3 class="tsd-anchor-link">MCP Features<a href="#md:mcp-features" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
435
|
+
<li><strong>Tool Integration</strong>: Connect external APIs and services to your AI conversations</li>
|
|
436
|
+
<li><strong>Dynamic Tool Discovery</strong>: Automatically detect and configure available MCP tools</li>
|
|
437
|
+
<li><strong>Secure Execution</strong>: All MCP tool calls go through your gateway API with proper authentication</li>
|
|
438
|
+
<li><strong>Real-time Updates</strong>: Tools can be enabled/disabled without restarting the application</li>
|
|
439
|
+
</ul>
|
|
440
|
+
<a id="md:using-mcp-tools" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Using MCP Tools<a href="#md:using-mcp-tools" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>MCP tools are automatically available in chat conversations when configured:</p>
|
|
441
|
+
<pre><code class="tsx"><span class="hl-8">// MCP tools are managed through the store</span><br/><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">useMCPToolsStore</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-6">function</span><span class="hl-1"> </span><span class="hl-0">MCPManager</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> { </span><span class="hl-7">tools</span><span class="hl-1">, </span><span class="hl-7">toggleTool</span><span class="hl-1">, </span><span class="hl-7">getEnabledTools</span><span class="hl-1"> } = </span><span class="hl-0">useMCPToolsStore</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Enable/disable tools</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-0">handleToggle</span><span class="hl-1"> = (</span><span class="hl-5">toolId</span><span class="hl-1">: </span><span class="hl-10">string</span><span class="hl-1">) </span><span class="hl-6">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">toggleTool</span><span class="hl-1">(</span><span class="hl-5">toolId</span><span class="hl-1">);</span><br/><span class="hl-1"> };</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Get currently enabled tools</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">enabledTools</span><span class="hl-1"> = </span><span class="hl-0">getEnabledTools</span><span class="hl-1">();</span><br/><span class="hl-1">}</span>
|
|
442
|
+
</code><button type="button">Copy</button></pre>
|
|
443
|
+
|
|
444
|
+
<a id="md:mcp-tool-configuration" class="tsd-anchor"></a><h3 class="tsd-anchor-link">MCP Tool Configuration<a href="#md:mcp-tool-configuration" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Tools are configured through your gateway API and automatically discovered by the engine:</p>
|
|
445
|
+
<pre><code class="json"><span class="hl-1">{</span><br/><span class="hl-1"> </span><span class="hl-3">"function"</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-3">"name"</span><span class="hl-1">: </span><span class="hl-2">"search_web"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"description"</span><span class="hl-1">: </span><span class="hl-2">"Search the web for current information"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"parameters"</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-3">"type"</span><span class="hl-1">: </span><span class="hl-2">"object"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"properties"</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-3">"query"</span><span class="hl-1">: {</span><br/><span class="hl-1"> </span><span class="hl-3">"type"</span><span class="hl-1">: </span><span class="hl-2">"string"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"description"</span><span class="hl-1">: </span><span class="hl-2">"Search query"</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-3">"endpoint"</span><span class="hl-1">: </span><span class="hl-2">"/mcp/search"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"method"</span><span class="hl-1">: </span><span class="hl-2">"POST"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"enabled"</span><span class="hl-1">: </span><span class="hl-6">true</span><br/><span class="hl-1">}</span>
|
|
446
|
+
</code><button type="button">Copy</button></pre>
|
|
447
|
+
|
|
448
|
+
<a id="md:mcp-service-api" class="tsd-anchor"></a><h3 class="tsd-anchor-link">MCP Service API<a href="#md:mcp-service-api" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>For advanced usage, you can directly execute MCP tools:</p>
|
|
449
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">executeMCPTool</span><span class="hl-1">, </span><span class="hl-5">isMCPAvailable</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">// Check if MCP is available</span><br/><span class="hl-4">if</span><span class="hl-1"> (</span><span class="hl-0">isMCPAvailable</span><span class="hl-1">()) {</span><br/><span class="hl-1"> </span><span class="hl-8">// Execute a tool</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">result</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">executeMCPTool</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-5">toolName:</span><span class="hl-1"> </span><span class="hl-2">"search_web"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">parameters:</span><span class="hl-1"> { </span><span class="hl-5">query:</span><span class="hl-1"> </span><span class="hl-2">"latest AI news"</span><span class="hl-1"> }</span><br/><span class="hl-1"> });</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-4">if</span><span class="hl-1"> (</span><span class="hl-5">result</span><span class="hl-1">.</span><span class="hl-5">success</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-5">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-5">result</span><span class="hl-1">.</span><span class="hl-5">data</span><span class="hl-1">);</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">}</span>
|
|
450
|
+
</code><button type="button">Copy</button></pre>
|
|
451
|
+
|
|
452
|
+
<hr>
|
|
453
|
+
<a id="md:🎛️-feature-flags--subscription-tiers" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🎛️ Feature Flags & Subscription Tiers<a href="#md:🎛️-feature-flags--subscription-tiers" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Bandit Engine includes a comprehensive <strong>tier-based feature flag system</strong> that enables subscription-based access control and feature gating:</p>
|
|
454
|
+
<a id="md:subscription-tiers" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Subscription Tiers<a href="#md:subscription-tiers" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The engine supports multiple subscription tiers with different feature access levels:</p>
|
|
455
|
+
<ul>
|
|
456
|
+
<li><strong>Basic</strong>: Core chat functionality with limitations</li>
|
|
457
|
+
<li><strong>Premium</strong>: Enhanced features and higher limits</li>
|
|
458
|
+
<li><strong>Pro</strong>: Advanced features for power users</li>
|
|
459
|
+
<li><strong>Team</strong>: Collaboration features and team management</li>
|
|
460
|
+
<li><strong>Trial</strong>: Temporary access with premium features</li>
|
|
461
|
+
<li><strong>Expired</strong>: Limited access for expired subscriptions</li>
|
|
462
|
+
</ul>
|
|
463
|
+
<a id="md:feature-flag-configuration" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Feature Flag Configuration<a href="#md:feature-flag-configuration" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Configure feature flags in your package settings:</p>
|
|
464
|
+
<pre><code class="tsx"><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">chatPackageSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-8">// ... other settings</span><br/><span class="hl-1"> </span><span class="hl-5">featureFlags:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-8">// Default tier (fallback when no JWT subscription info available)</span><br/><span class="hl-1"> </span><span class="hl-5">subscriptionType:</span><span class="hl-1"> </span><span class="hl-2">"premium"</span><span class="hl-1">, </span><span class="hl-8">// basic | premium | pro | team | trial</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// JWT claim configuration for authentication</span><br/><span class="hl-1"> </span><span class="hl-5">rolesClaimKey:</span><span class="hl-1"> </span><span class="hl-2">"roles"</span><span class="hl-1">, </span><span class="hl-8">// JWT claim key for user roles</span><br/><span class="hl-1"> </span><span class="hl-5">subscriptionTypeClaimKey:</span><span class="hl-1"> </span><span class="hl-2">"subscriptionType"</span><span class="hl-1">, </span><span class="hl-8">// JWT claim for subscription type</span><br/><span class="hl-1"> </span><span class="hl-5">isSubscribedClaimKey:</span><span class="hl-1"> </span><span class="hl-2">"isSubscribed"</span><span class="hl-1">, </span><span class="hl-8">// JWT claim for subscription status</span><br/><span class="hl-1"> </span><span class="hl-5">jwtStorageKey:</span><span class="hl-1"> </span><span class="hl-2">"authToken"</span><span class="hl-1">, </span><span class="hl-8">// Local storage key for JWT token</span><br/><span class="hl-1"> </span><span class="hl-5">adminRole:</span><span class="hl-1"> </span><span class="hl-2">"admin"</span><span class="hl-1">, </span><span class="hl-8">// Admin role name for elevated access</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Development settings</span><br/><span class="hl-1"> </span><span class="hl-5">debug:</span><span class="hl-1"> </span><span class="hl-5">process</span><span class="hl-1">.</span><span class="hl-5">env</span><span class="hl-1">.</span><span class="hl-7">NODE_ENV</span><span class="hl-1"> === </span><span class="hl-2">"development"</span><span class="hl-1">, </span><span class="hl-8">// Enable debug logging</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Optional: Override specific features</span><br/><span class="hl-1"> </span><span class="hl-5">featureMatrix:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-5">tts:</span><span class="hl-1"> </span><span class="hl-6">true</span><span class="hl-1">, </span><span class="hl-8">// Enable/disable Text-to-Speech</span><br/><span class="hl-1"> </span><span class="hl-5">stt:</span><span class="hl-1"> </span><span class="hl-6">true</span><span class="hl-1">, </span><span class="hl-8">// Enable/disable Speech-to-Text</span><br/><span class="hl-1"> </span><span class="hl-8">// ... other feature overrides</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">};</span>
|
|
465
|
+
</code><button type="button">Copy</button></pre>
|
|
466
|
+
|
|
467
|
+
<a id="md:tier-based-feature-matrix" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Tier-Based Feature Matrix<a href="#md:tier-based-feature-matrix" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Different subscription tiers have access to different features:</p>
|
|
468
|
+
<table>
|
|
469
|
+
<thead>
|
|
470
|
+
<tr>
|
|
471
|
+
<th>Feature</th>
|
|
472
|
+
<th>Basic</th>
|
|
473
|
+
<th>Premium</th>
|
|
474
|
+
<th>Pro</th>
|
|
475
|
+
<th>Team</th>
|
|
476
|
+
<th>Trial</th>
|
|
477
|
+
</tr>
|
|
478
|
+
</thead>
|
|
479
|
+
<tbody>
|
|
480
|
+
<tr>
|
|
481
|
+
<td><strong>Core Chat</strong></td>
|
|
482
|
+
<td>✅</td>
|
|
483
|
+
<td>✅</td>
|
|
484
|
+
<td>✅</td>
|
|
485
|
+
<td>✅</td>
|
|
486
|
+
<td>✅</td>
|
|
487
|
+
</tr>
|
|
488
|
+
<tr>
|
|
489
|
+
<td><strong>Text-to-Speech</strong></td>
|
|
490
|
+
<td>❌</td>
|
|
491
|
+
<td>✅</td>
|
|
492
|
+
<td>✅</td>
|
|
493
|
+
<td>✅</td>
|
|
494
|
+
<td>✅</td>
|
|
495
|
+
</tr>
|
|
496
|
+
<tr>
|
|
497
|
+
<td><strong>Speech-to-Text</strong></td>
|
|
498
|
+
<td>❌</td>
|
|
499
|
+
<td>✅</td>
|
|
500
|
+
<td>✅</td>
|
|
501
|
+
<td>✅</td>
|
|
502
|
+
<td>✅</td>
|
|
503
|
+
</tr>
|
|
504
|
+
<tr>
|
|
505
|
+
<td><strong>Document Upload</strong></td>
|
|
506
|
+
<td>❌</td>
|
|
507
|
+
<td>✅</td>
|
|
508
|
+
<td>✅</td>
|
|
509
|
+
<td>✅</td>
|
|
510
|
+
<td>✅</td>
|
|
511
|
+
</tr>
|
|
512
|
+
<tr>
|
|
513
|
+
<td><strong>Model Management</strong></td>
|
|
514
|
+
<td>❌</td>
|
|
515
|
+
<td>❌</td>
|
|
516
|
+
<td>✅</td>
|
|
517
|
+
<td>✅</td>
|
|
518
|
+
<td>❌</td>
|
|
519
|
+
</tr>
|
|
520
|
+
<tr>
|
|
521
|
+
<td><strong>Admin Dashboard</strong></td>
|
|
522
|
+
<td>❌</td>
|
|
523
|
+
<td>❌</td>
|
|
524
|
+
<td>✅</td>
|
|
525
|
+
<td>✅</td>
|
|
526
|
+
<td>❌</td>
|
|
527
|
+
</tr>
|
|
528
|
+
<tr>
|
|
529
|
+
<td><strong>API Access</strong></td>
|
|
530
|
+
<td>❌</td>
|
|
531
|
+
<td>❌</td>
|
|
532
|
+
<td>✅</td>
|
|
533
|
+
<td>✅</td>
|
|
534
|
+
<td>❌</td>
|
|
535
|
+
</tr>
|
|
536
|
+
<tr>
|
|
537
|
+
<td><strong>Team Collaboration</strong></td>
|
|
538
|
+
<td>❌</td>
|
|
539
|
+
<td>❌</td>
|
|
540
|
+
<td>❌</td>
|
|
541
|
+
<td>✅</td>
|
|
542
|
+
<td>❌</td>
|
|
543
|
+
</tr>
|
|
544
|
+
<tr>
|
|
545
|
+
<td><strong>Custom Branding</strong></td>
|
|
546
|
+
<td>❌</td>
|
|
547
|
+
<td>❌</td>
|
|
548
|
+
<td>❌</td>
|
|
549
|
+
<td>✅</td>
|
|
550
|
+
<td>❌</td>
|
|
551
|
+
</tr>
|
|
552
|
+
</tbody>
|
|
553
|
+
</table>
|
|
554
|
+
<a id="md:jwt-based-authentication" class="tsd-anchor"></a><h3 class="tsd-anchor-link">JWT-Based Authentication<a href="#md:jwt-based-authentication" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The feature flag system integrates with JWT tokens for dynamic subscription management:</p>
|
|
555
|
+
<pre><code class="tsx"><span class="hl-8">// Example JWT payload structure</span><br/><span class="hl-1">{</span><br/><span class="hl-1"> </span><span class="hl-2">"sub"</span><span class="hl-1">: </span><span class="hl-2">"user123"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-2">"subscriptionType"</span><span class="hl-1">: </span><span class="hl-2">"pro"</span><span class="hl-1">, </span><span class="hl-8">// Controls tier access</span><br/><span class="hl-1"> </span><span class="hl-2">"isSubscribed"</span><span class="hl-1">: </span><span class="hl-6">true</span><span class="hl-1">, </span><span class="hl-8">// Overall subscription status</span><br/><span class="hl-1"> </span><span class="hl-2">"roles"</span><span class="hl-1">: [</span><span class="hl-2">"user"</span><span class="hl-1">, </span><span class="hl-2">"admin"</span><span class="hl-1">], </span><span class="hl-8">// User roles for admin features</span><br/><span class="hl-1"> </span><span class="hl-2">"exp"</span><span class="hl-1">: </span><span class="hl-15">1640995200</span><br/><span class="hl-1">}</span>
|
|
556
|
+
</code><button type="button">Copy</button></pre>
|
|
557
|
+
|
|
558
|
+
<a id="md:using-feature-flags-in-components" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Using Feature Flags in Components<a href="#md:using-feature-flags-in-components" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Access feature flags throughout your application:</p>
|
|
559
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">useFeatureFlags</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-6">function</span><span class="hl-1"> </span><span class="hl-0">MyComponent</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> { </span><br/><span class="hl-1"> </span><span class="hl-7">hasFeature</span><span class="hl-1">, </span><br/><span class="hl-1"> </span><span class="hl-7">currentTier</span><span class="hl-1">, </span><br/><span class="hl-1"> </span><span class="hl-7">isAdmin</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-7">isSubscribed</span><span class="hl-1"> </span><br/><span class="hl-1"> } = </span><span class="hl-0">useFeatureFlags</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Check specific features</span><br/><span class="hl-1"> </span><span class="hl-4">if</span><span class="hl-1"> (</span><span class="hl-0">hasFeature</span><span class="hl-1">(</span><span class="hl-2">'tts'</span><span class="hl-1">)) {</span><br/><span class="hl-1"> </span><span class="hl-8">// Show text-to-speech controls</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Check subscription tier</span><br/><span class="hl-1"> </span><span class="hl-4">if</span><span class="hl-1"> (</span><span class="hl-5">currentTier</span><span class="hl-1"> === </span><span class="hl-2">'pro'</span><span class="hl-1"> || </span><span class="hl-5">currentTier</span><span class="hl-1"> === </span><span class="hl-2">'team'</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-8">// Show advanced features</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Check admin access</span><br/><span class="hl-1"> </span><span class="hl-4">if</span><span class="hl-1"> (</span><span class="hl-5">isAdmin</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-8">// Show admin controls</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">}</span>
|
|
560
|
+
</code><button type="button">Copy</button></pre>
|
|
561
|
+
|
|
562
|
+
<a id="md:subscription-state-management" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Subscription State Management<a href="#md:subscription-state-management" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The engine automatically handles subscription state changes:</p>
|
|
563
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">useAuthenticationStore</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-6">function</span><span class="hl-1"> </span><span class="hl-0">SubscriptionManager</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> { </span><br/><span class="hl-1"> </span><span class="hl-7">subscriptionType</span><span class="hl-1">, </span><br/><span class="hl-1"> </span><span class="hl-7">isSubscribed</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-7">refreshSubscription</span><span class="hl-1"> </span><br/><span class="hl-1"> } = </span><span class="hl-0">useAuthenticationStore</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Handle subscription upgrades</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-0">handleUpgrade</span><span class="hl-1"> = </span><span class="hl-6">async</span><span class="hl-1"> () </span><span class="hl-6">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-8">// After successful payment processing</span><br/><span class="hl-1"> </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">refreshSubscription</span><span class="hl-1">(); </span><span class="hl-8">// Reload JWT and feature access</span><br/><span class="hl-1"> };</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Display upgrade prompts for limited features</span><br/><span class="hl-1"> </span><span class="hl-4">if</span><span class="hl-1"> (!</span><span class="hl-5">isSubscribed</span><span class="hl-1"> && </span><span class="hl-5">attemptedRestrictedFeature</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">return</span><span class="hl-1"> </span><span class="hl-9"><</span><span class="hl-10">UpgradePrompt</span><span class="hl-1"> </span><span class="hl-9">/></span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">}</span>
|
|
564
|
+
</code><button type="button">Copy</button></pre>
|
|
565
|
+
|
|
566
|
+
<a id="md:feature-restrictions--upgrade-prompts" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Feature Restrictions & Upgrade Prompts<a href="#md:feature-restrictions--upgrade-prompts" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The engine automatically shows upgrade prompts when users try to access restricted features:</p>
|
|
567
|
+
<ul>
|
|
568
|
+
<li><strong>Graceful Degradation</strong>: Features are hidden or disabled based on subscription tier</li>
|
|
569
|
+
<li><strong>Upgrade Prompts</strong>: Users see contextual upgrade suggestions when attempting restricted actions</li>
|
|
570
|
+
<li><strong>Real-time Updates</strong>: Subscription changes take effect immediately without app restart</li>
|
|
571
|
+
</ul>
|
|
572
|
+
<a id="md:development--testing" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Development & Testing<a href="#md:development--testing" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>For development and testing environments:</p>
|
|
573
|
+
<pre><code class="tsx"><span class="hl-8">// Override subscription tier for testing</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">devSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-5">featureFlags:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-5">subscriptionType:</span><span class="hl-1"> </span><span class="hl-2">"team"</span><span class="hl-1">, </span><span class="hl-8">// Test with highest tier</span><br/><span class="hl-1"> </span><span class="hl-5">debug:</span><span class="hl-1"> </span><span class="hl-6">true</span><span class="hl-1">, </span><span class="hl-8">// Enable detailed logging</span><br/><span class="hl-1"> </span><span class="hl-5">featureMatrix:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-8">// Force enable specific features for testing</span><br/><span class="hl-1"> </span><span class="hl-5">experimentalFeature:</span><span class="hl-1"> </span><span class="hl-6">true</span><span class="hl-1">,</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">};</span>
|
|
574
|
+
</code><button type="button">Copy</button></pre>
|
|
575
|
+
|
|
576
|
+
<a id="md:backend-integration" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Backend Integration<a href="#md:backend-integration" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Your gateway API should validate subscription tiers and return appropriate feature access:</p>
|
|
577
|
+
<pre><code class="javascript"><span class="hl-8">// Example: Gateway API subscription validation</span><br/><span class="hl-5">app</span><span class="hl-1">.</span><span class="hl-0">post</span><span class="hl-1">(</span><span class="hl-2">'/api/chat/completions'</span><span class="hl-1">, </span><span class="hl-5">authenticateJWT</span><span class="hl-1">, </span><span class="hl-6">async</span><span class="hl-1"> (</span><span class="hl-5">req</span><span class="hl-1">, </span><span class="hl-5">res</span><span class="hl-1">) </span><span class="hl-6">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> { </span><span class="hl-7">subscriptionType</span><span class="hl-1">, </span><span class="hl-7">isSubscribed</span><span class="hl-1"> } = </span><span class="hl-5">req</span><span class="hl-1">.</span><span class="hl-5">user</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Validate tier access for requested features</span><br/><span class="hl-1"> </span><span class="hl-4">if</span><span class="hl-1"> (</span><span class="hl-5">req</span><span class="hl-1">.</span><span class="hl-5">body</span><span class="hl-1">.</span><span class="hl-5">tts</span><span class="hl-1"> && !</span><span class="hl-0">hasFeature</span><span class="hl-1">(</span><span class="hl-5">subscriptionType</span><span class="hl-1">, </span><span class="hl-2">'tts'</span><span class="hl-1">)) {</span><br/><span class="hl-1"> </span><span class="hl-4">return</span><span class="hl-1"> </span><span class="hl-5">res</span><span class="hl-1">.</span><span class="hl-0">status</span><span class="hl-1">(</span><span class="hl-15">403</span><span class="hl-1">).</span><span class="hl-0">json</span><span class="hl-1">({ </span><br/><span class="hl-1"> </span><span class="hl-5">error:</span><span class="hl-1"> </span><span class="hl-2">'TTS requires Premium subscription or higher'</span><span class="hl-1"> </span><br/><span class="hl-1"> });</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> </span><br/><span class="hl-1"> </span><span class="hl-8">// Proceed with AI request</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">response</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">processAIRequest</span><span class="hl-1">(</span><span class="hl-5">req</span><span class="hl-1">.</span><span class="hl-5">body</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-5">res</span><span class="hl-1">.</span><span class="hl-0">json</span><span class="hl-1">(</span><span class="hl-5">response</span><span class="hl-1">);</span><br/><span class="hl-1">});</span>
|
|
578
|
+
</code><button type="button">Copy</button></pre>
|
|
579
|
+
|
|
580
|
+
<p>This feature flag system enables you to build sophisticated subscription-based AI products with fine-grained access control and seamless upgrade flows.</p>
|
|
581
|
+
<hr>
|
|
582
|
+
<a id="md:🐛-debug-logger" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🐛 Debug Logger<a href="#md:🐛-debug-logger" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Bandit Engine exports a debug logger for consistent logging across your application:</p>
|
|
583
|
+
<pre><code class="tsx"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">debugLogger</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">'@burtson-labs/bandit-engine'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">// Use instead of console.log/warn/error</span><br/><span class="hl-5">debugLogger</span><span class="hl-1">.</span><span class="hl-0">info</span><span class="hl-1">(</span><span class="hl-2">'Chat message sent'</span><span class="hl-1">);</span><br/><span class="hl-5">debugLogger</span><span class="hl-1">.</span><span class="hl-0">warn</span><span class="hl-1">(</span><span class="hl-2">'Fallback model used'</span><span class="hl-1">);</span><br/><span class="hl-5">debugLogger</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">(</span><span class="hl-2">'Failed to connect to AI service'</span><span class="hl-1">);</span>
|
|
584
|
+
</code><button type="button">Copy</button></pre>
|
|
585
|
+
|
|
586
|
+
<a id="md:🔒-security-best-practices" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🔒 Security Best Practices<a href="#md:🔒-security-best-practices" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p><strong>⚠️ Important Security Notice:</strong></p>
|
|
587
|
+
<p>While Bandit Engine supports direct API key configuration for development and testing, <strong>we strongly recommend against using API keys directly in frontend applications</strong> for production environments.</p>
|
|
588
|
+
<a id="md:recommended-architecture" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Recommended Architecture<a href="#md:recommended-architecture" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ol>
|
|
589
|
+
<li><strong>Use an API Gateway/Wrapper</strong>: Deploy the OllamaGateway (soon to be renamed AiGateway) or similar backend service</li>
|
|
590
|
+
<li><strong>Proxy AI Requests</strong>: Route all AI requests through your secure backend</li>
|
|
591
|
+
<li><strong>Environment Isolation</strong>: Keep API keys and sensitive configuration on the server side</li>
|
|
592
|
+
<li><strong>Authentication</strong>: Implement proper user authentication and request validation</li>
|
|
593
|
+
</ol>
|
|
594
|
+
<a id="md:gateway-setup" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Gateway Setup<a href="#md:gateway-setup" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The recommended approach is to use a gateway service that:</p>
|
|
595
|
+
<ul>
|
|
596
|
+
<li>Handles API key management securely</li>
|
|
597
|
+
<li>Provides rate limiting and usage tracking</li>
|
|
598
|
+
<li>Exposes standardized endpoints for AI, TTS, and STT services</li>
|
|
599
|
+
<li>Manages provider switching and fallback logic</li>
|
|
600
|
+
<li><strong>Technology-agnostic</strong>: Works with any backend implementation</li>
|
|
601
|
+
</ul>
|
|
602
|
+
<pre><code class="tsx"><span class="hl-8">// Recommended: Use gateway with unified API</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">chatPackageSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-5">aiProvider:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-5">type:</span><span class="hl-1"> </span><span class="hl-2">"gateway"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">gatewayUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-api-gateway.com"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">provider:</span><span class="hl-1"> </span><span class="hl-2">"openai"</span><span class="hl-1"> </span><span class="hl-8">// or "anthropic", "azure-openai", "ollama"</span><br/><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-5">gatewayApiUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-api-gateway.com"</span><span class="hl-1">, </span><span class="hl-8">// Same URL for TTS/STT services</span><br/><span class="hl-1"> </span><span class="hl-8">// No API keys in frontend code</span><br/><span class="hl-1"> </span><span class="hl-8">// ... other settings</span><br/><span class="hl-1">};</span>
|
|
603
|
+
</code><button type="button">Copy</button></pre>
|
|
604
|
+
|
|
605
|
+
<a id="md:legacy-configuration-deprecated" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Legacy Configuration (Deprecated)<a href="#md:legacy-configuration-deprecated" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>⚠️ <strong>Legacy TTS/STT URLs are deprecated.</strong> Use the unified <code>gatewayApiUrl</code> instead:</p>
|
|
606
|
+
<pre><code class="tsx"><span class="hl-8">// ❌ Deprecated (still works but not recommended)</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">oldSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-5">ttsUrl:</span><span class="hl-1"> </span><span class="hl-2">"/api/tts"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">sttUrl:</span><span class="hl-1"> </span><span class="hl-2">"/api/stt"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">ollamaUrl:</span><span class="hl-1"> </span><span class="hl-2">"http://localhost:11434"</span><span class="hl-1">,</span><br/><span class="hl-1">};</span><br/><br/><span class="hl-8">// ✅ Recommended (unified gateway approach)</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">newSettings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-5">aiProvider:</span><span class="hl-1"> { </span><span class="hl-5">type:</span><span class="hl-1"> </span><span class="hl-2">"gateway"</span><span class="hl-1">, </span><span class="hl-5">gatewayUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-gateway.com"</span><span class="hl-1">, </span><span class="hl-5">provider:</span><span class="hl-1"> </span><span class="hl-2">"openai"</span><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-5">gatewayApiUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-gateway.com"</span><span class="hl-1">, </span><span class="hl-8">// Handles TTS, STT, and MCP</span><br/><span class="hl-1">};</span>
|
|
607
|
+
</code><button type="button">Copy</button></pre>
|
|
608
|
+
|
|
609
|
+
<a id="md:development-vs-production" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Development vs Production<a href="#md:development-vs-production" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
610
|
+
<li><strong>Development</strong>: Direct provider API keys are acceptable for local testing</li>
|
|
611
|
+
<li><strong>Production</strong>: Always use a gateway/wrapper service to protect sensitive credentials</li>
|
|
612
|
+
</ul>
|
|
613
|
+
<a id="md:requirements" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Requirements<a href="#md:requirements" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><a id="md:gateway-api-services" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Gateway API Services<a href="#md:gateway-api-services" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>The Bandit Engine uses a <strong>unified gateway approach</strong> for all backend services. Your gateway API should implement these endpoints:</p>
|
|
614
|
+
<p><strong>Core AI Services:</strong></p>
|
|
615
|
+
<ul>
|
|
616
|
+
<li><code>GET /api/health</code> - Health check and service discovery</li>
|
|
617
|
+
<li><code>POST /api/chat/completions</code> - Chat completions (OpenAI format)</li>
|
|
618
|
+
<li><code>POST /api/generate</code> - Text generation</li>
|
|
619
|
+
<li>Provider-specific routing (automatically handled)</li>
|
|
620
|
+
</ul>
|
|
621
|
+
<p><strong>Voice Services (Optional):</strong></p>
|
|
622
|
+
<ul>
|
|
623
|
+
<li>
|
|
624
|
+
<p><code>POST /api/tts</code> - Text-to-Speech conversion</p>
|
|
625
|
+
<ul>
|
|
626
|
+
<li>Input: <code>{ text: string, voice?: string, speed?: number }</code></li>
|
|
627
|
+
<li>Output: Audio file or streaming audio</li>
|
|
628
|
+
<li><strong>Technology-agnostic</strong>: Works with OpenAI TTS, Azure Speech, Google TTS, AWS Polly, Whisper.cpp, or custom implementations</li>
|
|
629
|
+
</ul>
|
|
630
|
+
</li>
|
|
631
|
+
<li>
|
|
632
|
+
<p><code>POST /api/stt</code> - Speech-to-Text transcription</p>
|
|
633
|
+
<ul>
|
|
634
|
+
<li>Input: Audio file upload (multipart/form-data)</li>
|
|
635
|
+
<li>Output: <code>{ text: string }</code> or <code>{ transcription: string }</code></li>
|
|
636
|
+
<li><strong>Technology-agnostic</strong>: Works with OpenAI Whisper, Azure Speech, Google Speech, AWS Transcribe, local Whisper, or custom implementations</li>
|
|
637
|
+
</ul>
|
|
638
|
+
</li>
|
|
639
|
+
<li>
|
|
640
|
+
<p><code>GET /api/tts/available-models</code> - Voice model discovery</p>
|
|
641
|
+
<ul>
|
|
642
|
+
<li>Output: <code>{ models: string[], defaultModel: string, fallbackModel: string }</code></li>
|
|
643
|
+
<li>Used for automatic service availability detection</li>
|
|
644
|
+
</ul>
|
|
645
|
+
</li>
|
|
646
|
+
</ul>
|
|
647
|
+
<p><strong>MCP Services (Optional):</strong></p>
|
|
648
|
+
<ul>
|
|
649
|
+
<li>Model Context Protocol endpoints for tool integration</li>
|
|
650
|
+
</ul>
|
|
651
|
+
<a id="md:technology-agnostic-implementation" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Technology-Agnostic Implementation<a href="#md:technology-agnostic-implementation" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Your gateway can be implemented in <strong>any language or framework</strong>:</p>
|
|
652
|
+
<ul>
|
|
653
|
+
<li><strong>Node.js/Express</strong>, <strong>Python/FastAPI</strong>, <strong>.NET Core</strong>, <strong>Java/Spring</strong></li>
|
|
654
|
+
<li><strong>PHP/Laravel</strong>, <strong>Ruby on Rails</strong>, <strong>Go/Gin</strong>, <strong>Rust/Axum</strong></li>
|
|
655
|
+
<li><strong>Serverless</strong> (AWS Lambda, Vercel Functions, Cloudflare Workers)</li>
|
|
656
|
+
</ul>
|
|
657
|
+
<p>The Bandit Engine only requires that your endpoints follow the expected input/output contracts. The underlying implementation is completely flexible.</p>
|
|
658
|
+
<a id="md:additional-resources" class="tsd-anchor"></a><h3 class="tsd-anchor-link">Additional Resources<a href="#md:additional-resources" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
659
|
+
<li><strong>PDF Worker</strong>: For document embedding features, the engine uses the PDF parsing worker from <code>https://cdn.burtson.ai/scripts/pdf.worker.js</code></li>
|
|
660
|
+
<li><strong>CDN Resources</strong>: Default avatars, logos, and configurations load from <code>https://cdn.burtson.ai/</code> if not overridden locally</li>
|
|
661
|
+
</ul>
|
|
662
|
+
<a id="md:💡-vision--roadmap" class="tsd-anchor"></a><h2 class="tsd-anchor-link">💡 Vision & Roadmap<a href="#md:💡-vision--roadmap" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Bandit Engine isn't just a component – it's a foundation. Coming soon:</p>
|
|
663
|
+
<ul>
|
|
664
|
+
<li>Multi-modal input: image, voice, document uploads</li>
|
|
665
|
+
<li>Agentic flow support with visualized cards and suggestions</li>
|
|
666
|
+
<li>Pluggable memory and long-term knowledge</li>
|
|
667
|
+
<li>Customizable avatars and real-time voice playback</li>
|
|
668
|
+
<li>Client-defined RAG and embedding search</li>
|
|
669
|
+
</ul>
|
|
670
|
+
<p>We’re building this to be the interface layer of your AI-first products. Own the UX. Own the brand. Own the experience.</p>
|
|
671
|
+
<hr>
|
|
672
|
+
<a id="md:📌-migration-guide" class="tsd-anchor"></a><h2 class="tsd-anchor-link">📌 Migration Guide<a href="#md:📌-migration-guide" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><a id="md:from-legacy-ttsstt-urls-to-gateway-api" class="tsd-anchor"></a><h3 class="tsd-anchor-link">From Legacy TTS/STT URLs to Gateway API<a href="#md:from-legacy-ttsstt-urls-to-gateway-api" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>If you're currently using separate <code>ttsUrl</code> and <code>sttUrl</code> settings, migrate to the unified gateway approach:</p>
|
|
673
|
+
<p><strong>Before (Deprecated):</strong></p>
|
|
674
|
+
<pre><code class="tsx"><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">settings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-5">ttsUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-tts-service.com/api/tts"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">sttUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-stt-service.com/api/stt"</span><span class="hl-1">, </span><br/><span class="hl-1"> </span><span class="hl-5">ollamaUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-ollama.com"</span><span class="hl-1">,</span><br/><span class="hl-1">};</span>
|
|
675
|
+
</code><button type="button">Copy</button></pre>
|
|
676
|
+
|
|
677
|
+
<p><strong>After (Recommended):</strong></p>
|
|
678
|
+
<pre><code class="tsx"><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">settings</span><span class="hl-1"> = {</span><br/><span class="hl-1"> </span><span class="hl-5">aiProvider:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-5">type:</span><span class="hl-1"> </span><span class="hl-2">"gateway"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">gatewayUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-gateway.com"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-5">provider:</span><span class="hl-1"> </span><span class="hl-2">"openai"</span><br/><span class="hl-1"> },</span><br/><span class="hl-1"> </span><span class="hl-5">gatewayApiUrl:</span><span class="hl-1"> </span><span class="hl-2">"https://your-gateway.com"</span><span class="hl-1">, </span><span class="hl-8">// Unified endpoint for all services</span><br/><span class="hl-1">};</span>
|
|
679
|
+
</code><button type="button">Copy</button></pre>
|
|
680
|
+
|
|
681
|
+
<p>The new approach provides:</p>
|
|
682
|
+
<ul>
|
|
683
|
+
<li>✅ <strong>Unified API</strong>: One endpoint for all services</li>
|
|
684
|
+
<li>✅ <strong>Better Security</strong>: Centralized authentication and rate limiting</li>
|
|
685
|
+
<li>✅ <strong>Technology Flexibility</strong>: Use any backend implementation</li>
|
|
686
|
+
<li>✅ <strong>Automatic Discovery</strong>: Real-time service availability detection</li>
|
|
687
|
+
</ul>
|
|
688
|
+
<hr>
|
|
689
|
+
<a id="md:🛡️-license--protection" class="tsd-anchor"></a><h2 class="tsd-anchor-link">🛡️ License & Protection<a href="#md:🛡️-license--protection" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>This software is protected under the <strong>Business Source License (BUSL) 1.1</strong> by Burtson Labs LLC.</p>
|
|
690
|
+
<a id="md:⚖️-license-summary" class="tsd-anchor"></a><h3 class="tsd-anchor-link">⚖️ License Summary<a href="#md:⚖️-license-summary" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><ul>
|
|
691
|
+
<li>✅ <strong>Development & Evaluation</strong>: Free for internal development, testing, and evaluation</li>
|
|
692
|
+
<li>✅ <strong>Non-Commercial Use</strong>: Free for educational, research, and personal projects</li>
|
|
693
|
+
<li>❌ <strong>Commercial Production</strong>: Requires commercial license for production deployment</li>
|
|
694
|
+
<li>❌ <strong>Competitive Use</strong>: Cannot be used to create competing AI chat products</li>
|
|
695
|
+
<li>❌ <strong>AI Training</strong>: Cannot be used as training data for AI models</li>
|
|
696
|
+
</ul>
|
|
697
|
+
<a id="md:📋-usage-rights" class="tsd-anchor"></a><h3 class="tsd-anchor-link">📋 Usage Rights<a href="#md:📋-usage-rights" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p><strong>Permitted:</strong></p>
|
|
698
|
+
<ul>
|
|
699
|
+
<li>Internal development and testing</li>
|
|
700
|
+
<li>Educational and research purposes</li>
|
|
701
|
+
<li>Evaluation for potential commercial licensing</li>
|
|
702
|
+
<li>Contributions back to the project (under same license)</li>
|
|
703
|
+
</ul>
|
|
704
|
+
<p><strong>Prohibited:</strong></p>
|
|
705
|
+
<ul>
|
|
706
|
+
<li>Production use without commercial license</li>
|
|
707
|
+
<li>Creating derivative commercial products</li>
|
|
708
|
+
<li>Using as training data for AI/ML models</li>
|
|
709
|
+
<li>Removing or modifying license notices and watermarks</li>
|
|
710
|
+
</ul>
|
|
711
|
+
<a id="md:🔒-protection-features" class="tsd-anchor"></a><h3 class="tsd-anchor-link">🔒 Protection Features<a href="#md:🔒-protection-features" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>This codebase includes multiple protection layers:</p>
|
|
712
|
+
<ul>
|
|
713
|
+
<li><strong>Embedded Watermarks</strong>: Visible and stealth fingerprints in all source files</li>
|
|
714
|
+
<li><strong>Audit Trails</strong>: Usage tracking and compliance monitoring</li>
|
|
715
|
+
<li><strong>License Validation</strong>: Runtime checks for compliance</li>
|
|
716
|
+
<li><strong>Honey Pot Files</strong>: Trap files that trigger license violations when accessed</li>
|
|
717
|
+
</ul>
|
|
718
|
+
<p><strong>⚠️ Warning</strong>: Removing, modifying, or bypassing these protection mechanisms constitutes a license violation and may result in immediate license termination.</p>
|
|
719
|
+
<a id="md:💼-commercial-licensing" class="tsd-anchor"></a><h3 class="tsd-anchor-link">💼 Commercial Licensing<a href="#md:💼-commercial-licensing" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p><strong>Production License</strong>: Required for commercial deployment</p>
|
|
720
|
+
<ul>
|
|
721
|
+
<li>Full production rights</li>
|
|
722
|
+
<li>Priority support and maintenance</li>
|
|
723
|
+
<li>Custom integrations and features</li>
|
|
724
|
+
<li>Enterprise SLA options</li>
|
|
725
|
+
</ul>
|
|
726
|
+
<p><strong>Contact for Licensing:</strong></p>
|
|
727
|
+
<ul>
|
|
728
|
+
<li><strong>Email</strong>: <a href="mailto:legal@burtson.ai">legal@burtson.ai</a></li>
|
|
729
|
+
<li><strong>Website</strong>: <a href="https://burtson.ai/license" target="_blank" class="external">https://burtson.ai/license</a></li>
|
|
730
|
+
<li><strong>Sales</strong>: <a href="mailto:sales@burtson.ai">sales@burtson.ai</a></li>
|
|
731
|
+
</ul>
|
|
732
|
+
<a id="md:👨💻-for-contributors--developers" class="tsd-anchor"></a><h3 class="tsd-anchor-link">👨💻 For Contributors & Developers<a href="#md:👨💻-for-contributors--developers" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Before contributing or making changes to this codebase:</p>
|
|
733
|
+
<pre><code class="bash"><span class="hl-8"># Essential pre-push workflow - run before every commit</span><br/><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">run</span><span class="hl-1"> </span><span class="hl-2">pre-push</span>
|
|
734
|
+
</code><button type="button">Copy</button></pre>
|
|
735
|
+
|
|
736
|
+
<p><strong>Developer Resources:</strong></p>
|
|
737
|
+
<ul>
|
|
738
|
+
<li><strong><a href="media/PROTECTION-README.md">PROTECTION-README.md</a></strong> - Quick protection system guide</li>
|
|
739
|
+
<li><strong><a href="media/PRE-PUSH-CHECKLIST.md">PRE-PUSH-CHECKLIST.md</a></strong> - Complete workflow documentation</li>
|
|
740
|
+
<li><strong><a href="media/PROTECTION-NOTICE.md">PROTECTION-NOTICE.md</a></strong> - Legal notices and compliance requirements</li>
|
|
741
|
+
<li><strong><a href="media/LICENSE">LICENSE</a></strong> - Full BUSL 1.1 license text</li>
|
|
742
|
+
</ul>
|
|
743
|
+
<a id="md:📝-license-compliance" class="tsd-anchor"></a><h3 class="tsd-anchor-link">📝 License Compliance<a href="#md:📝-license-compliance" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>All source files must include proper license headers and watermarks. The protection system automatically:</p>
|
|
744
|
+
<ul>
|
|
745
|
+
<li>Adds license headers to new files</li>
|
|
746
|
+
<li>Validates compliance on every build</li>
|
|
747
|
+
<li>Tracks usage and modifications</li>
|
|
748
|
+
<li>Prevents unauthorized distribution</li>
|
|
749
|
+
</ul>
|
|
750
|
+
<p><strong>Quick Commands:</strong></p>
|
|
751
|
+
<pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">run</span><span class="hl-1"> </span><span class="hl-2">protect</span><span class="hl-1"> </span><span class="hl-8"># Apply protection to new files</span><br/><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">run</span><span class="hl-1"> </span><span class="hl-2">validate-protection</span><span class="hl-1"> </span><span class="hl-8"># Check for license violations </span><br/><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">run</span><span class="hl-1"> </span><span class="hl-2">pre-push</span><span class="hl-1"> </span><span class="hl-8"># Complete pre-push validation</span>
|
|
752
|
+
</code><button type="button">Copy</button></pre>
|
|
753
|
+
|
|
754
|
+
<hr>
|
|
755
|
+
<p><strong>© 2025 Burtson Labs LLC. All rights reserved.</strong></p>
|
|
756
|
+
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><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><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><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></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#md:⚡-cli-quick-start"><span>⚡ CLI <wbr/>Quick <wbr/>Start</span></a><ul><li><a href="#md:cli-options"><span>CLI <wbr/>Options</span></a></li></ul><a href="#md:🛠️-getting-started--plug--play-ai"><span>🛠️ <wbr/>Getting <wbr/>Started – <wbr/>Plug & <wbr/>Play AI</span></a><ul><li><a href="#md:🔄-quick-provider-setup"><span>🔄 <wbr/>Quick <wbr/>Provider <wbr/>Setup</span></a></li><li><a href="#md:ollama-env-setup"><span>Ollama .env <wbr/>Setup</span></a></li><li><a href="#md:🎤-voice-services-ttsstt"><span>🎤 <wbr/>Voice <wbr/>Services (TTS/STT)</span></a></li></ul><a href="#md:🧩-consuming-the-components"><span>🧩 <wbr/>Consuming the <wbr/>Components</span></a><ul><li><a href="#md:🛠️-utility-functions--hooks"><span>🛠️ <wbr/>Utility <wbr/>Functions & <wbr/>Hooks</span></a></li><li><ul><li><a href="#md:debug-logger"><span>Debug <wbr/>Logger</span></a></li><li><a href="#md:ai-prompt-utilities"><span>AI <wbr/>Prompt <wbr/>Utilities</span></a></li><li><a href="#md:datetime-context"><span>Date/<wbr/>Time <wbr/>Context</span></a></li></ul></li></ul><a href="#md:🎛️-chat-control-center-chatmodal-feature"><span>🎛️ <wbr/>Chat <wbr/>Control <wbr/>Center (<wbr/>Chat<wbr/>Modal <wbr/>Feature)</span></a><ul><li><a href="#md:🔧-core-features"><span>🔧 <wbr/>Core <wbr/>Features</span></a></li><li><a href="#md:🎤-voice-integration"><span>🎤 <wbr/>Voice <wbr/>Integration</span></a></li><li><a href="#md:🔄-context-switching"><span>🔄 <wbr/>Context <wbr/>Switching</span></a></li><li><a href="#md:💾-memory-features"><span>💾 <wbr/>Memory <wbr/>Features</span></a></li><li><a href="#md:📧-feedback-system"><span>📧 <wbr/>Feedback <wbr/>System</span></a></li></ul><a href="#md:⚙️-angular-integration-experimental"><span>⚙️ <wbr/>Angular <wbr/>Integration (<wbr/>Experimental)</span></a><a href="#md:⚙️-vuejs-integration-experimental"><span>⚙️ <wbr/>Vue.js <wbr/>Integration (<wbr/>Experimental)</span></a><a href="#md:📦-custom-element-support"><span>📦 <wbr/>Custom <wbr/>Element <wbr/>Support</span></a><a href="#md:📸-live-preview"><span>📸 <wbr/>Live <wbr/>Preview</span></a><a href="#md:⚙️-configuration-options"><span>⚙️ <wbr/>Configuration <wbr/>Options</span></a><a href="#md:🤖-ai-provider-system"><span>🤖 AI <wbr/>Provider <wbr/>System</span></a><ul><li><a href="#md:supported-providers"><span>Supported <wbr/>Providers</span></a></li><li><a href="#md:gateway-provider-recommended"><span>Gateway <wbr/>Provider (<wbr/>Recommended)</span></a></li><li><a href="#md:legacy-direct-providers"><span>Legacy <wbr/>Direct <wbr/>Providers</span></a></li><li><a href="#md:migration-to-gateway"><span>Migration to <wbr/>Gateway</span></a></li><li><a href="#md:imagemultimodal-support"><span>Image/<wbr/>Multimodal <wbr/>Support</span></a></li><li><a href="#md:using-the-ai-provider"><span>Using the AI <wbr/>Provider</span></a></li></ul><a href="#md:🔧-model-context-protocol-mcp-integration"><span>🔧 <wbr/>Model <wbr/>Context <wbr/>Protocol (MCP) <wbr/>Integration</span></a><ul><li><a href="#md:mcp-features"><span>MCP <wbr/>Features</span></a></li><li><a href="#md:using-mcp-tools"><span>Using MCP <wbr/>Tools</span></a></li><li><a href="#md:mcp-tool-configuration"><span>MCP <wbr/>Tool <wbr/>Configuration</span></a></li><li><a href="#md:mcp-service-api"><span>MCP <wbr/>Service API</span></a></li></ul><a href="#md:🎛️-feature-flags--subscription-tiers"><span>🎛️ <wbr/>Feature <wbr/>Flags & <wbr/>Subscription <wbr/>Tiers</span></a><ul><li><a href="#md:subscription-tiers"><span>Subscription <wbr/>Tiers</span></a></li><li><a href="#md:feature-flag-configuration"><span>Feature <wbr/>Flag <wbr/>Configuration</span></a></li><li><a href="#md:tier-based-feature-matrix"><span>Tier-<wbr/>Based <wbr/>Feature <wbr/>Matrix</span></a></li><li><a href="#md:jwt-based-authentication"><span>JWT-<wbr/>Based <wbr/>Authentication</span></a></li><li><a href="#md:using-feature-flags-in-components"><span>Using <wbr/>Feature <wbr/>Flags in <wbr/>Components</span></a></li><li><a href="#md:subscription-state-management"><span>Subscription <wbr/>State <wbr/>Management</span></a></li><li><a href="#md:feature-restrictions--upgrade-prompts"><span>Feature <wbr/>Restrictions & <wbr/>Upgrade <wbr/>Prompts</span></a></li><li><a href="#md:development--testing"><span>Development & <wbr/>Testing</span></a></li><li><a href="#md:backend-integration"><span>Backend <wbr/>Integration</span></a></li></ul><a href="#md:🐛-debug-logger"><span>🐛 <wbr/>Debug <wbr/>Logger</span></a><a href="#md:🔒-security-best-practices"><span>🔒 <wbr/>Security <wbr/>Best <wbr/>Practices</span></a><ul><li><a href="#md:recommended-architecture"><span>Recommended <wbr/>Architecture</span></a></li><li><a href="#md:gateway-setup"><span>Gateway <wbr/>Setup</span></a></li><li><a href="#md:legacy-configuration-deprecated"><span>Legacy <wbr/>Configuration (<wbr/>Deprecated)</span></a></li><li><a href="#md:development-vs-production"><span>Development vs <wbr/>Production</span></a></li></ul><a href="#md:requirements"><span>Requirements</span></a><ul><li><a href="#md:gateway-api-services"><span>Gateway API <wbr/>Services</span></a></li><li><a href="#md:technology-agnostic-implementation"><span>Technology-<wbr/>Agnostic <wbr/>Implementation</span></a></li><li><a href="#md:additional-resources"><span>Additional <wbr/>Resources</span></a></li></ul><a href="#md:💡-vision--roadmap"><span>💡 <wbr/>Vision & <wbr/>Roadmap</span></a><a href="#md:📌-migration-guide"><span>📌 <wbr/>Migration <wbr/>Guide</span></a><ul><li><a href="#md:from-legacy-ttsstt-urls-to-gateway-api"><span>From <wbr/>Legacy TTS/STT URLs to <wbr/>Gateway API</span></a></li></ul><a href="#md:🛡️-license--protection"><span>🛡️ <wbr/>License & <wbr/>Protection</span></a><ul><li><a href="#md:⚖️-license-summary"><span>⚖️ <wbr/>License <wbr/>Summary</span></a></li><li><a href="#md:📋-usage-rights"><span>📋 <wbr/>Usage <wbr/>Rights</span></a></li><li><a href="#md:🔒-protection-features"><span>🔒 <wbr/>Protection <wbr/>Features</span></a></li><li><a href="#md:💼-commercial-licensing"><span>💼 <wbr/>Commercial <wbr/>Licensing</span></a></li><li><a href="#md:👨💻-for-contributors--developers"><span>👨💻 <wbr/>For <wbr/>Contributors & <wbr/>Developers</span></a></li><li><a href="#md:📝-license-compliance"><span>📝 <wbr/>License <wbr/>Compliance</span></a></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="assets/icons.svg#icon-1"></use></svg><span>@burtson-labs/bandit-engine</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base="."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|