claudish 3.3.8 → 3.3.10
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/dist/index.js +7 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57001,10 +57001,11 @@ class OpenAIHandler {
|
|
|
57001
57001
|
}
|
|
57002
57002
|
}
|
|
57003
57003
|
updateTokenTracking(inputTokens, outputTokens) {
|
|
57004
|
+
const incrementalInputTokens = Math.max(0, inputTokens - this.sessionInputTokens);
|
|
57004
57005
|
this.sessionInputTokens = inputTokens;
|
|
57005
57006
|
this.sessionOutputTokens += outputTokens;
|
|
57006
57007
|
const pricing = this.getPricing();
|
|
57007
|
-
const cost =
|
|
57008
|
+
const cost = incrementalInputTokens / 1e6 * pricing.inputCostPer1M + outputTokens / 1e6 * pricing.outputCostPer1M;
|
|
57008
57009
|
this.sessionTotalCost += cost;
|
|
57009
57010
|
this.writeTokenFile(inputTokens, this.sessionOutputTokens);
|
|
57010
57011
|
}
|
|
@@ -57190,6 +57191,7 @@ class OpenAIHandler {
|
|
|
57190
57191
|
const functionCalls = new Map;
|
|
57191
57192
|
const stream = new ReadableStream({
|
|
57192
57193
|
start: async (controller) => {
|
|
57194
|
+
log(`[OpenAIHandler] Sending message_start with placeholder tokens`);
|
|
57193
57195
|
const messageStart = {
|
|
57194
57196
|
type: "message_start",
|
|
57195
57197
|
message: {
|
|
@@ -57206,6 +57208,10 @@ class OpenAIHandler {
|
|
|
57206
57208
|
controller.enqueue(encoder.encode(`event: message_start
|
|
57207
57209
|
data: ${JSON.stringify(messageStart)}
|
|
57208
57210
|
|
|
57211
|
+
`));
|
|
57212
|
+
controller.enqueue(encoder.encode(`event: ping
|
|
57213
|
+
data: {"type":"ping"}
|
|
57214
|
+
|
|
57209
57215
|
`));
|
|
57210
57216
|
try {
|
|
57211
57217
|
while (true) {
|