@ww_nero/mini-cli 1.0.104 → 1.0.105
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/src/utils/output.js +11 -1
package/package.json
CHANGED
package/src/utils/output.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const { Marked } = require('marked');
|
|
3
3
|
const { markedTerminal } = require('marked-terminal');
|
|
4
|
+
const { encode } = require('gpt-tokenizer');
|
|
4
5
|
const { splitThinkContent } = require('./think');
|
|
5
6
|
|
|
6
7
|
const ANSI_PATTERN = /\u001B\[[0-9;]*m/g;
|
|
@@ -79,7 +80,16 @@ const printReasoningContent = (text, ensureNewline) => {
|
|
|
79
80
|
|
|
80
81
|
if (!normalized) return;
|
|
81
82
|
ensureNewline();
|
|
82
|
-
|
|
83
|
+
|
|
84
|
+
let tokenCount = 0;
|
|
85
|
+
try {
|
|
86
|
+
tokenCount = encode(normalized).length;
|
|
87
|
+
} catch (_) {
|
|
88
|
+
// 忽略分词异常
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const formattedTokens = `${(tokenCount / 1024).toFixed(1)}k`;
|
|
92
|
+
console.log(chalk.gray(`思考Tokens: ${formattedTokens}`));
|
|
83
93
|
};
|
|
84
94
|
|
|
85
95
|
const printAssistantContent = (text, ensureNewline) => {
|