@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
package/README.md
ADDED
|
@@ -0,0 +1,1235 @@
|
|
|
1
|
+
<a href="https://burtson.ai"><img src="https://cdn.burtson.ai/logos/burtson-labs-logo-alt.png" alt="Burtson Labs Logo" width="120" style="width: 120px !important; max-width: 120px !important; height: auto; display: inline-block;" /></a>
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@burtson-labs/bandit-engine)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
> **Welcome to the Bandit Engine β an AI chat interface toolkit from Burtson Labs.**
|
|
8
|
+
> 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.
|
|
9
|
+
|
|
10
|
+
π Looking for docs? Start with the [documentation index](./docs/README.md) or jump straight to the [gateway contract](./docs/02_gateway_api.md).
|
|
11
|
+
|
|
12
|
+
π§ͺ Want to kick the tires? Clone the [Node.js gateway example](./examples/gateway-node/README.md) for a ready-to-run backend.
|
|
13
|
+
|
|
14
|
+
## β‘ CLI Quick Start
|
|
15
|
+
|
|
16
|
+
Want a working playground instantly? Scaffold a Bandit app and gateway in one command:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx @burtson-labs/bandit-engine create my-bandit-app
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
What you get out of the box:
|
|
25
|
+
|
|
26
|
+
- Vite + React project wired with `Chat`, `ChatModal`, and `ChatProvider`
|
|
27
|
+
- Express gateway that proxies OpenAI or Ollama behind `/api`
|
|
28
|
+
- Branding + persona config in `public/config.json`, ready for your logo or prompts
|
|
29
|
+
|
|
30
|
+
Customize the output with options such as:
|
|
31
|
+
|
|
32
|
+
- `--branding-text "Bandit Support"` to set the assistant display name
|
|
33
|
+
- `--frontend-port 5190` to change the Vite dev server port
|
|
34
|
+
- `--gateway-port 9090` to run the sample gateway on an alternate port
|
|
35
|
+
- `--yes` / `--skip-prompts` to accept defaults non-interactively
|
|
36
|
+
- `--force` to overwrite a non-empty directory
|
|
37
|
+
|
|
38
|
+
> ποΈ The generated project includes an `.npmrc` that targets `https://npm.pkg.github.com/` and expects a `GITHUB_NPM_TOKEN` environment variable. Run `npm login --registry=https://npm.pkg.github.com --scope=@burtson-labs` (or export `GITHUB_NPM_TOKEN`) before installing dependencies.
|
|
39
|
+
|
|
40
|
+
Check out the [CLI quick start guide](./docs/05_cli_quickstart.md) for the full walkthrough, option matrix, and project anatomy.
|
|
41
|
+
|
|
42
|
+
### CLI Options
|
|
43
|
+
|
|
44
|
+
| Flag | Description | Example |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `--branding-text <text>` | Set the assistant name shown in the UI. | `--branding-text "Bandit Support"` |
|
|
47
|
+
| `--frontend-port <port>` | Change the Vite dev server port (default `5183`). | `--frontend-port 5190` |
|
|
48
|
+
| `--gateway-port <port>` | Change the sample gateway port (default `8080`). | `--gateway-port 9090` |
|
|
49
|
+
| `--yes`, `--skip-prompts` | Accept defaults without interactive questions. | `--yes` |
|
|
50
|
+
| `--force` | Overwrite the target directory if it already exists. | `--force` |
|
|
51
|
+
|
|
52
|
+
The CLI prints next steps (install, copy `.env`, run dev server) once scaffolding completes, so you can copy-paste and ship immediately.
|
|
53
|
+
|
|
54
|
+
## π οΈ Getting Started β Plug & Play AI
|
|
55
|
+
|
|
56
|
+
1. **Add a config.json** to your public folder (or host it on a CDN) and point `brandingConfigUrl` at it:
|
|
57
|
+
|
|
58
|
+
_Host it locally in `/public` or serve it from a CDN and reference it via `brandingConfigUrl`._
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"theme": "bandit-dark",
|
|
63
|
+
"branding": {
|
|
64
|
+
"brandingText": "Bandit Chat Premium Beta",
|
|
65
|
+
"logoBase64": ""
|
|
66
|
+
},
|
|
67
|
+
"models": [
|
|
68
|
+
{ "name": "Bandit-Core", "description": "General purpose model" },
|
|
69
|
+
{ "name": "Bandit-Muse", "description": "Creative writing model" }
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
No bloated setup. No magic strings. Just drop in your `config.json`, hook up a few props, and let your AI speak for itself.
|
|
75
|
+
|
|
76
|
+
2. **Wrap your entire app with `ChatProvider` to enable Bandit features globally:**
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import React from "react";
|
|
80
|
+
import ReactDOM from "react-dom/client";
|
|
81
|
+
import App from "./App";
|
|
82
|
+
import { CssBaseline, ThemeProvider } from "@mui/material";
|
|
83
|
+
import { banditDarkTheme } from "./theme/banditTheme";
|
|
84
|
+
import { AppInitializer } from "./app-initializer";
|
|
85
|
+
import { ChatProvider } from "@burtson-labs/bandit-engine";
|
|
86
|
+
|
|
87
|
+
const chatPackageSettings = {
|
|
88
|
+
// New Gateway Provider Configuration (Recommended)
|
|
89
|
+
aiProvider: {
|
|
90
|
+
type: "gateway" as const,
|
|
91
|
+
gatewayUrl: import.meta.env.VITE_GATEWAY_API_URL!,
|
|
92
|
+
provider: "openai" // Backend: openai, azure-openai, anthropic, ollama
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// Legacy Ollama Configuration (Still Supported)
|
|
96
|
+
// ollamaUrl: import.meta.env.VITE_OLLAMA_URL!,
|
|
97
|
+
|
|
98
|
+
// Model Configuration
|
|
99
|
+
defaultModel: import.meta.env.VITE_DEFAULT_MODEL!,
|
|
100
|
+
fallbackModel: import.meta.env.VITE_FALLBACK_MODEL,
|
|
101
|
+
|
|
102
|
+
gatewayApiUrl: import.meta.env.VITE_GATEWAY_API_URL!,
|
|
103
|
+
|
|
104
|
+
// Branding and optional overrides
|
|
105
|
+
brandingConfigUrl: "/config.json",
|
|
106
|
+
// s3ApiUrl: import.meta.env.VITE_S3_API_URL,
|
|
107
|
+
// homeUrl: "https://yourapp.com",
|
|
108
|
+
// feedbackEmail: "feedback@yourapp.com",
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
112
|
+
<React.StrictMode>
|
|
113
|
+
<ThemeProvider theme={banditDarkTheme}>
|
|
114
|
+
<CssBaseline />
|
|
115
|
+
<AppInitializer />
|
|
116
|
+
<ChatProvider packageSettings={chatPackageSettings}>
|
|
117
|
+
<App />
|
|
118
|
+
</ChatProvider>
|
|
119
|
+
</ThemeProvider>
|
|
120
|
+
</React.StrictMode>
|
|
121
|
+
);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
> π Within minutes, you'll have a fully functional chat interface that can read, speak, and reason β all brandable, themeable, and extensible.
|
|
125
|
+
|
|
126
|
+
### π Quick Provider Setup
|
|
127
|
+
|
|
128
|
+
**Option 1: Gateway Provider (Recommended)**
|
|
129
|
+
```tsx
|
|
130
|
+
// Most secure - API keys stay on your backend
|
|
131
|
+
// Your gateway can be built in ANY language: Node.js, Python, .NET, Java, PHP, Go, etc.
|
|
132
|
+
aiProvider: {
|
|
133
|
+
type: "gateway",
|
|
134
|
+
gatewayUrl: "https://your-api-gateway.com", // Your backend API
|
|
135
|
+
provider: "openai" // Specify which AI provider to use
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Option 2: Direct Provider (Development)**
|
|
140
|
+
```tsx
|
|
141
|
+
// Quick start - API keys in frontend (not for production)
|
|
142
|
+
aiProvider: {
|
|
143
|
+
type: "ollama",
|
|
144
|
+
baseUrl: "http://localhost:11434"
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Gateway Requirements:** Your backend needs to implement these endpoints:
|
|
149
|
+
- `GET /api/health` - Health check
|
|
150
|
+
- `POST /api/chat/completions` - Chat completions
|
|
151
|
+
- `POST /api/generate` - Text generation
|
|
152
|
+
- `POST /api/tts` - Text-to-Speech (optional, for voice features)
|
|
153
|
+
- `GET /api/tts/available-models` - TTS model listing (optional)
|
|
154
|
+
- `POST /api/stt` - Speech-to-Text (optional, for voice input)
|
|
155
|
+
|
|
156
|
+
> **β οΈ Important:** The Bandit Engine automatically routes to provider-specific endpoints:
|
|
157
|
+
> - **Ollama** β `/api/ollama/chat` (native Ollama format)
|
|
158
|
+
> - **OpenAI/Azure/Anthropic** β `/api/{provider}/chat/completions` (OpenAI format)
|
|
159
|
+
> - **TTS/STT** β Technology-agnostic endpoints that work with any backend implementation
|
|
160
|
+
|
|
161
|
+
### Ollama .env Setup
|
|
162
|
+
|
|
163
|
+
To run the quickstart purely against an Ollama daemon:
|
|
164
|
+
|
|
165
|
+
1. Install (or build) the models you want to expose, e.g.:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
ollama pull llava:latest
|
|
169
|
+
ollama pull gemma2:9b-instruct
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
2. Edit the generated `.env` and point both the frontend and gateway at Ollama:
|
|
173
|
+
|
|
174
|
+
```ini
|
|
175
|
+
# Frontend
|
|
176
|
+
VITE_GATEWAY_PROVIDER=ollama
|
|
177
|
+
VITE_DEFAULT_MODEL=llava:latest # any model installed on your Ollama box
|
|
178
|
+
VITE_FALLBACK_MODEL=gemma2:9b-instruct # optional, but handy for text-only fallbacks
|
|
179
|
+
|
|
180
|
+
# Gateway / server
|
|
181
|
+
OLLAMA_URL=http://localhost:11434 # or the remote daemon address
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Set `VITE_DEFAULT_MODEL` / `VITE_FALLBACK_MODEL` to the exact Ollama model tags you have available (`gemma`, `llava`, `moondream`, or your own custom builds). Bandit automatically detects multimodal Ollama models, so setting `llava`, `moondream`, or other vision-capable variants enables image understanding with no extra code.
|
|
185
|
+
|
|
186
|
+
### π€ Voice Services (TTS/STT)
|
|
187
|
+
|
|
188
|
+
The Bandit Engine supports Text-to-Speech (TTS) and Speech-to-Text (STT) through your gateway API. These services are **technology-agnostic** - you can implement them using any backend technology:
|
|
189
|
+
|
|
190
|
+
**TTS Endpoint (`POST /api/tts`)**
|
|
191
|
+
- **Input**: `{ text: string, voice?: string, speed?: number }`
|
|
192
|
+
- **Output**: Audio file (MP3, WAV, etc.) or streaming audio
|
|
193
|
+
- **Compatible with**: OpenAI TTS, Azure Speech, Google Cloud TTS, AWS Polly, local TTS servers, or custom implementations
|
|
194
|
+
|
|
195
|
+
**STT Endpoint (`POST /api/stt`)**
|
|
196
|
+
- **Input**: Audio file upload (multipart/form-data)
|
|
197
|
+
- **Output**: `{ text: string }` or `{ transcription: string }`
|
|
198
|
+
- **Compatible with**: OpenAI Whisper, Azure Speech, Google Speech, AWS Transcribe, local Whisper servers, or custom implementations
|
|
199
|
+
|
|
200
|
+
**Service Discovery (`GET /api/tts/available-models`)**
|
|
201
|
+
- **Output**: `{ models: string[], defaultModel: string, fallbackModel: string }`
|
|
202
|
+
- Used for automatic service availability detection and voice model selection
|
|
203
|
+
|
|
204
|
+
See the [Gateway API Contract](./docs/02_gateway_api.md) for complete implementation examples in multiple languages.
|
|
205
|
+
|
|
206
|
+
Use the Management interface to switch providers anytime or migrate from direct to gateway setup.
|
|
207
|
+
|
|
208
|
+
3. **Development**
|
|
209
|
+
|
|
210
|
+
- Use `npm link` or a monorepo workspace to test locally before publishing.
|
|
211
|
+
- Build with `tsup`.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## π§© Consuming the Components
|
|
216
|
+
|
|
217
|
+
Once you've wrapped your app with `ChatProvider`, you can selectively integrate Bandit's components as needed:
|
|
218
|
+
|
|
219
|
+
- `<Chat />`: The main chat interface, designed to be used on a dedicated page or embedded into your product.
|
|
220
|
+
- `<Management />`: A full-featured admin and model configuration UI. This should not be on the same page as `<Chat />`. Use this to allow authenticated users to manage themes, models, and embedded knowledge.
|
|
221
|
+
- `<ChatModal />`: A flexible, mobile-friendly modal that can be launched anywhere in your app for quick AI interactions. Features include:
|
|
222
|
+
- **Chat Control Center**: Built-in conversation management, voice model switching, and memory controls
|
|
223
|
+
- **Context Switching**: Toggle between local session and saved conversation history
|
|
224
|
+
- **Voice Integration**: Voice model selection with real-time preview (when TTS is configured)
|
|
225
|
+
- **Navigation**: Seamless transition from modal to full chat interface
|
|
226
|
+
- **Auto-theming**: Automatically uses the theme configured in the Management interface
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { Chat, Management, ChatModal, ChatProvider } from '@burtson-labs/bandit-engine';
|
|
230
|
+
import { useState } from 'react';
|
|
231
|
+
|
|
232
|
+
function YourPage() {
|
|
233
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<>
|
|
237
|
+
<Chat />
|
|
238
|
+
{/* Use <Management /> on a separate admin route with access controls */}
|
|
239
|
+
|
|
240
|
+
{/* Trigger the AI modal anywhere in your app */}
|
|
241
|
+
<button onClick={() => setIsModalOpen(true)}>
|
|
242
|
+
Ask AI
|
|
243
|
+
</button>
|
|
244
|
+
<ChatModal
|
|
245
|
+
open={isModalOpen}
|
|
246
|
+
onClose={() => setIsModalOpen(false)}
|
|
247
|
+
/>
|
|
248
|
+
</>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### π οΈ Utility Functions & Hooks
|
|
254
|
+
|
|
255
|
+
Bandit Engine exports several utility functions for advanced use cases:
|
|
256
|
+
|
|
257
|
+
#### Debug Logger
|
|
258
|
+
Replace console statements with structured logging:
|
|
259
|
+
|
|
260
|
+
```tsx
|
|
261
|
+
import { debugLogger } from '@burtson-labs/bandit-engine';
|
|
262
|
+
|
|
263
|
+
debugLogger.info('Chat session started');
|
|
264
|
+
debugLogger.warn('Fallback model selected');
|
|
265
|
+
debugLogger.error('Connection failed', { error: details });
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
#### AI Prompt Utilities
|
|
269
|
+
Access the same prompt functions used internally:
|
|
270
|
+
|
|
271
|
+
```tsx
|
|
272
|
+
import {
|
|
273
|
+
generateConversationStarters,
|
|
274
|
+
detectMessageMood,
|
|
275
|
+
detectUserInterestAndExcitement,
|
|
276
|
+
summarizeDocument,
|
|
277
|
+
determineRelevantDocuments
|
|
278
|
+
} from '@burtson-labs/bandit-engine';
|
|
279
|
+
|
|
280
|
+
// Generate conversation starters
|
|
281
|
+
const starters = await generateConversationStarters({
|
|
282
|
+
limit: 5,
|
|
283
|
+
topicOfInterest: "technology, coding, AI"
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Detect user mood for adaptive responses
|
|
287
|
+
const mood = await detectMessageMood("I'm so excited about this project!");
|
|
288
|
+
// Returns: "high" | "neutral" | "low"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
#### Date/Time Context
|
|
292
|
+
All AI interactions automatically include current date/time context to improve relevance and accuracy of responses.
|
|
293
|
+
|
|
294
|
+
> β οΈ **Important:** Each component (`<Chat />`, `<Management />`, `<ChatModal />`) **must** be wrapped in a `ChatProvider` to function correctly.
|
|
295
|
+
> In React, you can wrap your app once at the root.
|
|
296
|
+
> In Angular or Vue, you may need to wrap each usage with a `<bandit-chat-provider>` tag and pass settings each time until full reactive context is supported.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## ποΈ Chat Control Center (ChatModal Feature)
|
|
301
|
+
|
|
302
|
+
The `<ChatModal />` includes a comprehensive Chat Control Center that provides advanced session management:
|
|
303
|
+
|
|
304
|
+
### π§ Core Features
|
|
305
|
+
- **Session vs. Conversation Context**: Toggle between local modal session and persistent conversation history
|
|
306
|
+
- **Voice Model Selection**: Real-time voice switching with preview greetings (requires TTS gateway configuration)
|
|
307
|
+
- **Memory Management**: View and manage AI personal memory entries
|
|
308
|
+
- **Conversation Navigation**: Seamless transition from modal to full chat interface
|
|
309
|
+
- **Manual Refresh**: Force reload of conversations and voice models for troubleshooting
|
|
310
|
+
|
|
311
|
+
### π€ Voice Integration
|
|
312
|
+
When your gateway API includes TTS endpoints, the Chat Control Center provides:
|
|
313
|
+
- **Voice Selection Dropdown**: Choose from available voice models (e.g., Mark, Amy, Kathleen, Lessac, Ryan)
|
|
314
|
+
- **Real-time Preview**: Hear voice greetings when switching models
|
|
315
|
+
- **Consistent Formatting**: Voice names display as proper titles (e.g., "Mark" instead of "en_US-mark-premium")
|
|
316
|
+
- **Availability Detection**: Automatic detection and fallback when voice services are unavailable
|
|
317
|
+
|
|
318
|
+
### π Context Switching
|
|
319
|
+
- **Local Session**: Quick interactions within the modal scope
|
|
320
|
+
- **Main Conversation**: Access full conversation history with automatic navigation to `/chat` route
|
|
321
|
+
- **Smart Conversation Selection**: Automatically loads most recent conversation when switching contexts
|
|
322
|
+
|
|
323
|
+
### πΎ Memory Features
|
|
324
|
+
- **Personal Memory Display**: View AI's stored personal information about the user
|
|
325
|
+
- **Memory Entry Count**: Real-time count of stored memory entries
|
|
326
|
+
- **Memory Management Modal**: Full CRUD operations for memory entries
|
|
327
|
+
|
|
328
|
+
**Example Usage:**
|
|
329
|
+
```tsx
|
|
330
|
+
import { ChatModal } from '@burtson-labs/bandit-engine';
|
|
331
|
+
|
|
332
|
+
function App() {
|
|
333
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
334
|
+
|
|
335
|
+
return (
|
|
336
|
+
<>
|
|
337
|
+
<button onClick={() => setModalOpen(true)}>
|
|
338
|
+
Open AI Assistant
|
|
339
|
+
</button>
|
|
340
|
+
<ChatModal
|
|
341
|
+
open={modalOpen}
|
|
342
|
+
onClose={() => setModalOpen(false)}
|
|
343
|
+
// Chat Control Center is automatically included
|
|
344
|
+
/>
|
|
345
|
+
</>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### π§ Feedback System
|
|
351
|
+
|
|
352
|
+
The Bandit Engine includes a comprehensive feedback system that can be configured and customized for your application.
|
|
353
|
+
|
|
354
|
+
**Configuration:**
|
|
355
|
+
```tsx
|
|
356
|
+
// Package Settings - Configure feedback email
|
|
357
|
+
const chatPackageSettings = {
|
|
358
|
+
// ... other settings
|
|
359
|
+
feedbackEmail: "feedback@yourcompany.com", // Optional: custom feedback email
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// Preferences - Enable/disable feedback in management UI
|
|
363
|
+
// Users can toggle feedback button on/off in preferences
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Standalone Usage:**
|
|
367
|
+
```tsx
|
|
368
|
+
import { FeedbackButton } from '@burtson-labs/bandit-engine';
|
|
369
|
+
|
|
370
|
+
// Floating FAB button (default)
|
|
371
|
+
<FeedbackButton
|
|
372
|
+
feedbackEmail="support@myapp.com" // Optional: override default
|
|
373
|
+
size="small" // small | medium | large
|
|
374
|
+
position={{ bottom: 24, right: 24 }} // Custom positioning
|
|
375
|
+
/>
|
|
376
|
+
|
|
377
|
+
// Inline button
|
|
378
|
+
<FeedbackButton
|
|
379
|
+
inline={true}
|
|
380
|
+
buttonText="Send Feedback"
|
|
381
|
+
size="medium"
|
|
382
|
+
/>
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
**Features:**
|
|
386
|
+
- π± **Responsive Design**: Automatic floating FAB on desktop, inline button on mobile
|
|
387
|
+
- π¨ **Category System**: Bug reports, feature requests, general feedback
|
|
388
|
+
- π **Priority Levels**: Low, medium, high, critical
|
|
389
|
+
- π€ **Annoyance Slider**: Measure user frustration (1-5 scale)
|
|
390
|
+
- π **Single Image Support**: Automatic clipboard integration
|
|
391
|
+
- π§ **Email Fallback**: Generates mailto URLs when API unavailable
|
|
392
|
+
- βοΈ **User Preferences**: Can be enabled/disabled in management UI
|
|
393
|
+
|
|
394
|
+
**Auto-Integration:**
|
|
395
|
+
- Desktop: Floating feedback button (when `preferences.feedbackEnabled` is true)
|
|
396
|
+
- Mobile: Integrated into chat input controls
|
|
397
|
+
- Preferences: Toggle available in management interface
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## βοΈ Angular Integration (Experimental)
|
|
402
|
+
|
|
403
|
+
To use Bandit Engine in an Angular project:
|
|
404
|
+
|
|
405
|
+
1. Install the package:
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
npm install @burtson-labs/bandit-engine
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
2. **Usage:**
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
import { Chat, Management, ChatModal } from '@burtson-labs/bandit-engine';
|
|
415
|
+
import { defineCustomElement } from '@burtson-labs/bandit-engine';
|
|
416
|
+
|
|
417
|
+
customElements.define('bandit-chat', defineCustomElement(Chat));
|
|
418
|
+
customElements.define('bandit-management', defineCustomElement(Management));
|
|
419
|
+
customElements.define('bandit-modal', defineCustomElement(ChatModal));
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
These components can now be used in your templates inside a `<bandit-chat-provider>` block.
|
|
423
|
+
|
|
424
|
+
Usage in HTML:
|
|
425
|
+
|
|
426
|
+
```html
|
|
427
|
+
<bandit-chat-provider
|
|
428
|
+
packageSettings='{"ollamaUrl":"https://your-ollama-url.com","defaultModel":"Bandit-Core","brandingConfigUrl":"https://cdn.burtson.ai/configs/default-config.json"}'
|
|
429
|
+
>
|
|
430
|
+
<bandit-chat></bandit-chat>
|
|
431
|
+
<bandit-management></bandit-management>
|
|
432
|
+
<bandit-modal></bandit-modal>
|
|
433
|
+
</bandit-chat-provider>
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Note: You only need to define the elements you intend to use. Don't mount all components on the same page. Use `<bandit-management>` for secure admin routes and `<bandit-modal>` for contextual triggers.
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## βοΈ Vue.js Integration (Experimental)
|
|
441
|
+
|
|
442
|
+
To use Bandit Engine in a Vue 3 project:
|
|
443
|
+
|
|
444
|
+
1. Install the package:
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
npm install @burtson-labs/bandit-engine
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
2. **Usage:**
|
|
451
|
+
|
|
452
|
+
```ts
|
|
453
|
+
import { Chat, Management, ChatModal } from '@burtson-labs/bandit-engine';
|
|
454
|
+
import { defineCustomElement } from '@burtson-labs/bandit-engine';
|
|
455
|
+
|
|
456
|
+
customElements.define('bandit-chat', defineCustomElement(Chat));
|
|
457
|
+
customElements.define('bandit-management', defineCustomElement(Management));
|
|
458
|
+
customElements.define('bandit-modal', defineCustomElement(ChatModal));
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
These components can now be used in your templates inside a `<bandit-chat-provider>` block.
|
|
462
|
+
|
|
463
|
+
Usage in HTML:
|
|
464
|
+
|
|
465
|
+
```html
|
|
466
|
+
<bandit-chat-provider
|
|
467
|
+
packageSettings='{"ollamaUrl":"https://your-ollama-url.com","defaultModel":"Bandit-Core","brandingConfigUrl":"https://cdn.burtson.ai/configs/default-config.json"}'
|
|
468
|
+
>
|
|
469
|
+
<bandit-chat></bandit-chat>
|
|
470
|
+
<bandit-management></bandit-management>
|
|
471
|
+
<bandit-modal></bandit-modal>
|
|
472
|
+
</bandit-chat-provider>
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Note: You only need to define the elements you intend to use. Don't mount all components on the same page. Use `<bandit-management>` for secure admin routes and `<bandit-modal>` for contextual triggers.
|
|
476
|
+
|
|
477
|
+
> `defineCustomElement` allows usage in Vue and Angular apps via native Web Components, making Bandit fully framework-agnostic.
|
|
478
|
+
|
|
479
|
+
> π Similar to Angular, when using `<Management />` or `<ChatModal />`, wrap each one with a `<bandit-chat-provider>` to ensure proper context injection.
|
|
480
|
+
|
|
481
|
+
> Make sure `packageSettings` is passed as a serialized JSON string when using with HTML-based custom elements.
|
|
482
|
+
|
|
483
|
+
> 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.
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## π¦ Custom Element Support
|
|
488
|
+
|
|
489
|
+
To use Bandit components (`Chat`, `Management`, `ChatModal`) in any modern JS framework (Angular, Vue, Svelte, etc.), you can register them as native custom elements:
|
|
490
|
+
|
|
491
|
+
```ts
|
|
492
|
+
import { defineCustomElement } from '@burtson-labs/bandit-engine';
|
|
493
|
+
|
|
494
|
+
const BanditModal = defineCustomElement('ChatModal');
|
|
495
|
+
customElements.define('bandit-modal', BanditModal);
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Wrap it in `<bandit-chat-provider>` and youβre ready to go. Ideal for environments where React isnβt used directly.
|
|
499
|
+
|
|
500
|
+
> π§ **Note for Non-React Users:**
|
|
501
|
+
> 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.
|
|
502
|
+
|
|
503
|
+
To create custom elements, you must import the React components and pass them to `defineCustomElement`. For example:
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
import { ChatModal } from '@burtson-labs/bandit-engine';
|
|
507
|
+
import { defineCustomElement } from '@burtson-labs/bandit-engine';
|
|
508
|
+
customElements.define('bandit-modal', defineCustomElement(ChatModal));
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## πΈ Live Preview
|
|
514
|
+
|
|
515
|
+
Here are some screenshots of Bandit Chat in action:
|
|
516
|
+
|
|
517
|
+
**Chat Demo β Your AI-powered UI**
|
|
518
|
+
<p align="center">
|
|
519
|
+
<img src="./public/images/chat-demo.jpg" alt="Bandit chat session showing multi-turn conversation with inline actions" width="600" />
|
|
520
|
+
</p>
|
|
521
|
+
|
|
522
|
+
**Conversation Drawer & Project Context**
|
|
523
|
+
<p align="center">
|
|
524
|
+
<img src="./public/images/chat-demo-2.jpg" alt="Chat drawer open with projects list and answered question" width="600" />
|
|
525
|
+
</p>
|
|
526
|
+
|
|
527
|
+
**Chat Modal β Quick Assist Anywhere**
|
|
528
|
+
<p align="center">
|
|
529
|
+
<img src="./public/images/chat-modal.jpg" alt="Chat modal with control center options and message composer" width="600" />
|
|
530
|
+
</p>
|
|
531
|
+
|
|
532
|
+
**Management β Branding Controls**
|
|
533
|
+
<p align="center">
|
|
534
|
+
<img src="./public/images/mgmt-branding.jpg" alt="Management interface branding tab showing logo and color options" width="600" />
|
|
535
|
+
</p>
|
|
536
|
+
|
|
537
|
+
**Management β Personas**
|
|
538
|
+
<p align="center">
|
|
539
|
+
<img src="./public/images/mgmt-personalities.jpg" alt="Management interface personas tab with configurable AI personalities" width="600" />
|
|
540
|
+
</p>
|
|
541
|
+
|
|
542
|
+
**Management β Preferences**
|
|
543
|
+
<p align="center">
|
|
544
|
+
<img src="./public/images/mgmt-preferences.jpg" alt="Management interface preferences tab with feature toggles" width="600" />
|
|
545
|
+
</p>
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
4. **π CDN-Based Config (Optional)**
|
|
549
|
+
|
|
550
|
+
To streamline configuration, you can host your `config.json` (and related assets like model presets or branding) via your own CDN or edge cache.
|
|
551
|
+
|
|
552
|
+
Update the `brandingConfigUrl` like this:
|
|
553
|
+
|
|
554
|
+
```tsx
|
|
555
|
+
<ChatProvider
|
|
556
|
+
packageSettings={{
|
|
557
|
+
...chatPackageSettings,
|
|
558
|
+
brandingConfigUrl: "https://cdn.burtson.ai/configs/default-config.json"
|
|
559
|
+
}}
|
|
560
|
+
>
|
|
561
|
+
<App />
|
|
562
|
+
</ChatProvider>
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
This enables remote control of Bandit appearance, available models, and more β without redeploying your frontend.
|
|
566
|
+
|
|
567
|
+
> βΉοΈ Note: All CDN assets such as logos, avatars, config, and workers are available at `https://cdn.burtson.ai/`. You may override these by hosting your own versions and pointing `packageSettings` to the appropriate URLs.
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
## βοΈ Configuration Options
|
|
572
|
+
- `defaultModel`: Primary chat model (string; required)
|
|
573
|
+
- `fallbackModel`: Optional fallback model if the default is unavailable
|
|
574
|
+
- `gatewayApiUrl`: Gateway API base URL for AI, TTS, STT, and MCP
|
|
575
|
+
- `aiProvider`: Provider configuration object (recommended for new installs)
|
|
576
|
+
- `ollamaUrl`: Legacy Ollama base URL (deprecated, prefer `aiProvider`)
|
|
577
|
+
- `s3ApiUrl`: Optional file storage API base URL (defaults to `gatewayApiUrl`)
|
|
578
|
+
- `brandingConfigUrl`: Hosted branding JSON used to hydrate UI theming
|
|
579
|
+
- `homeUrl`: Optional URL for the home button in management UI
|
|
580
|
+
- `feedbackEmail`: Optional email address for feedback submissions
|
|
581
|
+
- `featureFlags`: Optional feature flag configuration (see examples below)
|
|
582
|
+
|
|
583
|
+
## π€ AI Provider System
|
|
584
|
+
|
|
585
|
+
Bandit Engine features a unified, gateway-based AI provider architecture that supports multiple AI services through a secure backend:
|
|
586
|
+
|
|
587
|
+
### Supported Providers
|
|
588
|
+
|
|
589
|
+
- **π Gateway Provider** (Recommended): Routes all requests through your secure .NET 9 backend
|
|
590
|
+
- **Ollama**: Self-hosted models and Ollama-compatible endpoints
|
|
591
|
+
- **OpenAI**: GPT models via OpenAI API
|
|
592
|
+
- **Azure OpenAI**: Azure-hosted OpenAI models
|
|
593
|
+
- **Anthropic**: Claude models via Anthropic API
|
|
594
|
+
|
|
595
|
+
### Gateway Provider (Recommended)
|
|
596
|
+
|
|
597
|
+
The gateway provider offers the most secure and scalable approach by routing all requests through your backend API:
|
|
598
|
+
|
|
599
|
+
```tsx
|
|
600
|
+
const chatPackageSettings = {
|
|
601
|
+
// Gateway provider configuration
|
|
602
|
+
aiProvider: {
|
|
603
|
+
type: "gateway" as const,
|
|
604
|
+
gatewayUrl: "https://your-gateway-api.example.com",
|
|
605
|
+
provider: "openai" // Backend provider: openai, azure-openai, anthropic, ollama
|
|
606
|
+
},
|
|
607
|
+
// ... other settings
|
|
608
|
+
};
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
**Benefits:**
|
|
612
|
+
- π **Security**: API keys stay on your server
|
|
613
|
+
- π **Monitoring**: Request logging and usage analytics
|
|
614
|
+
- π¦ **Rate Limiting**: Built-in throttling and quotas
|
|
615
|
+
- π **Provider Switching**: Change backends without frontend updates
|
|
616
|
+
- π‘οΈ **Authentication**: Unified auth across all AI services
|
|
617
|
+
|
|
618
|
+
**Gateway Requirements:**
|
|
619
|
+
Your gateway API can be built with any technology (Node.js, Python, .NET, Java, etc.) as long as it implements:
|
|
620
|
+
- `GET /api/health` - Health check endpoint
|
|
621
|
+
- `POST /api/chat/completions` - Chat completions with provider in request body
|
|
622
|
+
- `POST /api/generate` - Text generation with provider in request body
|
|
623
|
+
|
|
624
|
+
### Legacy Direct Providers
|
|
625
|
+
|
|
626
|
+
Direct providers are still supported but marked as deprecated for production use:
|
|
627
|
+
|
|
628
|
+
```tsx
|
|
629
|
+
// β οΈ Deprecated: Direct OpenAI (exposes API keys)
|
|
630
|
+
aiProvider: {
|
|
631
|
+
type: "openai",
|
|
632
|
+
apiKey: "sk-...", // Exposed in frontend
|
|
633
|
+
baseUrl: "https://api.openai.com/v1"
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// β οΈ Deprecated: Direct Ollama (no auth/monitoring)
|
|
637
|
+
aiProvider: {
|
|
638
|
+
type: "ollama",
|
|
639
|
+
baseUrl: "http://localhost:11434"
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
### Migration to Gateway
|
|
644
|
+
|
|
645
|
+
1. **Deploy Gateway Backend**: Set up your .NET 9 gateway service
|
|
646
|
+
2. **Update Configuration**: Switch from direct to gateway provider
|
|
647
|
+
3. **Test Connection**: Use the Management interface to validate
|
|
648
|
+
4. **Update API Keys**: Move keys from frontend to backend config
|
|
649
|
+
|
|
650
|
+
See `GATEWAY_MIGRATION_GUIDE.md` for detailed migration steps.
|
|
651
|
+
|
|
652
|
+
### Image/Multimodal Support
|
|
653
|
+
|
|
654
|
+
The Bandit Engine provides comprehensive image support across all AI providers through the gateway architecture:
|
|
655
|
+
|
|
656
|
+
**Supported Providers & Models:**
|
|
657
|
+
- **Ollama**: `llava`, `llava:13b`, `bakllava`, `llava-phi3`
|
|
658
|
+
- **OpenAI**: `gpt-4-vision-preview`, `gpt-4o`, `gpt-4o-mini`
|
|
659
|
+
- **Azure OpenAI**: `gpt-4-vision-preview` (deployed models)
|
|
660
|
+
- **Anthropic**: `claude-3-opus`, `claude-3-sonnet`, `claude-3-haiku`
|
|
661
|
+
|
|
662
|
+
**Key Features:**
|
|
663
|
+
- πΌοΈ **Universal Image Input**: Drop, paste, or upload images directly in chat
|
|
664
|
+
- π **Provider-Specific Formatting**: Automatic conversion to each provider's image format
|
|
665
|
+
- π± **Multi-Image Support**: Send multiple images in a single message
|
|
666
|
+
- π― **Vision Models**: Seamless integration with multimodal AI models
|
|
667
|
+
|
|
668
|
+
**Usage Example:**
|
|
669
|
+
```tsx
|
|
670
|
+
// Images are automatically handled by the chat interface
|
|
671
|
+
// Users can:
|
|
672
|
+
// 1. Drag & drop images into the chat input
|
|
673
|
+
// 2. Paste images from clipboard (Ctrl+V / Cmd+V)
|
|
674
|
+
// 3. Use the attach button to select image files
|
|
675
|
+
// 4. Ask questions about the images naturally
|
|
676
|
+
|
|
677
|
+
// The gateway provider automatically formats images correctly:
|
|
678
|
+
// - Ollama: base64 arrays in message.images
|
|
679
|
+
// - OpenAI/Azure/Anthropic: structured content with image_url objects
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
**Backend Requirements:**
|
|
683
|
+
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.
|
|
684
|
+
|
|
685
|
+
```javascript
|
|
686
|
+
// Example: Gateway forwards images as-is to each provider
|
|
687
|
+
app.post('/api/chat/completions', async (req, res) => {
|
|
688
|
+
const { provider, messages, ...options } = req.body;
|
|
689
|
+
|
|
690
|
+
// Messages already contain properly formatted images
|
|
691
|
+
// Forward directly to the target provider API
|
|
692
|
+
switch (provider) {
|
|
693
|
+
case 'ollama':
|
|
694
|
+
// messages[].images format (base64 arrays)
|
|
695
|
+
return await ollamaClient.chat({ messages, ...options });
|
|
696
|
+
case 'openai':
|
|
697
|
+
// messages[].content[].image_url format (structured)
|
|
698
|
+
return await openaiClient.chat.completions.create({ messages, ...options });
|
|
699
|
+
default:
|
|
700
|
+
throw new Error(`Unsupported provider: ${provider}`);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
### Using the AI Provider
|
|
706
|
+
|
|
707
|
+
All chat interactions use the unified provider system regardless of backend:
|
|
708
|
+
|
|
709
|
+
```tsx
|
|
710
|
+
import { useAIProvider } from '@burtson-labs/bandit-engine';
|
|
711
|
+
|
|
712
|
+
function MyComponent() {
|
|
713
|
+
const { generateResponse, isLoading } = useAIProvider();
|
|
714
|
+
|
|
715
|
+
const handleChat = async (message: string) => {
|
|
716
|
+
const response = await generateResponse(message);
|
|
717
|
+
console.log(response);
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
## π§ Model Context Protocol (MCP) Integration
|
|
723
|
+
|
|
724
|
+
Bandit Engine now supports **Model Context Protocol (MCP)** for extending AI capabilities with external tools and services:
|
|
725
|
+
|
|
726
|
+
### MCP Features
|
|
727
|
+
- **Tool Integration**: Connect external APIs and services to your AI conversations
|
|
728
|
+
- **Dynamic Tool Discovery**: Automatically detect and configure available MCP tools
|
|
729
|
+
- **Secure Execution**: All MCP tool calls go through your gateway API with proper authentication
|
|
730
|
+
- **Real-time Updates**: Tools can be enabled/disabled without restarting the application
|
|
731
|
+
|
|
732
|
+
### Using MCP Tools
|
|
733
|
+
|
|
734
|
+
MCP tools are automatically available in chat conversations when configured:
|
|
735
|
+
|
|
736
|
+
```tsx
|
|
737
|
+
// MCP tools are managed through the store
|
|
738
|
+
import { useMCPToolsStore } from '@burtson-labs/bandit-engine';
|
|
739
|
+
|
|
740
|
+
function MCPManager() {
|
|
741
|
+
const { tools, toggleTool, getEnabledTools } = useMCPToolsStore();
|
|
742
|
+
|
|
743
|
+
// Enable/disable tools
|
|
744
|
+
const handleToggle = (toolId: string) => {
|
|
745
|
+
toggleTool(toolId);
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
// Get currently enabled tools
|
|
749
|
+
const enabledTools = getEnabledTools();
|
|
750
|
+
}
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
### MCP Tool Configuration
|
|
754
|
+
|
|
755
|
+
Tools are configured through your gateway API and automatically discovered by the engine:
|
|
756
|
+
|
|
757
|
+
```json
|
|
758
|
+
{
|
|
759
|
+
"function": {
|
|
760
|
+
"name": "search_web",
|
|
761
|
+
"description": "Search the web for current information",
|
|
762
|
+
"parameters": {
|
|
763
|
+
"type": "object",
|
|
764
|
+
"properties": {
|
|
765
|
+
"query": {
|
|
766
|
+
"type": "string",
|
|
767
|
+
"description": "Search query"
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
"endpoint": "/mcp/search",
|
|
773
|
+
"method": "POST",
|
|
774
|
+
"enabled": true
|
|
775
|
+
}
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
### MCP Service API
|
|
779
|
+
|
|
780
|
+
For advanced usage, you can directly execute MCP tools:
|
|
781
|
+
|
|
782
|
+
```tsx
|
|
783
|
+
import { executeMCPTool, isMCPAvailable } from '@burtson-labs/bandit-engine';
|
|
784
|
+
|
|
785
|
+
// Check if MCP is available
|
|
786
|
+
if (isMCPAvailable()) {
|
|
787
|
+
// Execute a tool
|
|
788
|
+
const result = await executeMCPTool({
|
|
789
|
+
toolName: "search_web",
|
|
790
|
+
parameters: { query: "latest AI news" }
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
if (result.success) {
|
|
794
|
+
console.log(result.data);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
---
|
|
800
|
+
|
|
801
|
+
## ποΈ Feature Flags & Subscription Tiers
|
|
802
|
+
|
|
803
|
+
Bandit Engine includes a comprehensive **tier-based feature flag system** that enables subscription-based access control and feature gating:
|
|
804
|
+
|
|
805
|
+
### Subscription Tiers
|
|
806
|
+
|
|
807
|
+
The engine supports multiple subscription tiers with different feature access levels:
|
|
808
|
+
|
|
809
|
+
- **Basic**: Core chat functionality with limitations
|
|
810
|
+
- **Premium**: Enhanced features and higher limits
|
|
811
|
+
- **Pro**: Advanced features for power users
|
|
812
|
+
- **Team**: Collaboration features and team management
|
|
813
|
+
- **Trial**: Temporary access with premium features
|
|
814
|
+
- **Expired**: Limited access for expired subscriptions
|
|
815
|
+
|
|
816
|
+
### Feature Flag Configuration
|
|
817
|
+
|
|
818
|
+
Configure feature flags in your package settings:
|
|
819
|
+
|
|
820
|
+
```tsx
|
|
821
|
+
const chatPackageSettings = {
|
|
822
|
+
// ... other settings
|
|
823
|
+
featureFlags: {
|
|
824
|
+
// Default tier (fallback when no JWT subscription info available)
|
|
825
|
+
subscriptionType: "premium", // basic | premium | pro | team | trial
|
|
826
|
+
|
|
827
|
+
// JWT claim configuration for authentication
|
|
828
|
+
rolesClaimKey: "roles", // JWT claim key for user roles
|
|
829
|
+
subscriptionTypeClaimKey: "subscriptionType", // JWT claim for subscription type
|
|
830
|
+
isSubscribedClaimKey: "isSubscribed", // JWT claim for subscription status
|
|
831
|
+
jwtStorageKey: "authToken", // Local storage key for JWT token
|
|
832
|
+
adminRole: "admin", // Admin role name for elevated access
|
|
833
|
+
|
|
834
|
+
// Development settings
|
|
835
|
+
debug: process.env.NODE_ENV === "development", // Enable debug logging
|
|
836
|
+
|
|
837
|
+
// Optional: Override specific features
|
|
838
|
+
featureMatrix: {
|
|
839
|
+
tts: true, // Enable/disable Text-to-Speech
|
|
840
|
+
stt: true, // Enable/disable Speech-to-Text
|
|
841
|
+
// ... other feature overrides
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
### Tier-Based Feature Matrix
|
|
848
|
+
|
|
849
|
+
Different subscription tiers have access to different features:
|
|
850
|
+
|
|
851
|
+
| Feature | Basic | Premium | Pro | Team | Trial |
|
|
852
|
+
|---------|-------|---------|-----|------|-------|
|
|
853
|
+
| **Core Chat** | β
| β
| β
| β
| β
|
|
|
854
|
+
| **Text-to-Speech** | β | β
| β
| β
| β
|
|
|
855
|
+
| **Speech-to-Text** | β | β
| β
| β
| β
|
|
|
856
|
+
| **Document Upload** | β | β
| β
| β
| β
|
|
|
857
|
+
| **Model Management** | β | β | β
| β
| β |
|
|
858
|
+
| **Admin Dashboard** | β | β | β
| β
| β |
|
|
859
|
+
| **API Access** | β | β | β
| β
| β |
|
|
860
|
+
| **Team Collaboration** | β | β | β | β
| β |
|
|
861
|
+
| **Custom Branding** | β | β | β | β
| β |
|
|
862
|
+
|
|
863
|
+
### JWT-Based Authentication
|
|
864
|
+
|
|
865
|
+
The feature flag system integrates with JWT tokens for dynamic subscription management:
|
|
866
|
+
|
|
867
|
+
```tsx
|
|
868
|
+
// Example JWT payload structure
|
|
869
|
+
{
|
|
870
|
+
"sub": "user123",
|
|
871
|
+
"subscriptionType": "pro", // Controls tier access
|
|
872
|
+
"isSubscribed": true, // Overall subscription status
|
|
873
|
+
"roles": ["user", "admin"], // User roles for admin features
|
|
874
|
+
"exp": 1640995200
|
|
875
|
+
}
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
### Using Feature Flags in Components
|
|
879
|
+
|
|
880
|
+
Access feature flags throughout your application:
|
|
881
|
+
|
|
882
|
+
```tsx
|
|
883
|
+
import { useFeatureFlags } from '@burtson-labs/bandit-engine';
|
|
884
|
+
|
|
885
|
+
function MyComponent() {
|
|
886
|
+
const {
|
|
887
|
+
hasFeature,
|
|
888
|
+
currentTier,
|
|
889
|
+
isAdmin,
|
|
890
|
+
isSubscribed
|
|
891
|
+
} = useFeatureFlags();
|
|
892
|
+
|
|
893
|
+
// Check specific features
|
|
894
|
+
if (hasFeature('tts')) {
|
|
895
|
+
// Show text-to-speech controls
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// Check subscription tier
|
|
899
|
+
if (currentTier === 'pro' || currentTier === 'team') {
|
|
900
|
+
// Show advanced features
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// Check admin access
|
|
904
|
+
if (isAdmin) {
|
|
905
|
+
// Show admin controls
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
### Subscription State Management
|
|
911
|
+
|
|
912
|
+
The engine automatically handles subscription state changes:
|
|
913
|
+
|
|
914
|
+
```tsx
|
|
915
|
+
import { useAuthenticationStore } from '@burtson-labs/bandit-engine';
|
|
916
|
+
|
|
917
|
+
function SubscriptionManager() {
|
|
918
|
+
const {
|
|
919
|
+
subscriptionType,
|
|
920
|
+
isSubscribed,
|
|
921
|
+
refreshSubscription
|
|
922
|
+
} = useAuthenticationStore();
|
|
923
|
+
|
|
924
|
+
// Handle subscription upgrades
|
|
925
|
+
const handleUpgrade = async () => {
|
|
926
|
+
// After successful payment processing
|
|
927
|
+
await refreshSubscription(); // Reload JWT and feature access
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
// Display upgrade prompts for limited features
|
|
931
|
+
if (!isSubscribed && attemptedRestrictedFeature) {
|
|
932
|
+
return <UpgradePrompt />;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
### Feature Restrictions & Upgrade Prompts
|
|
938
|
+
|
|
939
|
+
The engine automatically shows upgrade prompts when users try to access restricted features:
|
|
940
|
+
|
|
941
|
+
- **Graceful Degradation**: Features are hidden or disabled based on subscription tier
|
|
942
|
+
- **Upgrade Prompts**: Users see contextual upgrade suggestions when attempting restricted actions
|
|
943
|
+
- **Real-time Updates**: Subscription changes take effect immediately without app restart
|
|
944
|
+
|
|
945
|
+
### Development & Testing
|
|
946
|
+
|
|
947
|
+
For development and testing environments:
|
|
948
|
+
|
|
949
|
+
```tsx
|
|
950
|
+
// Override subscription tier for testing
|
|
951
|
+
const devSettings = {
|
|
952
|
+
featureFlags: {
|
|
953
|
+
subscriptionType: "team", // Test with highest tier
|
|
954
|
+
debug: true, // Enable detailed logging
|
|
955
|
+
featureMatrix: {
|
|
956
|
+
// Force enable specific features for testing
|
|
957
|
+
experimentalFeature: true,
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
### Backend Integration
|
|
964
|
+
|
|
965
|
+
Your gateway API should validate subscription tiers and return appropriate feature access:
|
|
966
|
+
|
|
967
|
+
```javascript
|
|
968
|
+
// Example: Gateway API subscription validation
|
|
969
|
+
app.post('/api/chat/completions', authenticateJWT, async (req, res) => {
|
|
970
|
+
const { subscriptionType, isSubscribed } = req.user;
|
|
971
|
+
|
|
972
|
+
// Validate tier access for requested features
|
|
973
|
+
if (req.body.tts && !hasFeature(subscriptionType, 'tts')) {
|
|
974
|
+
return res.status(403).json({
|
|
975
|
+
error: 'TTS requires Premium subscription or higher'
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// Proceed with AI request
|
|
980
|
+
const response = await processAIRequest(req.body);
|
|
981
|
+
res.json(response);
|
|
982
|
+
});
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
This feature flag system enables you to build sophisticated subscription-based AI products with fine-grained access control and seamless upgrade flows.
|
|
986
|
+
|
|
987
|
+
---
|
|
988
|
+
|
|
989
|
+
## π Debug Logger
|
|
990
|
+
|
|
991
|
+
Bandit Engine exports a debug logger for consistent logging across your application:
|
|
992
|
+
|
|
993
|
+
```tsx
|
|
994
|
+
import { debugLogger } from '@burtson-labs/bandit-engine';
|
|
995
|
+
|
|
996
|
+
// Use instead of console.log/warn/error
|
|
997
|
+
debugLogger.info('Chat message sent');
|
|
998
|
+
debugLogger.warn('Fallback model used');
|
|
999
|
+
debugLogger.error('Failed to connect to AI service');
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
## π Security Best Practices
|
|
1003
|
+
|
|
1004
|
+
**β οΈ Important Security Notice:**
|
|
1005
|
+
|
|
1006
|
+
While Bandit Engine supports direct API key configuration for development and testing, **we strongly recommend against using API keys directly in frontend applications** for production environments.
|
|
1007
|
+
|
|
1008
|
+
### Recommended Architecture
|
|
1009
|
+
|
|
1010
|
+
1. **Use an API Gateway/Wrapper**: Deploy the OllamaGateway (soon to be renamed AiGateway) or similar backend service
|
|
1011
|
+
2. **Proxy AI Requests**: Route all AI requests through your secure backend
|
|
1012
|
+
3. **Environment Isolation**: Keep API keys and sensitive configuration on the server side
|
|
1013
|
+
4. **Authentication**: Implement proper user authentication and request validation
|
|
1014
|
+
|
|
1015
|
+
### Gateway Setup
|
|
1016
|
+
|
|
1017
|
+
The recommended approach is to use a gateway service that:
|
|
1018
|
+
- Handles API key management securely
|
|
1019
|
+
- Provides rate limiting and usage tracking
|
|
1020
|
+
- Exposes standardized endpoints for AI, TTS, and STT services
|
|
1021
|
+
- Manages provider switching and fallback logic
|
|
1022
|
+
- **Technology-agnostic**: Works with any backend implementation
|
|
1023
|
+
|
|
1024
|
+
```tsx
|
|
1025
|
+
// Recommended: Use gateway with unified API
|
|
1026
|
+
const chatPackageSettings = {
|
|
1027
|
+
aiProvider: {
|
|
1028
|
+
type: "gateway",
|
|
1029
|
+
gatewayUrl: "https://your-api-gateway.com",
|
|
1030
|
+
provider: "openai" // or "anthropic", "azure-openai", "ollama"
|
|
1031
|
+
},
|
|
1032
|
+
gatewayApiUrl: "https://your-api-gateway.com", // Same URL for TTS/STT services
|
|
1033
|
+
// No API keys in frontend code
|
|
1034
|
+
// ... other settings
|
|
1035
|
+
};
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
### Legacy Configuration (Deprecated)
|
|
1039
|
+
|
|
1040
|
+
β οΈ **Legacy TTS/STT URLs are deprecated.** Use the unified `gatewayApiUrl` instead:
|
|
1041
|
+
|
|
1042
|
+
```tsx
|
|
1043
|
+
// β Deprecated (still works but not recommended)
|
|
1044
|
+
const oldSettings = {
|
|
1045
|
+
ttsUrl: "/api/tts",
|
|
1046
|
+
sttUrl: "/api/stt",
|
|
1047
|
+
ollamaUrl: "http://localhost:11434",
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
// β
Recommended (unified gateway approach)
|
|
1051
|
+
const newSettings = {
|
|
1052
|
+
aiProvider: { type: "gateway", gatewayUrl: "https://your-gateway.com", provider: "openai" },
|
|
1053
|
+
gatewayApiUrl: "https://your-gateway.com", // Handles TTS, STT, and MCP
|
|
1054
|
+
};
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
### Development vs Production
|
|
1058
|
+
|
|
1059
|
+
- **Development**: Direct provider API keys are acceptable for local testing
|
|
1060
|
+
- **Production**: Always use a gateway/wrapper service to protect sensitive credentials
|
|
1061
|
+
|
|
1062
|
+
## Requirements
|
|
1063
|
+
|
|
1064
|
+
### Gateway API Services
|
|
1065
|
+
|
|
1066
|
+
The Bandit Engine uses a **unified gateway approach** for all backend services. Your gateway API should implement these endpoints:
|
|
1067
|
+
|
|
1068
|
+
**Core AI Services:**
|
|
1069
|
+
- `GET /api/health` - Health check and service discovery
|
|
1070
|
+
- `POST /api/chat/completions` - Chat completions (OpenAI format)
|
|
1071
|
+
- `POST /api/generate` - Text generation
|
|
1072
|
+
- Provider-specific routing (automatically handled)
|
|
1073
|
+
|
|
1074
|
+
**Voice Services (Optional):**
|
|
1075
|
+
- `POST /api/tts` - Text-to-Speech conversion
|
|
1076
|
+
- Input: `{ text: string, voice?: string, speed?: number }`
|
|
1077
|
+
- Output: Audio file or streaming audio
|
|
1078
|
+
- **Technology-agnostic**: Works with OpenAI TTS, Azure Speech, Google TTS, AWS Polly, Whisper.cpp, or custom implementations
|
|
1079
|
+
|
|
1080
|
+
- `POST /api/stt` - Speech-to-Text transcription
|
|
1081
|
+
- Input: Audio file upload (multipart/form-data)
|
|
1082
|
+
- Output: `{ text: string }` or `{ transcription: string }`
|
|
1083
|
+
- **Technology-agnostic**: Works with OpenAI Whisper, Azure Speech, Google Speech, AWS Transcribe, local Whisper, or custom implementations
|
|
1084
|
+
|
|
1085
|
+
- `GET /api/tts/available-models` - Voice model discovery
|
|
1086
|
+
- Output: `{ models: string[], defaultModel: string, fallbackModel: string }`
|
|
1087
|
+
- Used for automatic service availability detection
|
|
1088
|
+
|
|
1089
|
+
**MCP Services (Optional):**
|
|
1090
|
+
- Model Context Protocol endpoints for tool integration
|
|
1091
|
+
|
|
1092
|
+
### Technology-Agnostic Implementation
|
|
1093
|
+
|
|
1094
|
+
Your gateway can be implemented in **any language or framework**:
|
|
1095
|
+
- **Node.js/Express**, **Python/FastAPI**, **.NET Core**, **Java/Spring**
|
|
1096
|
+
- **PHP/Laravel**, **Ruby on Rails**, **Go/Gin**, **Rust/Axum**
|
|
1097
|
+
- **Serverless** (AWS Lambda, Vercel Functions, Cloudflare Workers)
|
|
1098
|
+
|
|
1099
|
+
The Bandit Engine only requires that your endpoints follow the expected input/output contracts. The underlying implementation is completely flexible.
|
|
1100
|
+
|
|
1101
|
+
### Additional Resources
|
|
1102
|
+
|
|
1103
|
+
- **PDF Worker**: For document embedding features, the engine uses the PDF parsing worker from `https://cdn.burtson.ai/scripts/pdf.worker.js`
|
|
1104
|
+
- **CDN Resources**: Default avatars, logos, and configurations load from `https://cdn.burtson.ai/` if not overridden locally
|
|
1105
|
+
|
|
1106
|
+
## π‘ Vision & Roadmap
|
|
1107
|
+
|
|
1108
|
+
Bandit Engine isn't just a component β it's a foundation. Coming soon:
|
|
1109
|
+
- Multi-modal input: image, voice, document uploads
|
|
1110
|
+
- Agentic flow support with visualized cards and suggestions
|
|
1111
|
+
- Pluggable memory and long-term knowledge
|
|
1112
|
+
- Customizable avatars and real-time voice playback
|
|
1113
|
+
- Client-defined RAG and embedding search
|
|
1114
|
+
|
|
1115
|
+
Weβre building this to be the interface layer of your AI-first products. Own the UX. Own the brand. Own the experience.
|
|
1116
|
+
|
|
1117
|
+
---
|
|
1118
|
+
|
|
1119
|
+
## π Migration Guide
|
|
1120
|
+
|
|
1121
|
+
### From Legacy TTS/STT URLs to Gateway API
|
|
1122
|
+
|
|
1123
|
+
If you're currently using separate `ttsUrl` and `sttUrl` settings, migrate to the unified gateway approach:
|
|
1124
|
+
|
|
1125
|
+
**Before (Deprecated):**
|
|
1126
|
+
```tsx
|
|
1127
|
+
const settings = {
|
|
1128
|
+
ttsUrl: "https://your-tts-service.com/api/tts",
|
|
1129
|
+
sttUrl: "https://your-stt-service.com/api/stt",
|
|
1130
|
+
ollamaUrl: "https://your-ollama.com",
|
|
1131
|
+
};
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
**After (Recommended):**
|
|
1135
|
+
```tsx
|
|
1136
|
+
const settings = {
|
|
1137
|
+
aiProvider: {
|
|
1138
|
+
type: "gateway",
|
|
1139
|
+
gatewayUrl: "https://your-gateway.com",
|
|
1140
|
+
provider: "openai"
|
|
1141
|
+
},
|
|
1142
|
+
gatewayApiUrl: "https://your-gateway.com", // Unified endpoint for all services
|
|
1143
|
+
};
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
The new approach provides:
|
|
1147
|
+
- β
**Unified API**: One endpoint for all services
|
|
1148
|
+
- β
**Better Security**: Centralized authentication and rate limiting
|
|
1149
|
+
- β
**Technology Flexibility**: Use any backend implementation
|
|
1150
|
+
- β
**Automatic Discovery**: Real-time service availability detection
|
|
1151
|
+
|
|
1152
|
+
---
|
|
1153
|
+
|
|
1154
|
+
## π‘οΈ License & Protection
|
|
1155
|
+
|
|
1156
|
+
This software is protected under the **Business Source License (BUSL) 1.1** by Burtson Labs LLC.
|
|
1157
|
+
|
|
1158
|
+
### βοΈ License Summary
|
|
1159
|
+
|
|
1160
|
+
- β
**Development & Evaluation**: Free for internal development, testing, and evaluation
|
|
1161
|
+
- β
**Non-Commercial Use**: Free for educational, research, and personal projects
|
|
1162
|
+
- β **Commercial Production**: Requires commercial license for production deployment
|
|
1163
|
+
- β **Competitive Use**: Cannot be used to create competing AI chat products
|
|
1164
|
+
- β **AI Training**: Cannot be used as training data for AI models
|
|
1165
|
+
|
|
1166
|
+
### π Usage Rights
|
|
1167
|
+
|
|
1168
|
+
**Permitted:**
|
|
1169
|
+
- Internal development and testing
|
|
1170
|
+
- Educational and research purposes
|
|
1171
|
+
- Evaluation for potential commercial licensing
|
|
1172
|
+
- Contributions back to the project (under same license)
|
|
1173
|
+
|
|
1174
|
+
**Prohibited:**
|
|
1175
|
+
- Production use without commercial license
|
|
1176
|
+
- Creating derivative commercial products
|
|
1177
|
+
- Using as training data for AI/ML models
|
|
1178
|
+
- Removing or modifying license notices and watermarks
|
|
1179
|
+
|
|
1180
|
+
### π Protection Features
|
|
1181
|
+
|
|
1182
|
+
This codebase includes multiple protection layers:
|
|
1183
|
+
- **Embedded Watermarks**: Visible and stealth fingerprints in all source files
|
|
1184
|
+
- **Audit Trails**: Usage tracking and compliance monitoring
|
|
1185
|
+
- **License Validation**: Runtime checks for compliance
|
|
1186
|
+
- **Honey Pot Files**: Trap files that trigger license violations when accessed
|
|
1187
|
+
|
|
1188
|
+
**β οΈ Warning**: Removing, modifying, or bypassing these protection mechanisms constitutes a license violation and may result in immediate license termination.
|
|
1189
|
+
|
|
1190
|
+
### πΌ Commercial Licensing
|
|
1191
|
+
|
|
1192
|
+
**Production License**: Required for commercial deployment
|
|
1193
|
+
- Full production rights
|
|
1194
|
+
- Priority support and maintenance
|
|
1195
|
+
- Custom integrations and features
|
|
1196
|
+
- Enterprise SLA options
|
|
1197
|
+
|
|
1198
|
+
**Contact for Licensing:**
|
|
1199
|
+
- **Email**: legal@burtson.ai
|
|
1200
|
+
- **Website**: https://burtson.ai/license
|
|
1201
|
+
- **Sales**: sales@burtson.ai
|
|
1202
|
+
|
|
1203
|
+
### π¨βπ» For Contributors & Developers
|
|
1204
|
+
|
|
1205
|
+
Before contributing or making changes to this codebase:
|
|
1206
|
+
|
|
1207
|
+
```bash
|
|
1208
|
+
# Essential pre-push workflow - run before every commit
|
|
1209
|
+
npm run pre-push
|
|
1210
|
+
```
|
|
1211
|
+
|
|
1212
|
+
**Developer Resources:**
|
|
1213
|
+
- **[PROTECTION-README.md](./PROTECTION-README.md)** - Quick protection system guide
|
|
1214
|
+
- **[PRE-PUSH-CHECKLIST.md](./PRE-PUSH-CHECKLIST.md)** - Complete workflow documentation
|
|
1215
|
+
- **[PROTECTION-NOTICE.md](./PROTECTION-NOTICE.md)** - Legal notices and compliance requirements
|
|
1216
|
+
- **[LICENSE](./LICENSE)** - Full BUSL 1.1 license text
|
|
1217
|
+
|
|
1218
|
+
### π License Compliance
|
|
1219
|
+
|
|
1220
|
+
All source files must include proper license headers and watermarks. The protection system automatically:
|
|
1221
|
+
- Adds license headers to new files
|
|
1222
|
+
- Validates compliance on every build
|
|
1223
|
+
- Tracks usage and modifications
|
|
1224
|
+
- Prevents unauthorized distribution
|
|
1225
|
+
|
|
1226
|
+
**Quick Commands:**
|
|
1227
|
+
```bash
|
|
1228
|
+
npm run protect # Apply protection to new files
|
|
1229
|
+
npm run validate-protection # Check for license violations
|
|
1230
|
+
npm run pre-push # Complete pre-push validation
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
---
|
|
1234
|
+
|
|
1235
|
+
**Β© 2025 Burtson Labs LLC. All rights reserved.**
|