fix: Token统计准确性修复 + 仪表盘增强

1. 修复eval_count只记最后一轮的bug:改为每轮累加
2. 新增prompt_eval_count(输入token)统计
3. 修复total_duration使用Ollama实际推理时间而非墙钟时间
4. 数据库messages表新增prompt_eval_count列(含兼容迁移)
5. 仪表盘显示输入/输出token分项统计
6. 柱状图堆叠显示输入(紫色)+输出(橙色)比例
7. 明细表格新增输入/输出/合计三列
This commit is contained in:
thzxx
2026-04-23 16:11:17 +08:00
parent e96b2a840e
commit 21b9a14824
8 changed files with 125 additions and 29 deletions
+3
View File
@@ -90,6 +90,7 @@ export class ChatDB {
tool_calls: msg.toolCalls?.length ? JSON.stringify(msg.toolCalls) : null,
tool_name: null,
eval_count: msg.eval_count || null,
prompt_eval_count: msg.prompt_eval_count || null,
total_duration: msg.total_duration || null,
created_at: msg.timestamp
};
@@ -112,6 +113,7 @@ export class ChatDB {
think: r.thinking || undefined,
images: r.images ? JSON.parse(r.images) : undefined,
eval_count: r.eval_count || undefined,
prompt_eval_count: r.prompt_eval_count || undefined,
total_duration: r.total_duration || undefined,
toolCalls: r.tool_calls ? JSON.parse(r.tool_calls) : undefined
}));
@@ -170,6 +172,7 @@ export class ChatDB {
images: m.images?.length ? JSON.stringify(m.images) : null,
tool_calls: m.toolCalls?.length ? JSON.stringify(m.toolCalls) : null,
tool_name: null, eval_count: m.eval_count || null,
prompt_eval_count: m.prompt_eval_count || null,
total_duration: m.total_duration || null, created_at: m.timestamp
}))),
memories: [],