diff --git a/index.ts b/index.ts index 93053e8..cbd1503 100644 --- a/index.ts +++ b/index.ts @@ -27,17 +27,21 @@ try { const prompt = Bun.argv[2] ?? "Introduce yourself."; messages.push({ role: "user", content: prompt }); -const { fullStream, reasoningText, text } = streamText({ +const { fullStream, reasoningText, text, totalUsage } = streamText({ model: provider("qwen3.5-35b-a3b"), messages, }); +const start = Date.now(); + renderStream(fullStream); const reasoning = await reasoningText; -await reasoningFile.write(reasoning ?? ""); - const response = await text; + +const stop = Date.now(); + +await reasoningFile.write(reasoning ?? ""); await responseFile.write(response); messages.push({ role: "assistant", content: response }); @@ -48,3 +52,11 @@ Bun.spawnSync({ cmd: ["glow", "-w", `${numColumns}`, responsePath], stdio: ["inherit", "inherit", "inherit"], }); + +const { inputTokens, outputTokens } = await totalUsage; +const context = (inputTokens ?? 0) / 1000; +const output = (outputTokens ?? 0) / 1000; +const time = (stop - start) / 1000; +process.stderr.write( + `Context: ${context.toFixed(1)}k, Output: ${output.toFixed(1)}k, Time: ${time.toFixed(2)}s\n`, +);