pi-siliconflow 1.0.0 → 1.1.0

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 CHANGED
@@ -1,9 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.0] - 2026-12-05
4
+
5
+ ### Added
6
+ - Every `session_start` (startup / reload / new session) now force-refreshes the SiliconFlow model catalog in the background, so `/model` always shows current prices and new releases; failures keep the cached catalog.
7
+ - `/sf-models-refresh` command to manually force-refresh on demand, with a notification on success (model count) or failure (cache kept).
8
+
3
9
  ## [1.0.0] - 2026-12-04
4
10
 
5
11
  ### Added
6
- - SiliconFlow provider:`/login siliconflow` 管理 API key(auth.json / SILICONFLOW_API_KEY)
7
- - 官网模型目录同步(上下文、价格、视觉/思考能力),离线缓存 + `/v1/models` 兜底
8
- - `EXCLUDE`/`INCLUDE` 黑白名单控制 `/model` 里的模型数量
9
- - 保守 compat:不发 `store`/`reasoning_effort`,max_tokens 字段
12
+ - SiliconFlow provider: `/login siliconflow` manages the API key (auth.json / SILICONFLOW_API_KEY)
13
+ - Website model catalog sync (context, price, vision/reasoning), offline cache + `/v1/models` fallback
14
+ - `EXCLUDE`/`INCLUDE` allow/deny lists to control the number of models in `/model`
15
+ - Conservative compat: no `store`/`reasoning_effort`, `max_tokens` field
@@ -8,10 +8,16 @@
8
8
  * pi auth check --provider siliconflow 检查是否就绪
9
9
  * export SILICONFLOW_API_KEY=sk-... 环境变量方式(已保存的 key 优先于环境变量)
10
10
  *
11
- * 模型目录:启动、打开 /model、/login 之后自动刷新。数据来自硅基流动官网目录接口
11
+ * 模型目录:打开 /model、/login 之后会自动刷新。数据来自硅基流动官网目录接口
12
12
  * (含上下文长度、¥ 价格、视觉/思考能力、工具调用),成功后缓存到 models-store.json
13
13
  * 供离线启动使用;官网目录不可用时退回官方 /v1/models?sub_type=chat(仅模型 id)。
14
14
  *
15
+ * 目录更新:
16
+ * - 每次 session_start(启动、新会话、/reload 等)后台强制刷新一次目录,
17
+ * 确保 /model 里永远是最新价格与上新;离线则自动回退缓存,不影响使用。
18
+ * - /sf-models-refresh 手动强制刷新,完成后提醒结果。
19
+ *
20
+ *
15
21
  * 目录瘦身(控制 /model 里 siliconflow 的条数,见下面 INCLUDE / EXCLUDE):
16
22
  * 1. 自动去掉与免费版同款的 `Pro/` 变体(同 targetModelName)
17
23
  * 2. EXCLUDE 黑名单:专用模型(OCR/字幕)+ 已被替代的老模型
@@ -281,4 +287,47 @@ export default function (pi: ExtensionAPI) {
281
287
  fetchModels: refreshCatalog,
282
288
  }),
283
289
  );
290
+
291
+ // 每次会话启动(startup / reload / new / resume / fork)后台强制刷新目录,
292
+ // 价格与上新变动及时反映到 /model;失败时保留缓存,不影响启动。
293
+ pi.on("session_start", (_event, ctx) => {
294
+ if (!ctx.modelRegistry.getProvider(PROVIDER_ID)) return;
295
+ void ctx.modelRegistry
296
+ .refresh({ force: true, providers: [PROVIDER_ID] })
297
+ .catch(() => {
298
+ // 网络问题等:保留 models-store.json 的缓存目录即可。
299
+ });
300
+ });
301
+
302
+ // 手动强制刷新。
303
+ pi.registerCommand("sf-models-refresh", {
304
+ description: "强制刷新硅基流动模型目录(价格/上新)",
305
+ handler: async (_args, ctx) => {
306
+ try {
307
+ const result = await ctx.modelRegistry.refresh({
308
+ force: true,
309
+ providers: [PROVIDER_ID],
310
+ });
311
+ const error = [...result.errors.entries()][0];
312
+ if (error) {
313
+ ctx.ui.notify(
314
+ `硅基流动目录刷新失败(保留缓存):${error[1].message}`,
315
+ "error",
316
+ );
317
+ } else if (result.aborted) {
318
+ ctx.ui.notify("硅基流动目录刷新超时,保留缓存", "warning");
319
+ } else {
320
+ const count = ctx.modelRegistry.getModelsOfType("chat", PROVIDER_ID).length;
321
+ ctx.ui.notify(`硅基流动目录已刷新:${count} 个 chat 模型`, "info");
322
+ }
323
+ } catch (error_) {
324
+ ctx.ui.notify(
325
+ `硅基流动目录刷新失败(保留缓存):${
326
+ error_ instanceof Error ? error_.message : String(error_)
327
+ }`,
328
+ "error",
329
+ );
330
+ }
331
+ },
332
+ });
284
333
  }
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "pi-siliconflow",
3
- "version": "1.0.0",
4
- "description": "Pi extension: SiliconFlow (硅基流动) provider — /login siliconflow to store the API key (auth.json), plus a live model catalog (context, price, vision/reasoning) with INCLUDE/EXCLUDE filtering.",
5
- "keywords": [
6
- "pi-package",
7
- "pi-extension",
8
- "siliconflow",
9
- "硅基流动",
10
- "provider",
11
- "openai-compatible"
12
- ],
13
- "license": "MIT",
14
- "author": "DHcurry",
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/DHcurry/pi-siliconflow.git"
18
- },
19
- "homepage": "https://github.com/DHcurry/pi-siliconflow#readme",
20
- "bugs": {
21
- "url": "https://github.com/DHcurry/pi-siliconflow/issues"
22
- },
23
- "type": "module",
24
- "files": [
25
- "extensions/",
26
- "README.md",
27
- "CHANGELOG.md",
28
- "LICENSE"
29
- ],
30
- "pi": {
31
- "extensions": [
32
- "./extensions/siliconflow.ts"
33
- ]
34
- },
35
- "peerDependencies": {
36
- "@earendil-works/pi-coding-agent": "*"
37
- },
38
- "engines": {
39
- "node": ">=18"
40
- }
1
+ {
2
+ "name": "pi-siliconflow",
3
+ "version": "1.1.0",
4
+ "description": "Pi extension: SiliconFlow (硅基流动) provider — /login siliconflow stores the API key, and the model catalog auto-refreshes on every session start (plus /sf-models-refresh), with INCLUDE/EXCLUDE filtering.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension",
8
+ "siliconflow",
9
+ "硅基流动",
10
+ "provider",
11
+ "openai-compatible"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "DHcurry",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/DHcurry/pi-siliconflow.git"
18
+ },
19
+ "homepage": "https://github.com/DHcurry/pi-siliconflow#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/DHcurry/pi-siliconflow/issues"
22
+ },
23
+ "type": "module",
24
+ "files": [
25
+ "extensions/",
26
+ "README.md",
27
+ "CHANGELOG.md",
28
+ "LICENSE"
29
+ ],
30
+ "pi": {
31
+ "extensions": [
32
+ "./extensions/siliconflow.ts"
33
+ ]
34
+ },
35
+ "peerDependencies": {
36
+ "@earendil-works/pi-coding-agent": "*"
37
+ },
38
+ "engines": {
39
+ "node": ">=18"
40
+ }
41
41
  }