@burtson-labs/bandit-engine 2.0.39 → 2.0.41
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/README.md +14 -11
- package/dist/{aiProviderStore-XN7GCBHJ.mjs → aiProviderStore-UQI33C5E.mjs} +2 -2
- package/dist/{chat-5QJNWB7I.mjs → chat-T5ANWWYQ.mjs} +5 -5
- package/dist/chat-provider.js +571 -122
- package/dist/chat-provider.js.map +1 -1
- package/dist/chat-provider.mjs +4 -4
- package/dist/{chunk-3A2527TE.mjs → chunk-22EY3ZDC.mjs} +3 -3
- package/dist/{chunk-ECRNIAG6.mjs → chunk-3E57HLDV.mjs} +4 -4
- package/dist/{chunk-QU5S5QQP.mjs → chunk-54ZQ3FSN.mjs} +481 -77
- package/dist/chunk-54ZQ3FSN.mjs.map +1 -0
- package/dist/{chunk-JRCDANLN.mjs → chunk-A6OBEF72.mjs} +75 -12
- package/dist/{chunk-JRCDANLN.mjs.map → chunk-A6OBEF72.mjs.map} +1 -1
- package/dist/{chunk-CDQYBO3Q.mjs → chunk-CX3INLYJ.mjs} +27 -5
- package/dist/chunk-CX3INLYJ.mjs.map +1 -0
- package/dist/{chunk-QYH2T4L5.mjs → chunk-LYWVYBKU.mjs} +3 -3
- package/dist/{chunk-WO5KFNNW.mjs → chunk-QFNEHSY4.mjs} +62 -24
- package/dist/chunk-QFNEHSY4.mjs.map +1 -0
- package/dist/{chunk-EOKIE5HZ.mjs → chunk-WPWWWUD7.mjs} +51 -46
- package/dist/chunk-WPWWWUD7.mjs.map +1 -0
- package/dist/{cli/cli.js → cli.js} +423 -10
- package/dist/cli.js.map +1 -0
- package/dist/{gateway-B0LJ3-jT.d.ts → gateway-5yt_3QDP.d.mts} +4 -4
- package/dist/{gateway-B0LJ3-jT.d.mts → gateway-5yt_3QDP.d.ts} +4 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +756 -206
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/management/management.js +754 -204
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +6 -6
- package/dist/modals/chat-modal/chat-modal.js +532 -88
- package/dist/modals/chat-modal/chat-modal.js.map +1 -1
- package/dist/modals/chat-modal/chat-modal.mjs +4 -4
- package/dist/public-types.d.mts +1 -1
- package/dist/public-types.d.ts +1 -1
- package/docs/01_quickstart.md +10 -4
- package/docs/02_gateway_api.md +19 -3
- package/docs/03_provider_integration.md +5 -4
- package/docs/api_reference/media/02_gateway_api.md +19 -3
- package/docs/api_reference/media/README.md +3 -1
- package/package.json +1 -1
- package/dist/chunk-CDQYBO3Q.mjs.map +0 -1
- package/dist/chunk-EOKIE5HZ.mjs.map +0 -1
- package/dist/chunk-QU5S5QQP.mjs.map +0 -1
- package/dist/chunk-WO5KFNNW.mjs.map +0 -1
- package/dist/cli/cli.js.map +0 -1
- /package/dist/{aiProviderStore-XN7GCBHJ.mjs.map → aiProviderStore-UQI33C5E.mjs.map} +0 -0
- /package/dist/{chat-5QJNWB7I.mjs.map → chat-T5ANWWYQ.mjs.map} +0 -0
- /package/dist/{chunk-3A2527TE.mjs.map → chunk-22EY3ZDC.mjs.map} +0 -0
- /package/dist/{chunk-ECRNIAG6.mjs.map → chunk-3E57HLDV.mjs.map} +0 -0
- /package/dist/{chunk-QYH2T4L5.mjs.map → chunk-LYWVYBKU.mjs.map} +0 -0
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
MAX_WINDOWED_HEIGHT,
|
|
4
4
|
MIN_WINDOWED_HEIGHT,
|
|
5
5
|
chat_modal_default
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
6
|
+
} from "../../chunk-3E57HLDV.mjs";
|
|
7
|
+
import "../../chunk-LYWVYBKU.mjs";
|
|
8
|
+
import "../../chunk-CX3INLYJ.mjs";
|
|
9
9
|
import "../../chunk-XUBYA5I7.mjs";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-54ZQ3FSN.mjs";
|
|
11
11
|
import "../../chunk-KCI46M23.mjs";
|
|
12
12
|
import "../../chunk-BJTO5JO5.mjs";
|
|
13
13
|
export {
|
package/dist/public-types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, h as ChatModalProps, g as ChatProviderProps, b as FeatureEvaluation, F as FeatureFlagConfig, a as FeatureKey, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, G as GatewayHealthResponse, r as GatewayMemoryRecord, d as GatewayMemoryResponse, l as GatewayMessage, k as GatewayMessageContent, c as GatewayModel, q as GatewayModelsResponse, P as PackageSettings, S as SubscriptionTier, T as TrialUsage, i as VoiceModelsResponse } from './gateway-
|
|
1
|
+
export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, h as ChatModalProps, g as ChatProviderProps, b as FeatureEvaluation, F as FeatureFlagConfig, a as FeatureKey, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, G as GatewayHealthResponse, r as GatewayMemoryRecord, d as GatewayMemoryResponse, l as GatewayMessage, k as GatewayMessageContent, c as GatewayModel, q as GatewayModelsResponse, P as PackageSettings, S as SubscriptionTier, T as TrialUsage, i as VoiceModelsResponse } from './gateway-5yt_3QDP.mjs';
|
|
2
2
|
import 'react';
|
|
3
3
|
|
|
4
4
|
interface StoredBrandingConfig {
|
package/dist/public-types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, h as ChatModalProps, g as ChatProviderProps, b as FeatureEvaluation, F as FeatureFlagConfig, a as FeatureKey, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, G as GatewayHealthResponse, r as GatewayMemoryRecord, d as GatewayMemoryResponse, l as GatewayMessage, k as GatewayMessageContent, c as GatewayModel, q as GatewayModelsResponse, P as PackageSettings, S as SubscriptionTier, T as TrialUsage, i as VoiceModelsResponse } from './gateway-
|
|
1
|
+
export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, h as ChatModalProps, g as ChatProviderProps, b as FeatureEvaluation, F as FeatureFlagConfig, a as FeatureKey, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, G as GatewayHealthResponse, r as GatewayMemoryRecord, d as GatewayMemoryResponse, l as GatewayMessage, k as GatewayMessageContent, c as GatewayModel, q as GatewayModelsResponse, P as PackageSettings, S as SubscriptionTier, T as TrialUsage, i as VoiceModelsResponse } from './gateway-5yt_3QDP.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
|
|
4
4
|
interface StoredBrandingConfig {
|
package/docs/01_quickstart.md
CHANGED
|
@@ -7,6 +7,7 @@ The quickstart gateway exposes the contract Bandit expects out of the box:
|
|
|
7
7
|
- `GET /api/health` — confirm connectivity and list configured providers.
|
|
8
8
|
- `GET /api/models` and `GET /api/models/:provider` — populate the model switcher and provider tabs.
|
|
9
9
|
- `POST /api/chat/completions` and `POST /api/generate` — default OpenAI-style chat/generation when no provider override is supplied.
|
|
10
|
+
- `POST /api/bandit/chat/completions` — Bandit AI chat completions (OpenAI-compatible).
|
|
10
11
|
- `POST /api/openai|azure-openai|anthropic/chat/completions` — provider-scoped chat completions.
|
|
11
12
|
- `POST /api/openai|azure-openai|anthropic/generate` — provider-scoped text generation.
|
|
12
13
|
- `POST /api/ollama/chat` and `POST /api/ollama/generate` — native Ollama streaming routes.
|
|
@@ -23,16 +24,21 @@ The quickstart gateway exposes the contract Bandit expects out of the box:
|
|
|
23
24
|
npm install
|
|
24
25
|
npm run dev
|
|
25
26
|
```
|
|
26
|
-
The example server listens on `http://localhost:8080` and proxies to OpenAI, Azure OpenAI, Anthropic, or Ollama using provider-scoped endpoints. Providers without credentials respond with `501` until you wire them up.
|
|
27
|
+
The example server listens on `http://localhost:8080` and proxies to Bandit AI, OpenAI, Azure OpenAI, Anthropic, or Ollama using provider-scoped endpoints. Providers without credentials respond with `501` until you wire them up.
|
|
27
28
|
3. **Wrap your app with `ChatProvider`**:
|
|
28
29
|
```tsx
|
|
29
30
|
import { ChatProvider } from "@burtson-labs/bandit-engine";
|
|
30
31
|
|
|
31
32
|
<ChatProvider
|
|
32
33
|
packageSettings={{
|
|
33
|
-
gatewayApiUrl: "http://localhost:8080",
|
|
34
|
-
defaultModel: "
|
|
35
|
-
brandingConfigUrl: "/config.json"
|
|
34
|
+
gatewayApiUrl: "http://localhost:8080/api",
|
|
35
|
+
defaultModel: "bandit-core-1",
|
|
36
|
+
brandingConfigUrl: "/config.json",
|
|
37
|
+
aiProvider: {
|
|
38
|
+
type: "gateway",
|
|
39
|
+
gatewayUrl: "http://localhost:8080/api",
|
|
40
|
+
provider: "bandit"
|
|
41
|
+
}
|
|
36
42
|
}}
|
|
37
43
|
>
|
|
38
44
|
{/* your routes */}
|
package/docs/02_gateway_api.md
CHANGED
|
@@ -18,16 +18,18 @@ Every request must include `Authorization: Bearer <token>`. Tokens are injected
|
|
|
18
18
|
| `/api/tts`, `/api/stt`, `/api/tts/available-models` | POST/GET | Optional voice endpoints for advanced deployments. |
|
|
19
19
|
|
|
20
20
|
### Provider-specific chat/generation routes
|
|
21
|
-
When the UI specifies a provider (OpenAI, Azure OpenAI, Anthropic, Ollama), Bandit Engine switches to provider-scoped endpoints automatically. Implement these routes alongside the core ones above:
|
|
21
|
+
When the UI specifies a provider (Bandit AI, OpenAI, Azure OpenAI, Anthropic, Ollama), Bandit Engine switches to provider-scoped endpoints automatically. Implement these routes alongside the core ones above:
|
|
22
22
|
|
|
23
23
|
| Provider | Chat endpoint | Generation endpoint |
|
|
24
24
|
| --- | --- | --- |
|
|
25
|
+
| Bandit AI | `POST /api/bandit/chat/completions` | `POST /api/bandit/generate`* |
|
|
25
26
|
| OpenAI | `POST /api/openai/chat/completions` | `POST /api/openai/generate` |
|
|
26
27
|
| Azure OpenAI | `POST /api/azure-openai/chat/completions` | `POST /api/azure-openai/generate` |
|
|
27
28
|
| Anthropic | `POST /api/anthropic/chat/completions` | `POST /api/anthropic/generate` |
|
|
28
29
|
| Ollama | `POST /api/ollama/chat` | `POST /api/ollama/generate` |
|
|
29
30
|
|
|
30
|
-
> ℹ️ Bandit still includes the `provider` field in the request body for convenience, but the URL itself determines which upstream integration should run. Ollama uses `/chat` (not `/chat/completions`) to match its native API.
|
|
31
|
+
> ℹ️ Bandit still includes the `provider` field in the request body for convenience, but the URL itself determines which upstream integration should run. Ollama uses `/chat` (not `/chat/completions`) to match its native API.
|
|
32
|
+
> \* `POST /api/bandit/generate` is optional today but mirrors the shape of `/api/chat/completions` for parity with other providers.
|
|
31
33
|
|
|
32
34
|
If you only support a single upstream provider you may implement the matching provider-specific endpoints and omit the others. The `/api/chat/completions` and `/api/generate` routes remain useful as a “default” path when the frontend has no explicit provider preference.
|
|
33
35
|
|
|
@@ -42,11 +44,25 @@ app.use(express.json());
|
|
|
42
44
|
app.get("/api/health", (req, res) => {
|
|
43
45
|
res.json({
|
|
44
46
|
status: "healthy",
|
|
45
|
-
providers: ["openai", "ollama"],
|
|
47
|
+
providers: ["bandit", "openai", "ollama"],
|
|
46
48
|
version: "1.0.0"
|
|
47
49
|
});
|
|
48
50
|
});
|
|
49
51
|
|
|
52
|
+
app.post("/api/bandit/chat/completions", async (req, res) => {
|
|
53
|
+
const response = await fetch(`${process.env.GATEWAY_URL}/completions`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: {
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
Authorization: `Bearer ${process.env.BANDIT_API_KEY}`
|
|
58
|
+
},
|
|
59
|
+
body: JSON.stringify(req.body)
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
res.status(response.status);
|
|
63
|
+
response.body?.pipe(res);
|
|
64
|
+
});
|
|
65
|
+
|
|
50
66
|
app.post("/api/openai/chat/completions", async (req, res) => {
|
|
51
67
|
const { model, messages, stream = true } = req.body;
|
|
52
68
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Bandit Engine routes every model invocation through your gateway but preserves provider-specific capabilities such as multimodal prompts, Azure deployment parameters, and local Ollama streaming. This guide summarizes the nuances for each supported provider and how to combine them with Bandit's feature flag system.
|
|
4
4
|
|
|
5
5
|
## Endpoints / API Usage
|
|
6
|
-
- `POST /api/{provider}/chat/completions` — automatically selected when `provider` is set to `openai`, `azure-openai`, or `
|
|
6
|
+
- `POST /api/{provider}/chat/completions` — automatically selected when `provider` is set to `bandit`, `openai`, `azure-openai`, `anthropic`, or `xai`.
|
|
7
7
|
- `POST /api/{provider}/generate` — optional non-chat endpoint for custom workloads.
|
|
8
8
|
- `GET /api/models/{provider}` — provider-specific model listing exposed in the management UI.
|
|
9
9
|
|
|
@@ -12,17 +12,18 @@ Bandit Engine routes every model invocation through your gateway but preserves p
|
|
|
12
12
|
import { GatewayProvider } from "@burtson-labs/bandit-engine";
|
|
13
13
|
|
|
14
14
|
const provider = new GatewayProvider({
|
|
15
|
-
provider: "
|
|
15
|
+
provider: "bandit",
|
|
16
16
|
gatewayUrl: "https://gateway.example.com",
|
|
17
17
|
tokenFactory: () => localStorage.getItem("authToken") ?? ""
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
provider.listModelsByProvider("
|
|
21
|
-
console.log("
|
|
20
|
+
provider.listModelsByProvider("bandit").subscribe(models => {
|
|
21
|
+
console.log("Bandit models", models.map(model => model.name));
|
|
22
22
|
});
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Provider Notes
|
|
26
|
+
- **Bandit AI**: Accepts OpenAI-format requests and automatically normalizes aliases such as `bandit-core-1`. Supports both auth tokens (UI) and API keys (CLI/partner usage) through the gateway.
|
|
26
27
|
- **OpenAI & Azure OpenAI**: Send images as `image_url` entries alongside text segments. Azure requires `deploymentName` and `apiVersion` within the gateway configuration.
|
|
27
28
|
- **Anthropic**: Supports the same streaming pipeline with Claude models and structured responses.
|
|
28
29
|
- **Ollama**: Keeps images on the final user message through the `images` array and exposes `/api/ollama/chat` plus `/api/ollama/generate` endpoints.
|
|
@@ -18,16 +18,18 @@ Every request must include `Authorization: Bearer <token>`. Tokens are injected
|
|
|
18
18
|
| `/api/tts`, `/api/stt`, `/api/tts/available-models` | POST/GET | Optional voice endpoints for advanced deployments. |
|
|
19
19
|
|
|
20
20
|
### Provider-specific chat/generation routes
|
|
21
|
-
When the UI specifies a provider (OpenAI, Azure OpenAI, Anthropic, Ollama), Bandit Engine switches to provider-scoped endpoints automatically. Implement these routes alongside the core ones above:
|
|
21
|
+
When the UI specifies a provider (Bandit AI, OpenAI, Azure OpenAI, Anthropic, Ollama), Bandit Engine switches to provider-scoped endpoints automatically. Implement these routes alongside the core ones above:
|
|
22
22
|
|
|
23
23
|
| Provider | Chat endpoint | Generation endpoint |
|
|
24
24
|
| --- | --- | --- |
|
|
25
|
+
| Bandit AI | `POST /api/bandit/chat/completions` | `POST /api/bandit/generate`* |
|
|
25
26
|
| OpenAI | `POST /api/openai/chat/completions` | `POST /api/openai/generate` |
|
|
26
27
|
| Azure OpenAI | `POST /api/azure-openai/chat/completions` | `POST /api/azure-openai/generate` |
|
|
27
28
|
| Anthropic | `POST /api/anthropic/chat/completions` | `POST /api/anthropic/generate` |
|
|
28
29
|
| Ollama | `POST /api/ollama/chat` | `POST /api/ollama/generate` |
|
|
29
30
|
|
|
30
|
-
> ℹ️ Bandit still includes the `provider` field in the request body for convenience, but the URL itself determines which upstream integration should run. Ollama uses `/chat` (not `/chat/completions`) to match its native API.
|
|
31
|
+
> ℹ️ Bandit still includes the `provider` field in the request body for convenience, but the URL itself determines which upstream integration should run. Ollama uses `/chat` (not `/chat/completions`) to match its native API.
|
|
32
|
+
> \* `POST /api/bandit/generate` is optional today but mirrors the shape of `/api/chat/completions` for parity with other providers.
|
|
31
33
|
|
|
32
34
|
If you only support a single upstream provider you may implement the matching provider-specific endpoints and omit the others. The `/api/chat/completions` and `/api/generate` routes remain useful as a “default” path when the frontend has no explicit provider preference.
|
|
33
35
|
|
|
@@ -42,11 +44,25 @@ app.use(express.json());
|
|
|
42
44
|
app.get("/api/health", (req, res) => {
|
|
43
45
|
res.json({
|
|
44
46
|
status: "healthy",
|
|
45
|
-
providers: ["openai", "ollama"],
|
|
47
|
+
providers: ["bandit", "openai", "ollama"],
|
|
46
48
|
version: "1.0.0"
|
|
47
49
|
});
|
|
48
50
|
});
|
|
49
51
|
|
|
52
|
+
app.post("/api/bandit/chat/completions", async (req, res) => {
|
|
53
|
+
const response = await fetch(`${process.env.GATEWAY_URL}/completions`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: {
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
Authorization: `Bearer ${process.env.BANDIT_API_KEY}`
|
|
58
|
+
},
|
|
59
|
+
body: JSON.stringify(req.body)
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
res.status(response.status);
|
|
63
|
+
response.body?.pipe(res);
|
|
64
|
+
});
|
|
65
|
+
|
|
50
66
|
app.post("/api/openai/chat/completions", async (req, res) => {
|
|
51
67
|
const { model, messages, stream = true } = req.body;
|
|
52
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Bandit Gateway Node Example
|
|
2
2
|
|
|
3
|
-
This example demonstrates a minimal HTTP gateway that proxies chat and generation requests to OpenAI, Azure OpenAI, Anthropic, or Ollama via provider-specific endpoints. Use it to validate your Bandit Engine integration before wiring up your production infrastructure.
|
|
3
|
+
This example demonstrates a minimal HTTP gateway that proxies chat and generation requests to Bandit AI, OpenAI, Azure OpenAI, Anthropic, or Ollama via provider-specific endpoints. Use it to validate your Bandit Engine integration before wiring up your production infrastructure.
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
```bash
|
|
@@ -10,6 +10,7 @@ npm run dev
|
|
|
10
10
|
|
|
11
11
|
The server listens on `http://localhost:8080`. Configure the following environment variables as needed:
|
|
12
12
|
|
|
13
|
+
- `BANDIT_API_KEY` – Optional; required when proxying to the Bandit API-key endpoint.
|
|
13
14
|
- `OPENAI_API_KEY` – Optional; required when proxying to OpenAI.
|
|
14
15
|
- `OLLAMA_URL` – Optional; defaults to `http://localhost:11434`.
|
|
15
16
|
- `AZURE_OPENAI_CHAT_URL` / `AZURE_OPENAI_RESPONSES_URL` – Optional; set to your Azure deployment REST URLs when using Azure OpenAI.
|
|
@@ -33,5 +34,6 @@ The server listens on `http://localhost:8080`. Configure the following environme
|
|
|
33
34
|
| `POST /api/anthropic/generate` | Anthropic text generation proxy. |
|
|
34
35
|
| `POST /api/ollama/chat` | Native Ollama chat streaming proxy. |
|
|
35
36
|
| `POST /api/ollama/generate` | Native Ollama generate proxy. |
|
|
37
|
+
| `POST /api/bandit/chat/completions` | Bandit AI chat completions proxy. |
|
|
36
38
|
|
|
37
39
|
These map directly to the requirements described in [`docs/02_gateway_api.md`](../../docs/02_gateway_api.md). Providers without credentials or URLs return `501 Not Implemented` responses so you can enable them incrementally.
|