@guojinpeng/dsh-cost-meter 0.1.4 → 0.1.5

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 CHANGED
@@ -76,10 +76,10 @@ npm pack
76
76
  ```
77
77
 
78
78
  `npm pack` also runs the build. It creates `guojinpeng-dsh-cost-meter-<version>.tgz`.
79
- Install the generated file in your DSH profile. For version 0.1.4:
79
+ Install the generated file in your DSH profile. For version 0.1.5:
80
80
 
81
81
  ```powershell
82
- dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.4.tgz
82
+ dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.5.tgz
83
83
  ```
84
84
 
85
85
  Restart DSH and check the plugin. Repeat the build, package and install steps after changes.
@@ -125,7 +125,7 @@ After npm publication succeeds, create the matching Git tag and GitHub Release:
125
125
  ```powershell
126
126
  git tag v<version>
127
127
  git push origin v<version>
128
- gh release create v<version> --verify-tag --title "v<version>" --generate-notes --latest
128
+ gh release create v<version> --verify-tag --title "<version>" --generate-notes --latest
129
129
  ```
130
130
 
131
131
  Replace `<version>` before you run these commands. GitHub Releases contain release
package/README.zh-CN.md CHANGED
@@ -76,10 +76,10 @@ npm pack
76
76
  ```
77
77
 
78
78
  `npm pack` 也会执行构建,生成 `guojinpeng-dsh-cost-meter-<版本号>.tgz`。
79
- 将生成的文件安装到你的 DSH profile。以 0.1.4 为例:
79
+ 将生成的文件安装到你的 DSH profile。以 0.1.5 为例:
80
80
 
81
81
  ```powershell
82
- dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.4.tgz
82
+ dsh plugin --profile web add -w ./guojinpeng-dsh-cost-meter-0.1.5.tgz
83
83
  ```
84
84
 
85
85
  重启 DSH,检查插件。每次修改后,重新构建、打包并安装。
@@ -125,7 +125,7 @@ npm 发布成功后,创建对应的 Git 标签和 GitHub Release:
125
125
  ```powershell
126
126
  git tag v<version>
127
127
  git push origin v<version>
128
- gh release create v<version> --verify-tag --title "v<version>" --generate-notes --latest
128
+ gh release create v<version> --verify-tag --title "<version>" --generate-notes --latest
129
129
  ```
130
130
 
131
131
  执行前替换 `<version>`。GitHub Release 用于发布说明,无需上传安装包。
package/dist/client.js CHANGED
@@ -261,7 +261,7 @@ function createUseCostView(react, store) {
261
261
  const raw = props.useProjection(PROJECTION_KEY);
262
262
  const snapshot = react.useSyncExternalStore(store.subscribe, store.getSnapshot);
263
263
  const loadStatus = react.useSyncExternalStore(store.subscribe, store.getLoadStatus);
264
- const missing = !snapshot || (raw == null ? void 0 : raw.accounting) && Object.keys(raw.accounting.byRoute).some((key) => key && !snapshot.config.pricing[key]);
264
+ const missing = snapshot ? (raw == null ? void 0 : raw.accounting) && Object.keys(raw.accounting.byRoute).some((key) => key && !snapshot.config.pricing[key]) : !raw || raw.unpricedTokens !== 0;
265
265
  react.useEffect(() => {
266
266
  if (!snapshot || (raw == null ? void 0 : raw.accounting) && Object.keys(raw.accounting.byRoute).some((key) => key && !snapshot.config.pricing[key]))
267
267
  store.load().catch(() => {
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ function createHistoryModels(sessionQuery, { readConfig: readConfig2, writeConfi
116
116
  let missing;
117
117
  do {
118
118
  missing = Object.fromEntries([...models].filter(needsPrice).map((key) => [key, zeroRate()]));
119
- if (!initializedOnce || Object.keys(missing).length) {
119
+ if (Object.keys(missing).length || !initializedOnce && !Object.keys(config.pricing).length) {
120
120
  initializedOnce = true;
121
121
  try {
122
122
  Object.assign(initialized, (await initializePrices({ ...config, pricing: missing })).config.pricing);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guojinpeng/dsh-cost-meter",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "DSH 会话和每轮费用估算插件,支持 models.dev 价格同步与自定义模型单价。配置位于 ~/.dsh/guojinpeng/dsh-cost-meter/config.json。",
6
6
  "license": "MIT",