Skip to content

Commit b470466

Browse files
committed
integrate cache read/write data
1 parent d1f9311 commit b470466

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/opencode/src/provider/models.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export namespace ModelsDev {
1717
cost: z.object({
1818
input: z.number(),
1919
output: z.number(),
20-
inputCached: z.number(),
21-
outputCached: z.number(),
20+
cache_read: z.number().optional(),
21+
cache_write: z.number().optional(),
2222
}),
2323
limit: z.object({
2424
context: z.number(),

packages/opencode/src/session/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,16 @@ export namespace Session {
759759
cost: new Decimal(0)
760760
.add(new Decimal(tokens.input).mul(model.cost.input).div(1_000_000))
761761
.add(new Decimal(tokens.output).mul(model.cost.output).div(1_000_000))
762+
.add(
763+
new Decimal(tokens.cache.read)
764+
.mul(model.cost.cache_read ?? 0)
765+
.div(1_000_000),
766+
)
767+
.add(
768+
new Decimal(tokens.cache.write)
769+
.mul(model.cost.cache_write ?? 0)
770+
.div(1_000_000),
771+
)
762772
.toNumber(),
763773
tokens,
764774
}

0 commit comments

Comments
 (0)