@haoyiyin/9router 0.1.5 → 0.1.6
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 +3 -3
- package/package.json +1 -1
- package/src/config.ts +5 -4
- package/src/provider.ts +11 -7
package/README.md
CHANGED
|
@@ -18,15 +18,15 @@ Environment variables are supported as a fallback: `ROUTER_API_BASE` / `ROUTER_A
|
|
|
18
18
|
|
|
19
19
|
## Combo models & thinking
|
|
20
20
|
|
|
21
|
-
Combo models (`sub` / `free` / `main`, `owned_by: "combo"`) advertise no capabilities, so reasoning is
|
|
21
|
+
Combo models (`sub` / `free` / `main`, `owned_by: "combo"`) advertise no capabilities from the router, so their reasoning is decided by `comboReasoning` in `~/.pi/agent/haoyiyin/9router.json`. It defaults to **on** (assumes combo routes hit thinking-capable upstreams) with the standard `off..high` range. Opt out per machine with:
|
|
22
22
|
|
|
23
23
|
```json
|
|
24
24
|
{
|
|
25
|
-
"comboReasoning":
|
|
25
|
+
"comboReasoning": false
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
To unlock `max`/`xhigh`, pass a custom `thinkingLevelMap` (keys: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`; values: what gets sent to the router, `null` hides the level):
|
|
30
30
|
|
|
31
31
|
```json
|
|
32
32
|
{
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -8,9 +8,10 @@ export interface RouterConfig {
|
|
|
8
8
|
baseUrl: string;
|
|
9
9
|
apiKey: string;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* Combo models carry no capabilities from the router, so
|
|
13
|
-
*
|
|
11
|
+
* Force reasoning:true onto combo models (`owned_by === "combo"`).
|
|
12
|
+
* Combo models carry no capabilities from the router, so this switch decides
|
|
13
|
+
* their reasoning status. Defaults to `true` (combo routes are assumed to hit
|
|
14
|
+
* thinking-capable upstreams); set `false` to opt out, or pass a custom
|
|
14
15
|
* `thinkingLevelMap` to unlock max/xhigh on the combo routes.
|
|
15
16
|
*/
|
|
16
17
|
comboReasoning?: boolean | { thinkingLevelMap?: Record<string, string | null> };
|
|
@@ -49,7 +50,7 @@ export function loadConfig(): RouterConfig {
|
|
|
49
50
|
|
|
50
51
|
const apiKey = fileKey ?? process.env.ROUTER_API_KEY ?? "";
|
|
51
52
|
|
|
52
|
-
return { baseUrl, apiKey, comboReasoning };
|
|
53
|
+
return { baseUrl, apiKey, comboReasoning: comboReasoning ?? true };
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export function saveConfig(cfg: RouterConfig): void {
|
package/src/provider.ts
CHANGED
|
@@ -85,8 +85,8 @@ function getThinkingFormat(model: RouterModel): "openai" | "deepseek" {
|
|
|
85
85
|
/**
|
|
86
86
|
* Derive pi's thinkingLevelMap from the router's advertised capabilities.
|
|
87
87
|
* DeepSeek exposes low/high/max (mirrors pi's own deepseek catalog); openai-style
|
|
88
|
-
* models
|
|
89
|
-
*
|
|
88
|
+
* models expose off..max, hiding `off` when thinking cannot be disabled. No map
|
|
89
|
+
* is returned when the backend does not declare reasoning.
|
|
90
90
|
*/
|
|
91
91
|
export function getThinkingLevelMap(
|
|
92
92
|
model: RouterModel,
|
|
@@ -96,15 +96,19 @@ export function getThinkingLevelMap(
|
|
|
96
96
|
if (cap.thinkingFormat === "deepseek") {
|
|
97
97
|
return { minimal: null, low: "low", medium: null, high: "high", max: "max" };
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
// openai-style: reasoning_effort takes the level name directly. Unlock
|
|
100
|
+
// xhigh/max, and hide off when thinking cannot be disabled.
|
|
101
|
+
return {
|
|
102
|
+
...(cap.thinkingCanDisable === false ? { off: null } : {}),
|
|
103
|
+
xhigh: "xhigh",
|
|
104
|
+
max: "max",
|
|
105
|
+
};
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
/**
|
|
104
109
|
* Combo models (`owned_by === "combo"`) carry no capabilities from the router, so
|
|
105
|
-
* reasoning is
|
|
106
|
-
*
|
|
107
|
-
* `true` for the default off..high range, or an object with a custom
|
|
110
|
+
* their reasoning is decided by `comboReasoning` in 9router.json: default `true`
|
|
111
|
+
* (off..high range), `false` disables, or an object with a custom
|
|
108
112
|
* `thinkingLevelMap` to unlock max/xhigh.
|
|
109
113
|
*/
|
|
110
114
|
export function resolveComboOptIn(
|