better:美化logger
This commit is contained in:
@@ -140,10 +140,8 @@ class HeartFCMessageReceiver:
|
||||
replace_bot_name=True
|
||||
)
|
||||
|
||||
if keywords:
|
||||
logger.info(f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}[兴趣度:{interested_rate:.2f}][关键词:{keywords}]") # type: ignore
|
||||
else:
|
||||
logger.info(f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}[兴趣度:{interested_rate:.2f}]") # type: ignore
|
||||
|
||||
logger.info(f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}[{interested_rate:.2f}]") # type: ignore
|
||||
|
||||
_ = Person.register_person(platform=message.message_info.platform, user_id=message.message_info.user_info.user_id,nickname=userinfo.user_nickname) # type: ignore
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ logger = get_logger("sender")
|
||||
|
||||
async def send_message(message: MessageSending, show_log=True) -> bool:
|
||||
"""合并后的消息发送函数,包含WS发送和日志记录"""
|
||||
message_preview = truncate_message(message.processed_plain_text, max_length=120)
|
||||
message_preview = truncate_message(message.processed_plain_text, max_length=200)
|
||||
|
||||
try:
|
||||
# 直接调用API发送消息
|
||||
|
||||
@@ -131,7 +131,7 @@ class ActionModifier:
|
||||
|
||||
available_actions = list(self.action_manager.get_using_actions().keys())
|
||||
available_actions_text = "、".join(available_actions) if available_actions else "无"
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 当前可用动作: {available_actions_text}||移除: {removals_summary}"
|
||||
)
|
||||
|
||||
|
||||
@@ -512,7 +512,6 @@ class ActionPlanner:
|
||||
self.last_obs_time_mark = time.time()
|
||||
|
||||
try:
|
||||
logger.info(f"{self.log_prefix}开始构建副Planner")
|
||||
sub_planner_actions: Dict[str, ActionInfo] = {}
|
||||
|
||||
for action_name, action_info in available_actions.items():
|
||||
@@ -537,7 +536,7 @@ class ActionPlanner:
|
||||
sub_planner_size = int(global_config.chat.planner_size) + 1
|
||||
sub_planner_num = math.ceil(sub_planner_actions_num / sub_planner_size)
|
||||
|
||||
logger.info(f"{self.log_prefix}副规划器数量: {sub_planner_num}, 副规划器大小: {sub_planner_size}")
|
||||
logger.info(f"{self.log_prefix}使用{sub_planner_num}个小脑进行思考(尺寸:{sub_planner_size})")
|
||||
|
||||
# 将sub_planner_actions随机分配到sub_planner_num个List中
|
||||
sub_planner_lists: List[List[Tuple[str, ActionInfo]]] = []
|
||||
|
||||
@@ -612,7 +612,7 @@ class StatisticOutputTask(AsyncTask):
|
||||
f"总在线时间: {_format_online_time(stats[ONLINE_TIME])}",
|
||||
f"总消息数: {stats[TOTAL_MSG_CNT]}",
|
||||
f"总请求数: {stats[TOTAL_REQ_CNT]}",
|
||||
f"总花费: {stats[TOTAL_COST]:.4f}¥",
|
||||
f"总花费: {stats[TOTAL_COST]:.2f}¥",
|
||||
"",
|
||||
]
|
||||
|
||||
@@ -625,7 +625,7 @@ class StatisticOutputTask(AsyncTask):
|
||||
"""
|
||||
if stats[TOTAL_REQ_CNT] <= 0:
|
||||
return ""
|
||||
data_fmt = "{:<32} {:>10} {:>12} {:>12} {:>12} {:>9.4f}¥ {:>10} {:>10}"
|
||||
data_fmt = "{:<32} {:>10} {:>12} {:>12} {:>12} {:>9.2f}¥ {:>10.1f} {:>10.1f}"
|
||||
|
||||
output = [
|
||||
"按模型分类统计:",
|
||||
@@ -723,9 +723,9 @@ class StatisticOutputTask(AsyncTask):
|
||||
f"<td>{stat_data[IN_TOK_BY_MODEL][model_name]}</td>"
|
||||
f"<td>{stat_data[OUT_TOK_BY_MODEL][model_name]}</td>"
|
||||
f"<td>{stat_data[TOTAL_TOK_BY_MODEL][model_name]}</td>"
|
||||
f"<td>{stat_data[COST_BY_MODEL][model_name]:.4f} ¥</td>"
|
||||
f"<td>{stat_data[AVG_TIME_COST_BY_MODEL][model_name]:.3f} 秒</td>"
|
||||
f"<td>{stat_data[STD_TIME_COST_BY_MODEL][model_name]:.3f} 秒</td>"
|
||||
f"<td>{stat_data[COST_BY_MODEL][model_name]:.2f} ¥</td>"
|
||||
f"<td>{stat_data[AVG_TIME_COST_BY_MODEL][model_name]:.1f} 秒</td>"
|
||||
f"<td>{stat_data[STD_TIME_COST_BY_MODEL][model_name]:.1f} 秒</td>"
|
||||
f"</tr>"
|
||||
for model_name, count in sorted(stat_data[REQ_CNT_BY_MODEL].items())
|
||||
]
|
||||
@@ -739,9 +739,9 @@ class StatisticOutputTask(AsyncTask):
|
||||
f"<td>{stat_data[IN_TOK_BY_TYPE][req_type]}</td>"
|
||||
f"<td>{stat_data[OUT_TOK_BY_TYPE][req_type]}</td>"
|
||||
f"<td>{stat_data[TOTAL_TOK_BY_TYPE][req_type]}</td>"
|
||||
f"<td>{stat_data[COST_BY_TYPE][req_type]:.4f} ¥</td>"
|
||||
f"<td>{stat_data[AVG_TIME_COST_BY_TYPE][req_type]:.3f} 秒</td>"
|
||||
f"<td>{stat_data[STD_TIME_COST_BY_TYPE][req_type]:.3f} 秒</td>"
|
||||
f"<td>{stat_data[COST_BY_TYPE][req_type]:.2f} ¥</td>"
|
||||
f"<td>{stat_data[AVG_TIME_COST_BY_TYPE][req_type]:.1f} 秒</td>"
|
||||
f"<td>{stat_data[STD_TIME_COST_BY_TYPE][req_type]:.1f} 秒</td>"
|
||||
f"</tr>"
|
||||
for req_type, count in sorted(stat_data[REQ_CNT_BY_TYPE].items())
|
||||
]
|
||||
@@ -755,9 +755,9 @@ class StatisticOutputTask(AsyncTask):
|
||||
f"<td>{stat_data[IN_TOK_BY_MODULE][module_name]}</td>"
|
||||
f"<td>{stat_data[OUT_TOK_BY_MODULE][module_name]}</td>"
|
||||
f"<td>{stat_data[TOTAL_TOK_BY_MODULE][module_name]}</td>"
|
||||
f"<td>{stat_data[COST_BY_MODULE][module_name]:.4f} ¥</td>"
|
||||
f"<td>{stat_data[AVG_TIME_COST_BY_MODULE][module_name]:.3f} 秒</td>"
|
||||
f"<td>{stat_data[STD_TIME_COST_BY_MODULE][module_name]:.3f} 秒</td>"
|
||||
f"<td>{stat_data[COST_BY_MODULE][module_name]:.2f} ¥</td>"
|
||||
f"<td>{stat_data[AVG_TIME_COST_BY_MODULE][module_name]:.1f} 秒</td>"
|
||||
f"<td>{stat_data[STD_TIME_COST_BY_MODULE][module_name]:.1f} 秒</td>"
|
||||
f"</tr>"
|
||||
for module_name, count in sorted(stat_data[REQ_CNT_BY_MODULE].items())
|
||||
]
|
||||
@@ -780,79 +780,47 @@ class StatisticOutputTask(AsyncTask):
|
||||
<p class=\"info-item\"><strong>总在线时间: </strong>{_format_online_time(stat_data[ONLINE_TIME])}</p>
|
||||
<p class=\"info-item\"><strong>总消息数: </strong>{stat_data[TOTAL_MSG_CNT]}</p>
|
||||
<p class=\"info-item\"><strong>总请求数: </strong>{stat_data[TOTAL_REQ_CNT]}</p>
|
||||
<p class=\"info-item\"><strong>总花费: </strong>{stat_data[TOTAL_COST]:.4f} ¥</p>
|
||||
<p class=\"info-item\"><strong>总花费: </strong>{stat_data[TOTAL_COST]:.2f} ¥</p>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; margin: 20px 0;">
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h2>按模型分类统计</h2>
|
||||
<table>
|
||||
<thead><tr><th>模型名称</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr></thead>
|
||||
<tbody>
|
||||
{model_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h3>模型调用次数分布</h3>
|
||||
<canvas id="modelPieChart_{div_id}" width="300" height="300"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<h2>按模型分类统计</h2>
|
||||
<table>
|
||||
<thead><tr><th>模型名称</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr></thead>
|
||||
<tbody>
|
||||
{model_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; margin: 20px 0;">
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h2>按模块分类统计</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>模块名称</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{module_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h3>模块调用次数分布</h3>
|
||||
<canvas id="modulePieChart_{div_id}" width="300" height="300"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<h2>按模块分类统计</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>模块名称</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{module_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; margin: 20px 0;">
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h2>按请求类型分类统计</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>请求类型</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{type_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h3>请求类型分布</h3>
|
||||
<canvas id="typePieChart_{div_id}" width="300" height="300"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<h2>按请求类型分类统计</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>请求类型</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{type_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; margin: 20px 0;">
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h2>聊天消息统计</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>联系人/群组名称</th><th>消息数量</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{chat_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="flex: 1; min-width: 300px;">
|
||||
<h3>消息分布</h3>
|
||||
<canvas id="chatPieChart_{div_id}" width="300" height="300"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<h2>聊天消息统计</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>联系人/群组名称</th><th>消息数量</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{chat_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
|
||||
// 为当前统计卡片创建饼图
|
||||
createPieCharts_{div_id}();
|
||||
|
||||
@@ -991,7 +959,7 @@ class StatisticOutputTask(AsyncTask):
|
||||
}}
|
||||
}});
|
||||
}}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user