@agent-inspect/langchain 6.28.0 → 6.29.0
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 +9 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +9 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -235,6 +235,9 @@ interface TokenUsage {
|
|
|
235
235
|
input?: number;
|
|
236
236
|
output?: number;
|
|
237
237
|
total?: number;
|
|
238
|
+
cached?: number;
|
|
239
|
+
cacheWrite?: number;
|
|
240
|
+
reasoning?: number;
|
|
238
241
|
}
|
|
239
242
|
/** Extract token usage from LangChain / provider-shaped LLM outputs. Never throws. */
|
|
240
243
|
declare function extractTokenUsage(output: unknown): TokenUsage | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -235,6 +235,9 @@ interface TokenUsage {
|
|
|
235
235
|
input?: number;
|
|
236
236
|
output?: number;
|
|
237
237
|
total?: number;
|
|
238
|
+
cached?: number;
|
|
239
|
+
cacheWrite?: number;
|
|
240
|
+
reasoning?: number;
|
|
238
241
|
}
|
|
239
242
|
/** Extract token usage from LangChain / provider-shaped LLM outputs. Never throws. */
|
|
240
243
|
declare function extractTokenUsage(output: unknown): TokenUsage | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -22,13 +22,21 @@ function normalizeTokenShape(raw) {
|
|
|
22
22
|
if (total === void 0 && input !== void 0 && output !== void 0) {
|
|
23
23
|
total = input + output;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const inputDetails = isRecord(raw.input_token_details) ? raw.input_token_details : isRecord(raw.inputTokenDetails) ? raw.inputTokenDetails : void 0;
|
|
26
|
+
const outputDetails = isRecord(raw.output_token_details) ? raw.output_token_details : isRecord(raw.outputTokenDetails) ? raw.outputTokenDetails : void 0;
|
|
27
|
+
const cached = num(raw.cached) ?? num(raw.cache_read) ?? num(raw.cacheRead) ?? (inputDetails ? num(inputDetails.cache_read) ?? num(inputDetails.cacheRead) : void 0);
|
|
28
|
+
const cacheWrite = num(raw.cacheWrite) ?? num(raw.cache_write) ?? num(raw.cache_creation) ?? (inputDetails ? num(inputDetails.cache_creation) ?? num(inputDetails.cache_write) ?? num(inputDetails.cacheWrite) : void 0);
|
|
29
|
+
const reasoning = num(raw.reasoning) ?? num(raw.reasoning_tokens) ?? (outputDetails ? num(outputDetails.reasoning) ?? num(outputDetails.reasoning_tokens) : void 0);
|
|
30
|
+
if (input === void 0 && output === void 0 && total === void 0 && cached === void 0 && cacheWrite === void 0 && reasoning === void 0) {
|
|
26
31
|
return void 0;
|
|
27
32
|
}
|
|
28
33
|
const out = {};
|
|
29
34
|
if (input !== void 0) out.input = input;
|
|
30
35
|
if (output !== void 0) out.output = output;
|
|
31
36
|
if (total !== void 0) out.total = total;
|
|
37
|
+
if (cached !== void 0) out.cached = cached;
|
|
38
|
+
if (cacheWrite !== void 0) out.cacheWrite = cacheWrite;
|
|
39
|
+
if (reasoning !== void 0) out.reasoning = reasoning;
|
|
32
40
|
return out;
|
|
33
41
|
}
|
|
34
42
|
function extractTokenUsage(output) {
|