@molecule/api-ai-decisions-kev 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +396 -2
- package/dist/browser-guard.d.ts +2 -0
- package/dist/browser-guard.d.ts.map +1 -0
- package/dist/browser-guard.js +19 -0
- package/dist/browser-guard.js.map +1 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +32 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +126 -0
- package/dist/provider.js.map +1 -0
- package/dist/secrets.d.ts +11 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +27 -0
- package/dist/secrets.js.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/wire.d.ts +94 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +205 -0
- package/dist/wire.js.map +1 -0
- package/package.json +52 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kev decisions provider for molecule.dev — typed decisions from the
|
|
3
|
+
* open-weights Kev models on a `kev.serve` host you run.
|
|
4
|
+
*
|
|
5
|
+
* Kev (github.com/jaredpalmer/kev; code and weights Apache-2.0) is a family of
|
|
6
|
+
* Qwen-based decision models — Kev-0.8B, 4B and 9B (LoRA adapters on
|
|
7
|
+
* Qwen3.5-*-Base) and Kev-27B (a full fine-tune of Qwen3.8-27B) — that answer
|
|
8
|
+
* `choice`, `score` and yes/no questions with calibrated probabilities and
|
|
9
|
+
* generate no text. Its README recommends Kev-4B as the default. `kev.serve`
|
|
10
|
+
* speaks TypeSafe Jev's `/v1/systemone` protocol, so swapping to
|
|
11
|
+
* `@molecule/api-ai-decisions-jev`, `-laya` or `-jeff` is a one-line change.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```bash
|
|
15
|
+
* # Run the model server (NVIDIA/AMD GPU, or Apple silicon via MLX; Python 3.12/3.13)
|
|
16
|
+
* git clone https://github.com/jaredpalmer/kev.git && cd kev && uv sync --extra serve
|
|
17
|
+
* KEV_API_KEY=change-me uv run --extra serve python -m kev.serve --run jaredpalmer/kev-4b@v1.0
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { setProvider, requireProvider } from '@molecule/api-ai-decisions'
|
|
22
|
+
* import { provider } from '@molecule/api-ai-decisions-kev'
|
|
23
|
+
*
|
|
24
|
+
* setProvider(provider) // reads KEV_URL + KEV_API_KEY on first use
|
|
25
|
+
*
|
|
26
|
+
* const { answers } = await requireProvider().decide({
|
|
27
|
+
* state: 'My card was charged twice, please refund one of them',
|
|
28
|
+
* questions: {
|
|
29
|
+
* queue: { type: 'choice', instructions: 'Which team?', criteria: { billing: 'charges, refunds', tech: 'bugs, login' } },
|
|
30
|
+
* refund: { type: 'yesNo', instructions: 'The customer wants a refund.' },
|
|
31
|
+
* },
|
|
32
|
+
* })
|
|
33
|
+
* answers.queue.choice // 'billing'
|
|
34
|
+
* answers.refund.probability // 0.93
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* - **You run the model.** `KEV_URL` (default `http://localhost:8008`, the
|
|
39
|
+
* server's own default port) points at a `kev.serve` host; its README
|
|
40
|
+
* examples use `--port 8009`, so set `KEV_URL` to match. `kev.serve` binds
|
|
41
|
+
* `127.0.0.1` unless you pass `--host 0.0.0.0` — and it is OPEN by default:
|
|
42
|
+
* set `KEV_API_KEY` on BOTH sides before exposing it, or you publish an
|
|
43
|
+
* unauthenticated GPU endpoint.
|
|
44
|
+
* - **Validated context.** The server accepts states up to 65,536 tokens, but
|
|
45
|
+
* accuracy holds only to 8,192 tokens for Kev-0.8B/4B/9B (trained mostly on
|
|
46
|
+
* states ≤384 tokens) and 65,536 for Kev-27B. A longer state is REFUSED with
|
|
47
|
+
* a 422 naming its token count (unless the server runs
|
|
48
|
+
* `KEV_TRUNCATE_STATES=1`); this bond surfaces it verbatim and never retries
|
|
49
|
+
* a 422. Shorten the state instead.
|
|
50
|
+
* - **`model` never selects a checkpoint.** Any string is echoed back; the
|
|
51
|
+
* server answers with the one checkpoint it loaded via `--run`. Run a second
|
|
52
|
+
* server for a second size.
|
|
53
|
+
* - **1–255 options or levels per question** (Kev's own limit — not Jeff's
|
|
54
|
+
* 26). This bond refuses more before sending. Option order can change an
|
|
55
|
+
* answer: questions are isolated from each other, options within one are not.
|
|
56
|
+
* - **Text only.** There is no `images` field; this bond throws if you pass
|
|
57
|
+
* any. Use `@molecule/api-ai-decisions-intern-decision` or `-llm` for images.
|
|
58
|
+
* - **Never use Kev-0.8B for tool routing** — it scores below chance on
|
|
59
|
+
* When2Call (0.133). Date arithmetic is weak below 27B: start the server with
|
|
60
|
+
* `KEV_DATE_FACTS=1`. Knowledge questions are capped by the base model, and
|
|
61
|
+
* smaller sizes trail Jev by 13–31 points out of domain.
|
|
62
|
+
* - **bf16 vs fp32.** Serving runs in bf16, so probabilities differ from the
|
|
63
|
+
* published fp32 numbers by up to ~0.03 (GPU) / ~0.05 (Mac) and the top
|
|
64
|
+
* answer flips on ~1 question in 300. `KEV_DTYPE=fp32` on the server gives
|
|
65
|
+
* the exact evaluation path.
|
|
66
|
+
* - **Ignore the wire `confidence`.** The server sends TypeSafe's dispersion
|
|
67
|
+
* statistic, not an accuracy rate; this bond recomputes `confidence` as the
|
|
68
|
+
* probability of the reported answer. Tune `minConfidence` on your own
|
|
69
|
+
* labelled data — Kev-0.8B can automate far fewer decisions at a fixed error
|
|
70
|
+
* budget than 4B/9B/27B.
|
|
71
|
+
* - **Not a CPU model.** It runs on CUDA/ROCm or Apple MLX (Kev-4B: ~42 ms on
|
|
72
|
+
* an L40S, ~721 ms on an M5). There is no `/health` route: probe
|
|
73
|
+
* `GET /v1/models`. A scale-to-zero host (Modal) takes ~35 s on the first
|
|
74
|
+
* call after idle; `createProvider({ timeoutMs })` defaults to 120 s for that.
|
|
75
|
+
* - **Hosted on rented compute?** Pass `headers: () => hosting.authHeaders(endpoint.id)`
|
|
76
|
+
* (`@molecule/api-model-hosting`) when the host's auth expires or is not a
|
|
77
|
+
* bearer token — e.g. Modal proxy auth. It runs before every request and is
|
|
78
|
+
* merged over the defaults.
|
|
79
|
+
* - **Other `/v1/systemone` servers.** Point `baseUrl` at any server of the
|
|
80
|
+
* same protocol and lower `maxOptions` to its limit (a self-hosted Nimble:
|
|
81
|
+
* `model: 'nimble-latest'`, `maxOptions: 26` — check its license first).
|
|
82
|
+
* - Use the core's `setProvider`, not `bond('ai-decisions', …)` directly.
|
|
83
|
+
*
|
|
84
|
+
* @module
|
|
85
|
+
*/
|
|
86
|
+
export * from './browser-guard.js';
|
|
87
|
+
export * from './provider.js';
|
|
88
|
+
export * from './secrets.js';
|
|
89
|
+
export * from './types.js';
|
|
90
|
+
export * from './wire.js';
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kev decisions provider for molecule.dev — typed decisions from the
|
|
3
|
+
* open-weights Kev models on a `kev.serve` host you run.
|
|
4
|
+
*
|
|
5
|
+
* Kev (github.com/jaredpalmer/kev; code and weights Apache-2.0) is a family of
|
|
6
|
+
* Qwen-based decision models — Kev-0.8B, 4B and 9B (LoRA adapters on
|
|
7
|
+
* Qwen3.5-*-Base) and Kev-27B (a full fine-tune of Qwen3.8-27B) — that answer
|
|
8
|
+
* `choice`, `score` and yes/no questions with calibrated probabilities and
|
|
9
|
+
* generate no text. Its README recommends Kev-4B as the default. `kev.serve`
|
|
10
|
+
* speaks TypeSafe Jev's `/v1/systemone` protocol, so swapping to
|
|
11
|
+
* `@molecule/api-ai-decisions-jev`, `-laya` or `-jeff` is a one-line change.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```bash
|
|
15
|
+
* # Run the model server (NVIDIA/AMD GPU, or Apple silicon via MLX; Python 3.12/3.13)
|
|
16
|
+
* git clone https://github.com/jaredpalmer/kev.git && cd kev && uv sync --extra serve
|
|
17
|
+
* KEV_API_KEY=change-me uv run --extra serve python -m kev.serve --run jaredpalmer/kev-4b@v1.0
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { setProvider, requireProvider } from '@molecule/api-ai-decisions'
|
|
22
|
+
* import { provider } from '@molecule/api-ai-decisions-kev'
|
|
23
|
+
*
|
|
24
|
+
* setProvider(provider) // reads KEV_URL + KEV_API_KEY on first use
|
|
25
|
+
*
|
|
26
|
+
* const { answers } = await requireProvider().decide({
|
|
27
|
+
* state: 'My card was charged twice, please refund one of them',
|
|
28
|
+
* questions: {
|
|
29
|
+
* queue: { type: 'choice', instructions: 'Which team?', criteria: { billing: 'charges, refunds', tech: 'bugs, login' } },
|
|
30
|
+
* refund: { type: 'yesNo', instructions: 'The customer wants a refund.' },
|
|
31
|
+
* },
|
|
32
|
+
* })
|
|
33
|
+
* answers.queue.choice // 'billing'
|
|
34
|
+
* answers.refund.probability // 0.93
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* - **You run the model.** `KEV_URL` (default `http://localhost:8008`, the
|
|
39
|
+
* server's own default port) points at a `kev.serve` host; its README
|
|
40
|
+
* examples use `--port 8009`, so set `KEV_URL` to match. `kev.serve` binds
|
|
41
|
+
* `127.0.0.1` unless you pass `--host 0.0.0.0` — and it is OPEN by default:
|
|
42
|
+
* set `KEV_API_KEY` on BOTH sides before exposing it, or you publish an
|
|
43
|
+
* unauthenticated GPU endpoint.
|
|
44
|
+
* - **Validated context.** The server accepts states up to 65,536 tokens, but
|
|
45
|
+
* accuracy holds only to 8,192 tokens for Kev-0.8B/4B/9B (trained mostly on
|
|
46
|
+
* states ≤384 tokens) and 65,536 for Kev-27B. A longer state is REFUSED with
|
|
47
|
+
* a 422 naming its token count (unless the server runs
|
|
48
|
+
* `KEV_TRUNCATE_STATES=1`); this bond surfaces it verbatim and never retries
|
|
49
|
+
* a 422. Shorten the state instead.
|
|
50
|
+
* - **`model` never selects a checkpoint.** Any string is echoed back; the
|
|
51
|
+
* server answers with the one checkpoint it loaded via `--run`. Run a second
|
|
52
|
+
* server for a second size.
|
|
53
|
+
* - **1–255 options or levels per question** (Kev's own limit — not Jeff's
|
|
54
|
+
* 26). This bond refuses more before sending. Option order can change an
|
|
55
|
+
* answer: questions are isolated from each other, options within one are not.
|
|
56
|
+
* - **Text only.** There is no `images` field; this bond throws if you pass
|
|
57
|
+
* any. Use `@molecule/api-ai-decisions-intern-decision` or `-llm` for images.
|
|
58
|
+
* - **Never use Kev-0.8B for tool routing** — it scores below chance on
|
|
59
|
+
* When2Call (0.133). Date arithmetic is weak below 27B: start the server with
|
|
60
|
+
* `KEV_DATE_FACTS=1`. Knowledge questions are capped by the base model, and
|
|
61
|
+
* smaller sizes trail Jev by 13–31 points out of domain.
|
|
62
|
+
* - **bf16 vs fp32.** Serving runs in bf16, so probabilities differ from the
|
|
63
|
+
* published fp32 numbers by up to ~0.03 (GPU) / ~0.05 (Mac) and the top
|
|
64
|
+
* answer flips on ~1 question in 300. `KEV_DTYPE=fp32` on the server gives
|
|
65
|
+
* the exact evaluation path.
|
|
66
|
+
* - **Ignore the wire `confidence`.** The server sends TypeSafe's dispersion
|
|
67
|
+
* statistic, not an accuracy rate; this bond recomputes `confidence` as the
|
|
68
|
+
* probability of the reported answer. Tune `minConfidence` on your own
|
|
69
|
+
* labelled data — Kev-0.8B can automate far fewer decisions at a fixed error
|
|
70
|
+
* budget than 4B/9B/27B.
|
|
71
|
+
* - **Not a CPU model.** It runs on CUDA/ROCm or Apple MLX (Kev-4B: ~42 ms on
|
|
72
|
+
* an L40S, ~721 ms on an M5). There is no `/health` route: probe
|
|
73
|
+
* `GET /v1/models`. A scale-to-zero host (Modal) takes ~35 s on the first
|
|
74
|
+
* call after idle; `createProvider({ timeoutMs })` defaults to 120 s for that.
|
|
75
|
+
* - **Hosted on rented compute?** Pass `headers: () => hosting.authHeaders(endpoint.id)`
|
|
76
|
+
* (`@molecule/api-model-hosting`) when the host's auth expires or is not a
|
|
77
|
+
* bearer token — e.g. Modal proxy auth. It runs before every request and is
|
|
78
|
+
* merged over the defaults.
|
|
79
|
+
* - **Other `/v1/systemone` servers.** Point `baseUrl` at any server of the
|
|
80
|
+
* same protocol and lower `maxOptions` to its limit (a self-hosted Nimble:
|
|
81
|
+
* `model: 'nimble-latest'`, `maxOptions: 26` — check its license first).
|
|
82
|
+
* - Use the core's `setProvider`, not `bond('ai-decisions', …)` directly.
|
|
83
|
+
*
|
|
84
|
+
* @module
|
|
85
|
+
*/
|
|
86
|
+
export * from './browser-guard.js';
|
|
87
|
+
export * from './provider.js';
|
|
88
|
+
export * from './secrets.js';
|
|
89
|
+
export * from './types.js';
|
|
90
|
+
export * from './wire.js';
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kev implementation of `AIDecisionsProvider`.
|
|
3
|
+
*
|
|
4
|
+
* Talks to a self-hosted `kev.serve` over its `POST /v1/systemone` route
|
|
5
|
+
* (the TypeSafe Jev wire protocol), so the open-weights Kev models answer
|
|
6
|
+
* typed decisions on your own hardware.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import './secrets.js';
|
|
11
|
+
import type { AIDecisionsProvider } from '@molecule/api-ai-decisions';
|
|
12
|
+
import type { KevConfig } from './types.js';
|
|
13
|
+
/** `kev.serve`'s default bind (`--port` defaults to 8008; its README examples use 8009). */
|
|
14
|
+
export declare const DEFAULT_KEV_URL = "http://localhost:8008";
|
|
15
|
+
/** The model id `kev.serve` documents; any string is echoed back, none selects a checkpoint. */
|
|
16
|
+
export declare const DEFAULT_KEV_MODEL = "kev-latest";
|
|
17
|
+
/** Most `choice` options or `score` levels `kev.serve` accepts (`MAX_OPTIONS` in `kev/api.py`). */
|
|
18
|
+
export declare const DEFAULT_KEV_MAX_OPTIONS = 255;
|
|
19
|
+
/** Default per-call timeout: room for a scale-to-zero cold start (~35 s on Modal). */
|
|
20
|
+
export declare const DEFAULT_KEV_TIMEOUT_MS = 120000;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a Kev decisions provider.
|
|
23
|
+
*
|
|
24
|
+
* @param config - Base URL, API key, headers hook, model id, option limit and timeout.
|
|
25
|
+
* @returns An `AIDecisionsProvider` backed by a `kev.serve` host.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createProvider(config?: KevConfig): AIDecisionsProvider;
|
|
28
|
+
/**
|
|
29
|
+
* The provider implementation — lazy, so env vars are read on first use.
|
|
30
|
+
*/
|
|
31
|
+
export declare const provider: AIDecisionsProvider;
|
|
32
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EACV,mBAAmB,EAIpB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAG3C,4FAA4F;AAC5F,eAAO,MAAM,eAAe,0BAA0B,CAAA;AAEtD,gGAAgG;AAChG,eAAO,MAAM,iBAAiB,eAAe,CAAA;AAE7C,mGAAmG;AACnG,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAE1C,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,SAAU,CAAA;AA8F7C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,mBAAmB,CAEtE;AAGD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,mBASrB,CAAA"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kev implementation of `AIDecisionsProvider`.
|
|
3
|
+
*
|
|
4
|
+
* Talks to a self-hosted `kev.serve` over its `POST /v1/systemone` route
|
|
5
|
+
* (the TypeSafe Jev wire protocol), so the open-weights Kev models answer
|
|
6
|
+
* typed decisions on your own hardware.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
// Side-effect import: registers this bond's secret definitions.
|
|
11
|
+
import './secrets.js';
|
|
12
|
+
import { fromWireResponse, postSystemOne, toWireQuestions } from './wire.js';
|
|
13
|
+
/** `kev.serve`'s default bind (`--port` defaults to 8008; its README examples use 8009). */
|
|
14
|
+
export const DEFAULT_KEV_URL = 'http://localhost:8008';
|
|
15
|
+
/** The model id `kev.serve` documents; any string is echoed back, none selects a checkpoint. */
|
|
16
|
+
export const DEFAULT_KEV_MODEL = 'kev-latest';
|
|
17
|
+
/** Most `choice` options or `score` levels `kev.serve` accepts (`MAX_OPTIONS` in `kev/api.py`). */
|
|
18
|
+
export const DEFAULT_KEV_MAX_OPTIONS = 255;
|
|
19
|
+
/** Default per-call timeout: room for a scale-to-zero cold start (~35 s on Modal). */
|
|
20
|
+
export const DEFAULT_KEV_TIMEOUT_MS = 120_000;
|
|
21
|
+
/**
|
|
22
|
+
* Refuses, before any request, what `kev.serve` would reject with a 422:
|
|
23
|
+
* a `choice` or `score` question with no options or more than `maxOptions`.
|
|
24
|
+
*
|
|
25
|
+
* @param questions - The questions keyed by id.
|
|
26
|
+
* @param maxOptions - Most options/levels per question.
|
|
27
|
+
*/
|
|
28
|
+
function checkLimits(questions, maxOptions) {
|
|
29
|
+
for (const [id, q] of Object.entries(questions)) {
|
|
30
|
+
if (q.type === 'choice') {
|
|
31
|
+
const count = Object.keys(q.criteria ?? {}).length;
|
|
32
|
+
if (count < 1 || count > maxOptions) {
|
|
33
|
+
throw new Error(`ai-decisions-kev: question "${id}" has ${count} options; Kev answers 1–${maxOptions}. Shortlist the options first, or split the question.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (q.type === 'score') {
|
|
37
|
+
const count = q.criteria?.length ?? 0;
|
|
38
|
+
if (count < 1 || count > maxOptions) {
|
|
39
|
+
throw new Error(`ai-decisions-kev: question "${id}" has ${count} score levels; Kev answers 1–${maxOptions}.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Kev decisions provider over HTTP.
|
|
46
|
+
*/
|
|
47
|
+
class KevDecisionsProvider {
|
|
48
|
+
name = 'kev';
|
|
49
|
+
baseUrl;
|
|
50
|
+
apiKey;
|
|
51
|
+
headers;
|
|
52
|
+
model;
|
|
53
|
+
maxOptions;
|
|
54
|
+
timeoutMs;
|
|
55
|
+
/**
|
|
56
|
+
* Creates the provider.
|
|
57
|
+
*
|
|
58
|
+
* @param config - Provider configuration; env vars fill anything omitted.
|
|
59
|
+
*/
|
|
60
|
+
constructor(config = {}) {
|
|
61
|
+
this.baseUrl = (config.baseUrl || process.env.KEV_URL || DEFAULT_KEV_URL).replace(/\/+$/, '');
|
|
62
|
+
this.apiKey = config.apiKey ?? (process.env.KEV_API_KEY || undefined);
|
|
63
|
+
this.headers = config.headers;
|
|
64
|
+
this.model = config.model || DEFAULT_KEV_MODEL;
|
|
65
|
+
this.maxOptions = config.maxOptions ?? DEFAULT_KEV_MAX_OPTIONS;
|
|
66
|
+
this.timeoutMs = config.timeoutMs ?? DEFAULT_KEV_TIMEOUT_MS;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Answers every question about `input.state` in one request.
|
|
70
|
+
*
|
|
71
|
+
* @param input - The state, questions and options.
|
|
72
|
+
* @returns One typed answer per question id.
|
|
73
|
+
*/
|
|
74
|
+
async decide(input) {
|
|
75
|
+
if (input.state === undefined || input.state === null) {
|
|
76
|
+
throw new Error('ai-decisions: decide() requires a `state`');
|
|
77
|
+
}
|
|
78
|
+
if (!input.questions || Object.keys(input.questions).length === 0) {
|
|
79
|
+
throw new Error('ai-decisions: decide() requires at least one question');
|
|
80
|
+
}
|
|
81
|
+
if (input.images?.length) {
|
|
82
|
+
throw new Error('ai-decisions-kev: Kev reads text only, so `images` is not supported. Bond @molecule/api-ai-decisions-intern-decision or @molecule/api-ai-decisions-llm (over a vision model) to ask about images.');
|
|
83
|
+
}
|
|
84
|
+
checkLimits(input.questions, this.maxOptions);
|
|
85
|
+
const timeout = AbortSignal.timeout(this.timeoutMs);
|
|
86
|
+
const body = await postSystemOne({
|
|
87
|
+
url: `${this.baseUrl}/v1/systemone`,
|
|
88
|
+
apiKey: this.apiKey,
|
|
89
|
+
headers: this.headers,
|
|
90
|
+
body: {
|
|
91
|
+
model: input.model || this.model,
|
|
92
|
+
state: input.state,
|
|
93
|
+
questions: toWireQuestions(input.questions),
|
|
94
|
+
},
|
|
95
|
+
signal: input.signal ? AbortSignal.any([input.signal, timeout]) : timeout,
|
|
96
|
+
label: 'Kev',
|
|
97
|
+
});
|
|
98
|
+
return fromWireResponse(input.questions, body, input.minConfidence);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Creates a Kev decisions provider.
|
|
103
|
+
*
|
|
104
|
+
* @param config - Base URL, API key, headers hook, model id, option limit and timeout.
|
|
105
|
+
* @returns An `AIDecisionsProvider` backed by a `kev.serve` host.
|
|
106
|
+
*/
|
|
107
|
+
export function createProvider(config) {
|
|
108
|
+
return new KevDecisionsProvider(config);
|
|
109
|
+
}
|
|
110
|
+
let _provider = null;
|
|
111
|
+
/**
|
|
112
|
+
* The provider implementation — lazy, so env vars are read on first use.
|
|
113
|
+
*/
|
|
114
|
+
export const provider = new Proxy({}, {
|
|
115
|
+
get(_, prop, receiver) {
|
|
116
|
+
if (!_provider)
|
|
117
|
+
_provider = createProvider();
|
|
118
|
+
return Reflect.get(_provider, prop, receiver);
|
|
119
|
+
},
|
|
120
|
+
set(_, prop, value) {
|
|
121
|
+
if (!_provider)
|
|
122
|
+
_provider = createProvider();
|
|
123
|
+
return Reflect.set(_provider, prop, value);
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gEAAgE;AAChE,OAAO,cAAc,CAAA;AAUrB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE5E,4FAA4F;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAA;AAEtD,gGAAgG;AAChG,MAAM,CAAC,MAAM,iBAAiB,GAAG,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|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kev secret definitions — self-registered at import time so the runtime
|
|
3
|
+
* secrets registry (`@molecule/api-secrets`) can drive boot-time configuration
|
|
4
|
+
* reports and actionable "not configured" errors.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { SecretDefinition } from '@molecule/api-secrets';
|
|
9
|
+
/** Secret definitions used by the Kev decisions bond. */
|
|
10
|
+
export declare const aiDecisionsKevSecretDefinitions: SecretDefinition[];
|
|
11
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,yDAAyD;AACzD,eAAO,MAAM,+BAA+B,EAAE,gBAAgB,EAiB7D,CAAA"}
|
package/dist/secrets.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kev secret definitions — self-registered at import time so the runtime
|
|
3
|
+
* secrets registry (`@molecule/api-secrets`) can drive boot-time configuration
|
|
4
|
+
* reports and actionable "not configured" errors.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { registerSecrets } from '@molecule/api-secrets';
|
|
9
|
+
/** Secret definitions used by the Kev decisions bond. */
|
|
10
|
+
export const aiDecisionsKevSecretDefinitions = [
|
|
11
|
+
{
|
|
12
|
+
key: 'KEV_URL',
|
|
13
|
+
description: 'Kev server URL — The base URL of your kev.serve host (clone github.com/jaredpalmer/kev, uv sync --extra serve, then uv run --extra serve python -m kev.serve --run jaredpalmer/kev-4b@v1.0). Defaults to http://localhost:8008.',
|
|
14
|
+
helpUrl: 'https://github.com/jaredpalmer/kev#readme',
|
|
15
|
+
required: false,
|
|
16
|
+
example: 'http://localhost:8008',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
key: 'KEV_API_KEY',
|
|
20
|
+
description: 'Kev server API key — The bearer token your kev.serve host requires, if you set KEV_API_KEY on the server.',
|
|
21
|
+
helpUrl: 'https://github.com/jaredpalmer/kev#readme',
|
|
22
|
+
required: false,
|
|
23
|
+
example: 'a-long-random-string',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
registerSecrets(aiDecisionsKevSecretDefinitions);
|
|
27
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,yDAAyD;AACzD,MAAM,CAAC,MAAM,+BAA+B,GAAuB;IACjE;QACE,GAAG,EAAE,SAAS;QACd,WAAW,EACT,iOAAiO;QACnO,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,uBAAuB;KACjC;IACD;QACE,GAAG,EAAE,aAAa;QAClB,WAAW,EACT,2GAA2G;QAC7G,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,sBAAsB;KAChC;CACF,CAAA;AAED,eAAe,CAAC,+BAA+B,CAAC,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kev decisions provider configuration.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the Kev decisions provider.
|
|
8
|
+
*/
|
|
9
|
+
export interface KevConfig {
|
|
10
|
+
/** Base URL of the `kev.serve` host. Defaults to `KEV_URL`, then `http://localhost:8008`. */
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
/** Bearer token, when the server sets `KEV_API_KEY`. Defaults to the `KEV_API_KEY` env var. */
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Extra request headers, resolved before each call and merged over the
|
|
16
|
+
* defaults — for a host whose auth expires or is not a bearer token (a Cloud
|
|
17
|
+
* Run ID token, Modal proxy auth). Pair with `@molecule/api-model-hosting`:
|
|
18
|
+
* `headers: () => hosting.authHeaders(endpoint.id)`.
|
|
19
|
+
*/
|
|
20
|
+
headers?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* Model id sent on every request. `kev.serve` accepts any string and echoes
|
|
23
|
+
* it back; it never selects a checkpoint (the server answers with the one
|
|
24
|
+
* it loaded via `--run`). Defaults to `'kev-latest'`.
|
|
25
|
+
*/
|
|
26
|
+
model?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Most `choice` options / `score` levels sent in one question. Defaults to
|
|
29
|
+
* 255, `kev.serve`'s own limit. Lower it for another `/v1/systemone` server
|
|
30
|
+
* with a smaller one (Nimble: 26).
|
|
31
|
+
*/
|
|
32
|
+
maxOptions?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Milliseconds to wait for one `decide()` (retries included) before
|
|
35
|
+
* aborting. Defaults to 120000 — long enough for a scale-to-zero host's
|
|
36
|
+
* cold start (~35 s on Modal) plus the model load.
|
|
37
|
+
*/
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+FAA+F;IAC/F,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACxE;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `/v1/systemone` wire protocol (TypeSafe Jev, spoken verbatim by Kev's
|
|
3
|
+
* `kev.serve`) ↔ the `@molecule/api-ai-decisions` types.
|
|
4
|
+
*
|
|
5
|
+
* Wire facts (github.com/jaredpalmer/kev `kev/api.py`, `kev/serve.py`):
|
|
6
|
+
* request `{ model?, state, questions: { <id>: { type: 'choice'|'score'|'noul', instructions?, criteria } } }`
|
|
7
|
+
* — `model` is optional, any string is accepted and echoed back, and it never
|
|
8
|
+
* selects a checkpoint; `choice` criteria is `{ label: description }` (1–255
|
|
9
|
+
* options), `score` criteria a list of 1–255 levels, lowest first, `noul`
|
|
10
|
+
* criteria optional `{ true, false }`. There is no `images` field. Answers
|
|
11
|
+
* carry `choice` + `probabilities` keyed by label, `score` (expected level) +
|
|
12
|
+
* `probabilities` keyed `"0".."k-1"`, or `noul` (P(true), no
|
|
13
|
+
* `probabilities`). The wire `confidence` is TypeSafe's dispersion statistic,
|
|
14
|
+
* not an accuracy rate, and is ignored: the core defines `confidence` as the
|
|
15
|
+
* probability of the reported answer, computed here from the distribution.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import type { DecideResult, DecisionAnswer, DecisionQuestion } from '@molecule/api-ai-decisions';
|
|
20
|
+
/** One question as sent on the wire. */
|
|
21
|
+
export interface WireQuestion {
|
|
22
|
+
type: 'choice' | 'score' | 'noul';
|
|
23
|
+
instructions: string;
|
|
24
|
+
criteria?: Record<string, string> | string[];
|
|
25
|
+
}
|
|
26
|
+
/** One answer as received on the wire (only the fields we read). */
|
|
27
|
+
export interface WireAnswer {
|
|
28
|
+
type?: string;
|
|
29
|
+
choice?: string;
|
|
30
|
+
score?: number;
|
|
31
|
+
noul?: number;
|
|
32
|
+
probabilities?: Record<string, number>;
|
|
33
|
+
}
|
|
34
|
+
/** The response body (only the fields we read). */
|
|
35
|
+
export interface WireResponse {
|
|
36
|
+
model?: string;
|
|
37
|
+
answers?: Record<string, WireAnswer>;
|
|
38
|
+
usage?: {
|
|
39
|
+
input_tokens?: number;
|
|
40
|
+
output_tokens?: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts the core's questions into wire questions (`yesNo` → `noul`).
|
|
45
|
+
*
|
|
46
|
+
* @param questions - The questions keyed by id.
|
|
47
|
+
* @returns The wire `questions` object.
|
|
48
|
+
*/
|
|
49
|
+
export declare function toWireQuestions(questions: Record<string, DecisionQuestion>): Record<string, WireQuestion>;
|
|
50
|
+
/**
|
|
51
|
+
* Converts one wire answer into the core's answer for `question`.
|
|
52
|
+
*
|
|
53
|
+
* @param id - The question id (for error messages).
|
|
54
|
+
* @param question - The question that was asked.
|
|
55
|
+
* @param wire - The wire answer.
|
|
56
|
+
* @param minConfidence - Optional low-confidence threshold.
|
|
57
|
+
* @returns The typed answer.
|
|
58
|
+
*/
|
|
59
|
+
export declare function fromWireAnswer(id: string, question: DecisionQuestion, wire: WireAnswer | undefined, minConfidence?: number): DecisionAnswer;
|
|
60
|
+
/**
|
|
61
|
+
* Converts a whole wire response into the core's result.
|
|
62
|
+
*
|
|
63
|
+
* @param questions - The questions that were asked.
|
|
64
|
+
* @param body - The parsed response body.
|
|
65
|
+
* @param minConfidence - Optional low-confidence threshold.
|
|
66
|
+
* @returns The typed result.
|
|
67
|
+
*/
|
|
68
|
+
export declare function fromWireResponse<Q extends Record<string, DecisionQuestion>>(questions: Q, body: WireResponse, minConfidence?: number): DecideResult<Q>;
|
|
69
|
+
/** Options for {@link postSystemOne}. */
|
|
70
|
+
export interface PostOptions {
|
|
71
|
+
/** Full endpoint URL. */
|
|
72
|
+
url: string;
|
|
73
|
+
/** Bearer token, if any. */
|
|
74
|
+
apiKey?: string;
|
|
75
|
+
/** Extra headers resolved before the request (merged over the defaults). */
|
|
76
|
+
headers?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
77
|
+
/** Request body. */
|
|
78
|
+
body: Record<string, unknown>;
|
|
79
|
+
/** Abort signal. */
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
/** Label for error messages (`'Kev'`). */
|
|
82
|
+
label: string;
|
|
83
|
+
/** Max retries on a retryable status (default 3). */
|
|
84
|
+
maxRetries?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* POSTs a `/v1/systemone` request with retry on 429/5xx-busy, honouring
|
|
88
|
+
* `Retry-After`. Throws an Error carrying `status` on a non-2xx response.
|
|
89
|
+
*
|
|
90
|
+
* @param opts - Request options.
|
|
91
|
+
* @returns The parsed response body.
|
|
92
|
+
*/
|
|
93
|
+
export declare function postSystemOne(opts: PostOptions): Promise<WireResponse>;
|
|
94
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAEV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAGjB,MAAM,4BAA4B,CAAA;AAEnC,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACjC,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,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