@oisin-ee/oisinpi 0.9.0 → 0.9.2
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 +20 -0
- package/node_modules/@oisin-ee/pi-guardrails/package.json +1 -1
- package/node_modules/@oisin-ee/pi-prewalk/package.json +1 -1
- package/node_modules/@oisin-ee/pi-tiers/package.json +1 -1
- package/node_modules/@oisin-ee/pi-tiers/src/policy.ts +3 -1
- package/node_modules/@oisin-ee/pi-tiers/src/recovery.ts +3 -1
- package/node_modules/@oisin-ee/pi-tiers/src/router.ts +31 -6
- package/node_modules/@oisin-ee/pi-todo/package.json +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @oisin-ee/oisinpi
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`3e750ac`](https://github.com/oisin-ee/oisinpi/commit/3e750ace481cfcf55296da1df034473d86d74347)]:
|
|
8
|
+
- @oisin-ee/pi-tiers@0.9.2
|
|
9
|
+
- @oisin-ee/pi-guardrails@0.9.2
|
|
10
|
+
- @oisin-ee/pi-prewalk@0.9.2
|
|
11
|
+
- @oisin-ee/pi-todo@0.9.2
|
|
12
|
+
|
|
13
|
+
## 0.9.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`bcba2d4`](https://github.com/oisin-ee/oisinpi/commit/bcba2d42673c2cf12c23b62079c2a96c0b098e30)]:
|
|
18
|
+
- @oisin-ee/pi-tiers@0.9.1
|
|
19
|
+
- @oisin-ee/pi-guardrails@0.9.1
|
|
20
|
+
- @oisin-ee/pi-prewalk@0.9.1
|
|
21
|
+
- @oisin-ee/pi-todo@0.9.1
|
|
22
|
+
|
|
3
23
|
## 0.9.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -77,7 +77,9 @@ const ZERO = 0,
|
|
|
77
77
|
["minimax-", "minimax"],
|
|
78
78
|
],
|
|
79
79
|
pool =
|
|
80
|
-
pools.find(([prefix]: readonly string[]) => id.startsWith(prefix ?? ""))?.[
|
|
80
|
+
pools.find(([prefix]: readonly string[]) => id.toLowerCase().startsWith(prefix ?? ""))?.[
|
|
81
|
+
ONE
|
|
82
|
+
] ?? provider;
|
|
81
83
|
return { id, pool, provider };
|
|
82
84
|
};
|
|
83
85
|
|
|
@@ -9,6 +9,7 @@ import type { Context } from "./ports.ts";
|
|
|
9
9
|
import type { Router } from "./router.ts";
|
|
10
10
|
import type { Tiers } from "./config.ts";
|
|
11
11
|
import { classify } from "./policy.ts";
|
|
12
|
+
import { listed } from "./router.ts";
|
|
12
13
|
|
|
13
14
|
const ZERO = 0,
|
|
14
15
|
ONE = 1;
|
|
@@ -76,7 +77,8 @@ class Recovery {
|
|
|
76
77
|
}
|
|
77
78
|
const tier = ctx.model.id,
|
|
78
79
|
state = branchState(ctx.sessionManager.getBranch(), tier),
|
|
79
|
-
|
|
80
|
+
tierTargets = this.#tiers.get(tier),
|
|
81
|
+
targets = tierTargets === undefined ? undefined : listed(tierTargets, ctx),
|
|
80
82
|
message = event.context.contextMessages.findLast((item) => item.role === "assistant"),
|
|
81
83
|
entry = event.context.contextEntries.findLast(
|
|
82
84
|
(item: Readonly<{ sourceEntry: SessionEntry; messages: readonly unknown[] }>) =>
|
|
@@ -10,7 +10,29 @@ import type { Window } from "./quota.ts";
|
|
|
10
10
|
|
|
11
11
|
const ZERO = 0,
|
|
12
12
|
ONE = 1,
|
|
13
|
-
CACHE_MS = 60_000
|
|
13
|
+
CACHE_MS = 60_000,
|
|
14
|
+
/**
|
|
15
|
+
* Resolves tier targets to the references the model registry lists. Provider model
|
|
16
|
+
* ids differ in case from the tier file (`MiniMax-M3.1-Flash`), so matching ignores
|
|
17
|
+
* case and returns the registry's exact reference. A target that is not listed yet
|
|
18
|
+
* behaves like an unavailable target instead of a terminal error.
|
|
19
|
+
* @param {readonly string[]} targets Ordered tier.
|
|
20
|
+
* @param {Context} ctx Pi authority.
|
|
21
|
+
* @returns {readonly string[]} Listed registry references, in tier order.
|
|
22
|
+
*/
|
|
23
|
+
listed = (targets: readonly string[], ctx: Context): readonly string[] => {
|
|
24
|
+
const available = new Map(
|
|
25
|
+
ctx.modelRegistry.getAvailable().map((candidate) => {
|
|
26
|
+
const reference = `${candidate.provider}/${candidate.id}`;
|
|
27
|
+
return [reference.toLowerCase(), reference];
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
return targets.flatMap((reference) => {
|
|
31
|
+
const parsed = target(reference),
|
|
32
|
+
found = available.get(`${parsed.provider}/${parsed.id}`.toLowerCase());
|
|
33
|
+
return found === undefined ? [] : [found];
|
|
34
|
+
});
|
|
35
|
+
};
|
|
14
36
|
|
|
15
37
|
/** Sticky routing with host-wide quota and gateway health. */
|
|
16
38
|
class Router {
|
|
@@ -139,19 +161,20 @@ class Router {
|
|
|
139
161
|
|
|
140
162
|
/**
|
|
141
163
|
* Routes a tier without fabricating conversation messages.
|
|
142
|
-
* @param {readonly string[]}
|
|
164
|
+
* @param {readonly string[]} tier Ordered physical models, listed or not.
|
|
143
165
|
* @param {Request} request Pi request.
|
|
144
166
|
* @param {Context} ctx Pi authority.
|
|
145
167
|
* @returns {Promise<ModelRoute<State>>} Physical dispatch.
|
|
146
168
|
*/
|
|
147
169
|
public async route(
|
|
148
|
-
|
|
170
|
+
tier: readonly string[],
|
|
149
171
|
request: Request,
|
|
150
172
|
ctx: Context,
|
|
151
173
|
): Promise<ModelRoute<State>> {
|
|
152
174
|
request.signal?.throwIfAborted();
|
|
153
175
|
await this.#refresh();
|
|
154
|
-
const
|
|
176
|
+
const targets = listed(tier, ctx),
|
|
177
|
+
previous =
|
|
155
178
|
request.reason === "direct"
|
|
156
179
|
? undefined
|
|
157
180
|
: (branchState(ctx.sessionManager.getBranch(), request.model.id) ?? request.state),
|
|
@@ -163,7 +186,9 @@ class Router {
|
|
|
163
186
|
state = await this.#retry(request, current),
|
|
164
187
|
health = await this.#effects.read(),
|
|
165
188
|
chosen =
|
|
166
|
-
|
|
189
|
+
targets.includes(state.chosen) &&
|
|
190
|
+
!state.attempted.includes(state.chosen) &&
|
|
191
|
+
this.#available(state.chosen, health)
|
|
167
192
|
? state.chosen
|
|
168
193
|
: await this.next(targets, state);
|
|
169
194
|
if (chosen === undefined) {
|
|
@@ -173,4 +198,4 @@ class Router {
|
|
|
173
198
|
}
|
|
174
199
|
}
|
|
175
200
|
|
|
176
|
-
export { Router };
|
|
201
|
+
export { Router, listed };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oisin-ee/oisinpi",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Oisin's pi packages in one install: prewalk, todo, tiers, and guardrails.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"guardrails",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@oisin-ee/pi-guardrails": "0.9.
|
|
21
|
-
"@oisin-ee/pi-prewalk": "0.9.
|
|
22
|
-
"@oisin-ee/pi-tiers": "0.9.
|
|
23
|
-
"@oisin-ee/pi-todo": "0.9.
|
|
20
|
+
"@oisin-ee/pi-guardrails": "0.9.2",
|
|
21
|
+
"@oisin-ee/pi-prewalk": "0.9.2",
|
|
22
|
+
"@oisin-ee/pi-tiers": "0.9.2",
|
|
23
|
+
"@oisin-ee/pi-todo": "0.9.2"
|
|
24
24
|
},
|
|
25
25
|
"bundleDependencies": [
|
|
26
26
|
"@oisin-ee/pi-guardrails",
|