@plumbus/ai-decision-laya 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/README.md +166 -18
- package/dist/.tsbuildinfo +1 -1
- package/instructions/README.md +8 -3
- package/instructions/framework.md +13 -1
- package/instructions/testing.md +5 -0
- package/package.json +3 -3
- package/service/test_audit_round_two.py +8 -1
package/instructions/README.md
CHANGED
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
| [framework.md](framework.md) | Installation, public exports, adapter boundary, usage rules |
|
|
6
6
|
| [testing.md](testing.md) | Offline validation and live environment setup |
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
**Classification, categorization, provider/model selection, TypeSafe/Jev or Laya:**
|
|
9
|
+
read `node_modules/@plumbus/core/instructions/ai-classification.md` first (core
|
|
10
|
+
**0.7.4+**), then [framework.md](framework.md) for this package.
|
|
11
|
+
|
|
12
|
+
Core 0.7.3+ provides `ctx.ai.decide()`; core 0.7.4+ also routes `ctx.ai.classify()`
|
|
13
|
+
to explicitly registered decision adapters. Keep app business logic in Plumbus
|
|
14
|
+
primitives and `ctx.*`. Never route predictions around capability access checks
|
|
15
|
+
or confirmation policy. Provider registration is explicit in `app/server.ts`.
|
|
11
16
|
|
|
12
17
|
[Package README](../README.md) · [Monorepo guide](https://github.com/plumbus-framework/plumbus/blob/main/docs/ai/decision-providers.md)
|
|
@@ -14,7 +14,19 @@ Public exports: `createLayaDecisionAdapter` — construct an explicitly configur
|
|
|
14
14
|
File map: `src/index.ts` is the public barrel, `src/__tests__/` exercises the public
|
|
15
15
|
API, `instructions/` contains these recipes. Laya alone also ships `service/`.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Classification and model selection (core 0.7.4+)
|
|
18
|
+
|
|
19
|
+
Read `node_modules/@plumbus/core/instructions/ai-classification.md` for the complete
|
|
20
|
+
registration and usage recipe. Call `ctx.ai.classify({ text, labels, provider, model,
|
|
21
|
+
threshold })` inside capabilities/flows. `provider` is your registered decision map
|
|
22
|
+
key; `model` is an optional endpoint-supported ID. Native `threshold` defaults to
|
|
23
|
+
0.5 and returns all matching labels. Use `decide()` for richer questions.
|
|
24
|
+
|
|
25
|
+
Core records one `classify` cost row, including dispatched failures, with actual
|
|
26
|
+
model/usage and identity. Omitted `provider` still uses the text default. Keep
|
|
27
|
+
decision adapters under `decisions.providers`, separate from text providers.
|
|
28
|
+
|
|
29
|
+
## Minimal usage (infrastructure / smoke testing)
|
|
18
30
|
|
|
19
31
|
```ts
|
|
20
32
|
import { createLayaDecisionAdapter } from '@plumbus/ai-decision-laya';
|
package/instructions/testing.md
CHANGED
|
@@ -18,6 +18,11 @@ Validate choices, scores, probabilities, actual model/routing, usage and unknown
|
|
|
18
18
|
cost handling. Measure live accuracy and calibration separately from connection
|
|
19
19
|
success. Do not assert a universal confidence cutoff or guaranteed live label.
|
|
20
20
|
|
|
21
|
+
For core 0.7.4+ classification, use `mockAI({ classify: ['billing'] })` and test
|
|
22
|
+
through `runCapability()` / `simulateFlow()`. Integration tests should assert
|
|
23
|
+
provider/model forwarding, zero/multiple matches, inclusive thresholds, and one
|
|
24
|
+
`classify` cost row. Use injected fetch; routine tests do not require live Laya.
|
|
25
|
+
|
|
21
26
|
For core 0.7.3+ integration tests, configure `mockAI({ decide: result })` or a real
|
|
22
27
|
`createAIService({ decisions, costTracker, onAICostRecorded })` with injected
|
|
23
28
|
provider fetch. Assert exactly one cost row, identity, actual model/usage, unknown
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumbus/ai-decision-laya",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Self-hosted Laya typed decision adapter and Python reference service for Plumbus.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"@types/node": "^25.4.0",
|
|
44
44
|
"typescript": "^5.7.0",
|
|
45
45
|
"vitest": "^3.2.4",
|
|
46
|
-
"@plumbus/core": "0.7.
|
|
46
|
+
"@plumbus/core": "0.7.9"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@plumbus/ai-decision": "~0.2.
|
|
49
|
+
"@plumbus/ai-decision": "~0.2.3"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsc -b",
|
|
@@ -108,7 +108,14 @@ class ServiceRoundTwo(unittest.TestCase):
|
|
|
108
108
|
first.start()
|
|
109
109
|
try:
|
|
110
110
|
self.assertTrue(entered.wait(1))
|
|
111
|
-
|
|
111
|
+
# Capacity is rejected before request bytes are read. Sending a body
|
|
112
|
+
# here races the server closing the rejected connection.
|
|
113
|
+
with socket.create_connection(server.server_address, timeout=2) as rejected:
|
|
114
|
+
response = http.client.HTTPResponse(rejected)
|
|
115
|
+
response.begin()
|
|
116
|
+
self.assertEqual(response.status, 503)
|
|
117
|
+
self.assertEqual(response.getheader("Retry-After"), "1")
|
|
118
|
+
self.assertEqual(json.loads(response.read()), {"error": "Service connection capacity reached"})
|
|
112
119
|
finish.set()
|
|
113
120
|
first.join(2)
|
|
114
121
|
self.assertEqual(results, [200])
|