@oisin-ee/pi-tiers 0.9.1 → 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/package.json +1 -1
- package/src/policy.ts +3 -1
- package/src/router.ts +14 -8
package/package.json
CHANGED
package/src/policy.ts
CHANGED
|
@@ -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
|
|
package/src/router.ts
CHANGED
|
@@ -12,19 +12,25 @@ const ZERO = 0,
|
|
|
12
12
|
ONE = 1,
|
|
13
13
|
CACHE_MS = 60_000,
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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.
|
|
17
19
|
* @param {readonly string[]} targets Ordered tier.
|
|
18
20
|
* @param {Context} ctx Pi authority.
|
|
19
|
-
* @returns {readonly string[]} Listed
|
|
21
|
+
* @returns {readonly string[]} Listed registry references, in tier order.
|
|
20
22
|
*/
|
|
21
23
|
listed = (targets: readonly string[], ctx: Context): readonly string[] => {
|
|
22
|
-
const available = new
|
|
23
|
-
ctx.modelRegistry.getAvailable().map((candidate) =>
|
|
24
|
+
const available = new Map(
|
|
25
|
+
ctx.modelRegistry.getAvailable().map((candidate) => {
|
|
26
|
+
const reference = `${candidate.provider}/${candidate.id}`;
|
|
27
|
+
return [reference.toLowerCase(), reference];
|
|
28
|
+
}),
|
|
24
29
|
);
|
|
25
|
-
return targets.
|
|
26
|
-
const parsed = target(reference)
|
|
27
|
-
|
|
30
|
+
return targets.flatMap((reference) => {
|
|
31
|
+
const parsed = target(reference),
|
|
32
|
+
found = available.get(`${parsed.provider}/${parsed.id}`.toLowerCase());
|
|
33
|
+
return found === undefined ? [] : [found];
|
|
28
34
|
});
|
|
29
35
|
};
|
|
30
36
|
|