ruff fix但指定了--unsafe-fixes

This commit is contained in:
minecraft1024a
2025-10-05 21:48:32 +08:00
committed by Windpicker-owo
parent 04feb585b4
commit 2a89efe47a
76 changed files with 301 additions and 316 deletions

View File

@@ -812,7 +812,7 @@ class StatisticOutputTask(AsyncTask):
<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>
<h2>按模型分类统计</h2>
<table>
<tr><th>模块名称</th><th>调用次数</th><th>输入Token</th><th>输出Token</th><th>Token总量</th><th>累计花费</th><th>平均耗时(秒)</th><th>标准差(秒)</th></tr>
@@ -820,7 +820,7 @@ class StatisticOutputTask(AsyncTask):
{model_rows}
</tbody>
</table>
<h2>按模块分类统计</h2>
<table>
<thead>
@@ -830,7 +830,7 @@ class StatisticOutputTask(AsyncTask):
{module_rows}
</tbody>
</table>
<h2>按请求类型分类统计</h2>
<table>
<thead>
@@ -840,7 +840,7 @@ class StatisticOutputTask(AsyncTask):
{type_rows}
</tbody>
</table>
<h2>聊天消息统计</h2>
<table>
<thead>
@@ -850,7 +850,7 @@ class StatisticOutputTask(AsyncTask):
{chat_rows}
</tbody>
</table>
</div>
"""
@@ -997,7 +997,7 @@ class StatisticOutputTask(AsyncTask):
let i, tab_content, tab_links;
tab_content = document.getElementsByClassName("tab-content");
tab_links = document.getElementsByClassName("tab-link");
tab_content[0].classList.add("active");
tab_links[0].classList.add("active");
@@ -1185,7 +1185,7 @@ class StatisticOutputTask(AsyncTask):
return f"""
<div id="charts" class="tab-content">
<h2>数据图表</h2>
<!-- 时间范围选择按钮 -->
<div style="margin: 20px 0; text-align: center;">
<label style="margin-right: 10px; font-weight: bold;">时间范围:</label>
@@ -1194,7 +1194,7 @@ class StatisticOutputTask(AsyncTask):
<button class="time-range-btn active" onclick="switchTimeRange('24h')">24小时</button>
<button class="time-range-btn" onclick="switchTimeRange('48h')">48小时</button>
</div>
<div style="margin-top: 20px;">
<div style="margin-bottom: 40px;">
<canvas id="totalCostChart" width="800" height="400"></canvas>
@@ -1209,7 +1209,7 @@ class StatisticOutputTask(AsyncTask):
<canvas id="messageByChatChart" width="800" height="400"></canvas>
</div>
</div>
<style>
.time-range-btn {{
background-color: #ecf0f1;
@@ -1222,22 +1222,22 @@ class StatisticOutputTask(AsyncTask):
font-size: 14px;
transition: all 0.3s ease;
}}
.time-range-btn:hover {{
background-color: #d5dbdb;
}}
.time-range-btn.active {{
background-color: #3498db;
color: white;
border-color: #2980b9;
}}
</style>
<script>
const allChartData = {chart_data};
let currentCharts = {{}};
// 图表配置模板
const chartConfigs = {{
totalCost: {{
@@ -1248,7 +1248,7 @@ class StatisticOutputTask(AsyncTask):
fill: true
}},
costByModule: {{
id: 'costByModuleChart',
id: 'costByModuleChart',
title: '各模块花费',
yAxisLabel: '花费 (¥)',
dataKey: 'cost_by_module',
@@ -1256,7 +1256,7 @@ class StatisticOutputTask(AsyncTask):
}},
costByModel: {{
id: 'costByModelChart',
title: '各模型花费',
title: '各模型花费',
yAxisLabel: '花费 (¥)',
dataKey: 'cost_by_model',
fill: false
@@ -1283,40 +1283,40 @@ class StatisticOutputTask(AsyncTask):
fill: false
}}
}};
function switchTimeRange(timeRange) {{
// 更新按钮状态
document.querySelectorAll('.time-range-btn').forEach(btn => {{
btn.classList.remove('active');
}});
event.target.classList.add('active');
// 更新图表数据
const data = allChartData[timeRange];
updateAllCharts(data, timeRange);
}}
function updateAllCharts(data, timeRange) {{
// 销毁现有图表
Object.values(currentCharts).forEach(chart => {{
if (chart) chart.destroy();
}});
currentCharts = {{}};
// 重新创建图表
createChart('totalCost', data, timeRange);
createChart('costByModule', data, timeRange);
createChart('costByModel', data, timeRange);
createChart('messageByChat', data, timeRange);
}}
function createChart(chartType, data, timeRange) {{
const config = chartConfigs[chartType];
const colors = ['#3498db', '#e74c3c', '#2ecc71', '#f39c12', '#9b59b6', '#1abc9c', '#34495e', '#e67e22', '#95a5a6', '#f1c40f'];
let datasets = [];
if (chartType === 'totalCost') {{
datasets = [{{
label: config.title,
@@ -1340,7 +1340,7 @@ class StatisticOutputTask(AsyncTask):
i++;
}});
}}
currentCharts[chartType] = new Chart(document.getElementById(config.id), {{
type: 'line',
data: {{
@@ -1385,7 +1385,7 @@ class StatisticOutputTask(AsyncTask):
}}
}});
}}
// 初始化图表默认24小时
document.addEventListener('DOMContentLoaded', function() {{
updateAllCharts(allChartData['24h'], '24h');

View File

@@ -51,7 +51,7 @@ print(a) # 直接输出当前 perf_counter 值
- storage计时器结果存储字典默认为 None
- auto_unit自动选择单位毫秒或秒默认为 True自动根据时间切换毫秒或秒
- do_type_check是否进行类型检查默认为 False不进行类型检查
属性human_readable
自定义错误TimerTypeError

View File

@@ -722,7 +722,6 @@ def assign_message_ids(messages: list[Any]) -> list[dict[str, Any]]:
包含 {'id': str, 'message': any} 格式的字典列表
"""
result = []
used_ids = set()
for i, message in enumerate(messages):
# 使用简单的索引作为ID
message_id = f"m{i + 1}"

View File

@@ -209,7 +209,7 @@ class ImageManager:
emotion_prompt = f"""
请你基于这个表情包的详细描述提取出最核心的情感含义用1-2个词概括。
详细描述:'{detailed_description}'
要求:
1. 只输出1-2个最核心的情感词汇
2. 从互联网梗、meme的角度理解

View File

@@ -389,7 +389,7 @@ class LegacyVideoAnalyzer:
logger.info(f"✅ 成功提取{len(frames)}")
return frames
async def analyze_frames_batch(self, frames: list[tuple[str, float]], user_question: str = None) -> str:
async def analyze_frames_batch(self, frames: list[tuple[str, float]], user_question: str | None = None) -> str:
"""批量分析所有帧"""
logger.info(f"开始批量分析{len(frames)}")
@@ -478,7 +478,7 @@ class LegacyVideoAnalyzer:
logger.info(f"视频识别完成,响应长度: {len(api_response.content or '')} ")
return api_response.content or "❌ 未获得响应内容"
async def analyze_frames_sequential(self, frames: list[tuple[str, float]], user_question: str = None) -> str:
async def analyze_frames_sequential(self, frames: list[tuple[str, float]], user_question: str | None = None) -> str:
"""逐帧分析并汇总"""
logger.info(f"开始逐帧分析{len(frames)}")
@@ -536,7 +536,7 @@ class LegacyVideoAnalyzer:
# 如果汇总失败,返回各帧分析结果
return f"视频逐帧分析结果:\n\n{chr(10).join(frame_analyses)}"
async def analyze_video(self, video_path: str, user_question: str = None) -> str:
async def analyze_video(self, video_path: str, user_question: str | None = None) -> str:
"""分析视频的主要方法"""
try:
logger.info(f"开始分析视频: {os.path.basename(video_path)}")