feat(assist): сбор usage-токенов и отдача в meta (время этапов уже было)

This commit is contained in:
Repinoid
2026-10-07 18:53:11 +03:00
parent 5018acf150
commit f42017f012
4 changed files with 22 additions and 0 deletions
+3
View File
@@ -229,6 +229,7 @@ function hasHeader(text, header) {
* @param {string} [params.model]
* @param {number} [params.maxTokens]
* @param {AbortController} [params.controller]
* @param {object} [params.usageRef]
* @returns {Promise<{ok:true, answer:string} | {ok:false, error:string}>}
*/
async function stage2Generate({
@@ -239,6 +240,7 @@ async function stage2Generate({
model = process.env.LLM_MODEL || DEFAULT_MODEL,
maxTokens = 2048,
controller,
usageRef,
}) {
const docsBlock = context
.map((c, i) => `[${i + 1}] ${c.title}\n${c.text}`)
@@ -270,6 +272,7 @@ async function stage2Generate({
baseUrl,
apiKey,
model,
usageRef,
});
} catch (err) {
const code = err && err.code ? err.code : 'stage2_failed';