pi-model-fallback 0.3.2 → 0.3.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 +6 -0
- package/README.md +131 -164
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
- Add Buy Me a Coffee sponsor button to README and native GitHub funding link via `.github/FUNDING.yml`.
|
|
6
6
|
|
|
7
|
+
## [0.3.3] - 2026-07-04
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Rewrite the README with real `pi-model-fallback` install, command, configuration, and state-path documentation instead of template placeholders.
|
|
12
|
+
|
|
7
13
|
## [0.3.2] - 2026-07-04
|
|
8
14
|
|
|
9
15
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,164 +1,131 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
[](LICENSE)
|
|
8
|
-
[](https://pi.dev/packages)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
pi install npm
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
pi install
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
pi
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
2. Run the **post-generation docs cleanup** in that checklist: delete or merge template bootstrap docs that no longer add project value.
|
|
133
|
-
|
|
134
|
-
Useful docs to keep when they add value:
|
|
135
|
-
|
|
136
|
-
- [`docs/examples.md`](docs/examples.md) — examples for extensions, skills, prompts, and themes
|
|
137
|
-
- [`docs/release.md`](docs/release.md) — Trusted Publishing details (README Release summarizes the flow)
|
|
138
|
-
- `docs/usage.md` — create when usage does not fit in README
|
|
139
|
-
|
|
140
|
-
Optional maintainer guidance (not a public-user navigation target in mature repos):
|
|
141
|
-
|
|
142
|
-
- [`docs/template-checklist.md`](docs/template-checklist.md)
|
|
143
|
-
|
|
144
|
-
Template bootstrap docs to delete or merge after setup unless they still teach something project-specific:
|
|
145
|
-
|
|
146
|
-
- `docs/github-template.md`
|
|
147
|
-
- `docs/repository-settings.md`
|
|
148
|
-
- `docs/typescript.md`
|
|
149
|
-
|
|
150
|
-
## Security
|
|
151
|
-
|
|
152
|
-
Pi packages can execute code with your local permissions. Review extensions before installing third-party packages.
|
|
153
|
-
|
|
154
|
-
For vulnerability reporting, see [`SECURITY.md`](SECURITY.md).
|
|
155
|
-
|
|
156
|
-
## Links
|
|
157
|
-
|
|
158
|
-
- npm: https://www.npmjs.com/package/PACKAGE_NAME
|
|
159
|
-
- GitHub: https://github.com/OWNER/REPO
|
|
160
|
-
- Issues: https://github.com/OWNER/REPO/issues
|
|
161
|
-
|
|
162
|
-
## License
|
|
163
|
-
|
|
164
|
-
MIT
|
|
1
|
+
# pi-model-fallback
|
|
2
|
+
|
|
3
|
+
[](https://github.com/eiei114/pi-model-fallback/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/eiei114/pi-model-fallback/actions/workflows/publish.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/pi-model-fallback)
|
|
6
|
+
[](https://www.npmjs.com/package/pi-model-fallback)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://pi.dev/packages)
|
|
9
|
+
<a href="https://buymeacoffee.com/ekawano114m"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" width="217" height="60"></a>
|
|
10
|
+
|
|
11
|
+
> Pi extension that switches to a fallback model after provider failures such as 429 rate limits.
|
|
12
|
+
|
|
13
|
+
## What this does
|
|
14
|
+
|
|
15
|
+
`pi-model-fallback` watches provider failures and automatically moves Pi to a safer fallback model when a matching rule fires.
|
|
16
|
+
|
|
17
|
+
Current default:
|
|
18
|
+
|
|
19
|
+
- source provider: `zai`
|
|
20
|
+
- matching statuses: `429`, `500`, `502`, `503`, `504`
|
|
21
|
+
- fallback model: `deepseek/deepseek-v4-flash`
|
|
22
|
+
|
|
23
|
+
When a failure matches, the extension also stores persistent fallback state so future sessions can preselect the fallback model until the cooldown expires.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
Install from npm:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pi install npm:pi-model-fallback
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Install into the current project only:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pi install npm:pi-model-fallback -l
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or install from GitHub:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pi install git:github.com/eiei114/pi-model-fallback
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Try it without permanently installing:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pi -e npm:pi-model-fallback
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Commands
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
/model-fallback:status
|
|
55
|
+
/model-fallback:reset
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- `status`: shows whether fallback is enabled, active persistent entries, and current paths
|
|
59
|
+
- `reset`: clears persistent fallback state and switches back to the remembered original model when possible
|
|
60
|
+
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
The extension exposes the `model_fallback_config` tool for reading, validating, and saving config JSON.
|
|
64
|
+
|
|
65
|
+
Default config shape:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"version": 1,
|
|
70
|
+
"enabled": true,
|
|
71
|
+
"rules": [
|
|
72
|
+
{
|
|
73
|
+
"name": "zai-to-deepseek-flash",
|
|
74
|
+
"matchProviders": ["zai"],
|
|
75
|
+
"statuses": [429, 500, 502, 503, 504],
|
|
76
|
+
"fallback": {
|
|
77
|
+
"provider": "deepseek",
|
|
78
|
+
"model": "deepseek-v4-flash"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Rule fields:
|
|
86
|
+
|
|
87
|
+
- `matchProviders`: match all models from a provider
|
|
88
|
+
- `matchModels`: match specific `provider` + `model` pairs
|
|
89
|
+
- `statuses`: optional; defaults to `429, 500, 502, 503, 504`
|
|
90
|
+
- `cooldownMs`: optional persistent fallback window
|
|
91
|
+
- `fallback`: target model Pi should switch to
|
|
92
|
+
|
|
93
|
+
## State and paths
|
|
94
|
+
|
|
95
|
+
The extension stores:
|
|
96
|
+
|
|
97
|
+
- config: `model-fallback/config.json`
|
|
98
|
+
- state: `model-fallback/state.json`
|
|
99
|
+
|
|
100
|
+
If the package is installed project-locally and the current project references it from `.pi/settings.json`, those files live under the project `.pi/` directory. Otherwise they live under the user agent directory.
|
|
101
|
+
|
|
102
|
+
## Behavior notes
|
|
103
|
+
|
|
104
|
+
- Successful responses do nothing.
|
|
105
|
+
- Matching failures from `after_provider_response` can trigger fallback immediately.
|
|
106
|
+
- Assistant error messages parsed at `turn_end` can also persist fallback state for SDK/provider failures that do not emit the normal response hook.
|
|
107
|
+
- The failed request is not automatically replayed.
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npm install
|
|
113
|
+
npm run ci
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Run locally in Pi:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pi -e .
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Links
|
|
123
|
+
|
|
124
|
+
- npm: https://www.npmjs.com/package/pi-model-fallback
|
|
125
|
+
- GitHub: https://github.com/eiei114/pi-model-fallback
|
|
126
|
+
- Issues: https://github.com/eiei114/pi-model-fallback/issues
|
|
127
|
+
- Usage notes: [`docs/usage.md`](docs/usage.md)
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT
|