Explorar el Código

fix: default value for models with no cost object (#1601)

Mahamed-Belkheir hace 6 meses
padre
commit
5bf7691ea6
Se han modificado 1 ficheros con 4 adiciones y 4 borrados
  1. 4 4
      packages/opencode/src/session/index.ts

+ 4 - 4
packages/opencode/src/session/index.ts

@@ -1344,10 +1344,10 @@ export namespace Session {
     }
     }
     return {
     return {
       cost: new Decimal(0)
       cost: new Decimal(0)
-        .add(new Decimal(tokens.input).mul(model.cost.input).div(1_000_000))
-        .add(new Decimal(tokens.output).mul(model.cost.output).div(1_000_000))
-        .add(new Decimal(tokens.cache.read).mul(model.cost.cache_read ?? 0).div(1_000_000))
-        .add(new Decimal(tokens.cache.write).mul(model.cost.cache_write ?? 0).div(1_000_000))
+        .add(new Decimal(tokens.input).mul(model.cost?.input?? 0).div(1_000_000))
+        .add(new Decimal(tokens.output).mul(model.cost?.output?? 0).div(1_000_000))
+        .add(new Decimal(tokens.cache.read).mul(model.cost?.cache_read ?? 0).div(1_000_000))
+        .add(new Decimal(tokens.cache.write).mul(model.cost?.cache_write ?? 0).div(1_000_000))
         .toNumber(),
         .toNumber(),
       tokens,
       tokens,
     }
     }