Skip to content

Commit 582b262

Browse files
author
Theodore Li
committed
Simplify logic
1 parent a7839a1 commit 582b262

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

apps/sim/providers/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ function isReadableStream(response: any): response is ReadableStream {
5454
return response instanceof ReadableStream
5555
}
5656

57-
const ZERO_COST = Object.freeze({ input: 0, output: 0, total: 0 })
57+
const ZERO_COST = Object.freeze({
58+
input: 0,
59+
output: 0,
60+
total: 0,
61+
pricing: Object.freeze({ input: 0, output: 0, updatedAt: '' }),
62+
})
5863

5964
/**
60-
* Zeros out cost on a StreamingExecution for BYOK users.
61-
* Providers calculate cost inside streaming callbacks, so we override the cost
62-
* property on execution.output to always return zero regardless of callback writes.
65+
* Prevents streaming callbacks from writing non-zero cost for BYOK users.
66+
* The property is frozen via defineProperty because providers set cost inside
67+
* streaming callbacks that fire after this function returns.
6368
*/
6469
function zeroCostForBYOK(response: StreamingExecution): void {
6570
const output = response.execution?.output
@@ -113,11 +118,6 @@ export async function executeProviderRequest(
113118
})
114119
throw error
115120
}
116-
} else {
117-
logger.info('No workspaceId provided, skipping BYOK check', {
118-
provider: providerId,
119-
model: request.model,
120-
})
121121
}
122122

123123
resolvedRequest.isBYOK = isBYOK

0 commit comments

Comments
 (0)