@yeaft/webchat-agent 0.1.453 → 0.1.454
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/package.json +1 -1
- package/unify/engine.js +4 -0
- package/unify/web-bridge.js +1 -0
package/package.json
CHANGED
package/unify/engine.js
CHANGED
|
@@ -374,6 +374,7 @@ export class Engine {
|
|
|
374
374
|
});
|
|
375
375
|
|
|
376
376
|
const startTime = Date.now();
|
|
377
|
+
let ttfbMs = null; // Time to first token
|
|
377
378
|
let responseText = '';
|
|
378
379
|
const toolCalls = [];
|
|
379
380
|
let stopReason = 'end_turn';
|
|
@@ -393,6 +394,7 @@ export class Engine {
|
|
|
393
394
|
})) {
|
|
394
395
|
switch (event.type) {
|
|
395
396
|
case 'text_delta':
|
|
397
|
+
if (ttfbMs === null) ttfbMs = Date.now() - startTime;
|
|
396
398
|
responseText += event.text;
|
|
397
399
|
yield event;
|
|
398
400
|
break;
|
|
@@ -439,6 +441,7 @@ export class Engine {
|
|
|
439
441
|
toolCalls: toolCalls.map(tc => ({ id: tc.id, name: tc.name, input: tc.input })),
|
|
440
442
|
usage: { inputTokens: totalUsage.inputTokens, outputTokens: totalUsage.outputTokens },
|
|
441
443
|
latencyMs,
|
|
444
|
+
ttfbMs,
|
|
442
445
|
stopReason: 'error',
|
|
443
446
|
};
|
|
444
447
|
|
|
@@ -495,6 +498,7 @@ export class Engine {
|
|
|
495
498
|
toolCalls: toolCalls.map(tc => ({ id: tc.id, name: tc.name, input: tc.input })),
|
|
496
499
|
usage: { inputTokens: totalUsage.inputTokens, outputTokens: totalUsage.outputTokens },
|
|
497
500
|
latencyMs,
|
|
501
|
+
ttfbMs,
|
|
498
502
|
stopReason,
|
|
499
503
|
};
|
|
500
504
|
|