feat(assist): сбор usage-токенов и отдача в meta (время этапов уже было)
This commit is contained in:
@@ -241,11 +241,13 @@ async function runPipeline(question, stand, vmDocsBaseUrl, controller, start) {
|
||||
// Этап 1 (resource_type).
|
||||
let resourceType = null;
|
||||
let stage1Ok = false;
|
||||
const usage = { prompt: 0, completion: 0, total: 0 };
|
||||
const budget = TOTAL_DEADLINE_MS - (Date.now() - start);
|
||||
if (budget > 0 && resourceTypes.size > 0) {
|
||||
const r1 = await stage1ExtractResourceType(question, {
|
||||
resourceTypesSet: resourceTypes,
|
||||
controller,
|
||||
usageRef: usage,
|
||||
});
|
||||
stage1Ok = r1.ok;
|
||||
if (r1.ok && r1.resourceType) resourceType = r1.resourceType;
|
||||
@@ -267,6 +269,7 @@ async function runPipeline(question, stand, vmDocsBaseUrl, controller, start) {
|
||||
model: ENV.LLM_MODEL,
|
||||
maxTokens: 2048,
|
||||
controller,
|
||||
usageRef: usage,
|
||||
});
|
||||
const tStage2 = Date.now();
|
||||
|
||||
@@ -288,6 +291,9 @@ async function runPipeline(question, stand, vmDocsBaseUrl, controller, start) {
|
||||
stage1_ms: tStage1 - tIndex,
|
||||
search_ms: tSearch - tStage1,
|
||||
stage2_ms: tStage2 - tSearch,
|
||||
tokens: usage.total,
|
||||
prompt_tokens: usage.prompt,
|
||||
completion_tokens: usage.completion,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user