@jambonz/llm 0.6.5 → 0.6.6
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.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +11 -3
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.js +11 -3
- package/dist/test-kit/index.js.map +1 -1
- package/package.json +1 -1
package/dist/test-kit/index.cjs
CHANGED
|
@@ -174,12 +174,20 @@ async function* streamFromOpenAI(client, req, options) {
|
|
|
174
174
|
throw new Error(`OpenAI-compatible stream returned an error: ${message}`);
|
|
175
175
|
}
|
|
176
176
|
if (chunk.usage) {
|
|
177
|
-
const
|
|
177
|
+
const details = chunk.usage.prompt_tokens_details;
|
|
178
|
+
const cachedTokens = details?.cached_tokens;
|
|
179
|
+
const cacheWriteTokens = details?.cache_write_tokens;
|
|
178
180
|
usage = {
|
|
179
|
-
...chunk.usage.prompt_tokens !== void 0 ? {
|
|
181
|
+
...chunk.usage.prompt_tokens !== void 0 ? {
|
|
182
|
+
inputTokens: Math.max(
|
|
183
|
+
0,
|
|
184
|
+
chunk.usage.prompt_tokens - (cachedTokens ?? 0) - (cacheWriteTokens ?? 0)
|
|
185
|
+
)
|
|
186
|
+
} : {},
|
|
180
187
|
...chunk.usage.completion_tokens !== void 0 ? { outputTokens: chunk.usage.completion_tokens } : {},
|
|
181
188
|
...chunk.usage.total_tokens !== void 0 ? { totalTokens: chunk.usage.total_tokens } : {},
|
|
182
|
-
...cachedTokens !== void 0 ? { cacheReadTokens: cachedTokens } : {}
|
|
189
|
+
...cachedTokens !== void 0 ? { cacheReadTokens: cachedTokens } : {},
|
|
190
|
+
...cacheWriteTokens !== void 0 ? { cacheWriteTokens } : {}
|
|
183
191
|
};
|
|
184
192
|
}
|
|
185
193
|
const choice = chunk.choices?.[0];
|