diff --git a/src/chat/utils/statistic.py b/src/chat/utils/statistic.py index 6a0b95964..970746138 100644 --- a/src/chat/utils/statistic.py +++ b/src/chat/utils/statistic.py @@ -512,46 +512,54 @@ class StatisticOutputTask(AsyncTask): # format总在线时间 # 按模型分类统计 - model_rows = "\n".join([ - f"" - f"{model_name}" - f"{count}" - f"{stat_data[IN_TOK_BY_MODEL][model_name]}" - f"{stat_data[OUT_TOK_BY_MODEL][model_name]}" - f"{stat_data[TOTAL_TOK_BY_MODEL][model_name]}" - f"{stat_data[COST_BY_MODEL][model_name]:.4f} ¥" - f"" - for model_name, count in sorted(stat_data[REQ_CNT_BY_MODEL].items()) - ]) + model_rows = "\n".join( + [ + f"" + f"{model_name}" + f"{count}" + f"{stat_data[IN_TOK_BY_MODEL][model_name]}" + f"{stat_data[OUT_TOK_BY_MODEL][model_name]}" + f"{stat_data[TOTAL_TOK_BY_MODEL][model_name]}" + f"{stat_data[COST_BY_MODEL][model_name]:.4f} ¥" + f"" + for model_name, count in sorted(stat_data[REQ_CNT_BY_MODEL].items()) + ] + ) # 按请求类型分类统计 - type_rows = "\n".join([ - f"" - f"{req_type}" - f"{count}" - f"{stat_data[IN_TOK_BY_TYPE][req_type]}" - f"{stat_data[OUT_TOK_BY_TYPE][req_type]}" - f"{stat_data[TOTAL_TOK_BY_TYPE][req_type]}" - f"{stat_data[COST_BY_TYPE][req_type]:.4f} ¥" - f"" - for req_type, count in sorted(stat_data[REQ_CNT_BY_TYPE].items()) - ]) + type_rows = "\n".join( + [ + f"" + f"{req_type}" + f"{count}" + f"{stat_data[IN_TOK_BY_TYPE][req_type]}" + f"{stat_data[OUT_TOK_BY_TYPE][req_type]}" + f"{stat_data[TOTAL_TOK_BY_TYPE][req_type]}" + f"{stat_data[COST_BY_TYPE][req_type]:.4f} ¥" + f"" + for req_type, count in sorted(stat_data[REQ_CNT_BY_TYPE].items()) + ] + ) # 按用户分类统计 - user_rows = "\n".join([ - f"" - f"{user_id}" - f"{count}" - f"{stat_data[IN_TOK_BY_USER][user_id]}" - f"{stat_data[OUT_TOK_BY_USER][user_id]}" - f"{stat_data[TOTAL_TOK_BY_USER][user_id]}" - f"{stat_data[COST_BY_USER][user_id]:.4f} ¥" - f"" - for user_id, count in sorted(stat_data[REQ_CNT_BY_USER].items()) - ]) + user_rows = "\n".join( + [ + f"" + f"{user_id}" + f"{count}" + f"{stat_data[IN_TOK_BY_USER][user_id]}" + f"{stat_data[OUT_TOK_BY_USER][user_id]}" + f"{stat_data[TOTAL_TOK_BY_USER][user_id]}" + f"{stat_data[COST_BY_USER][user_id]:.4f} ¥" + f"" + for user_id, count in sorted(stat_data[REQ_CNT_BY_USER].items()) + ] + ) # 聊天消息统计 - chat_rows = "\n".join([ - f"{self.name_mapping[chat_id][0]}{count}" - for chat_id, count in sorted(stat_data[MSG_CNT_BY_CHAT].items()) - ]) + chat_rows = "\n".join( + [ + f"{self.name_mapping[chat_id][0]}{count}" + for chat_id, count in sorted(stat_data[MSG_CNT_BY_CHAT].items()) + ] + ) # 生成HTML return f"""