From eb311de0c23f1cdc2d1ae6950c9f1f96d4f0e5ba Mon Sep 17 00:00:00 2001 From: snaily Date: Sun, 20 Apr 2025 01:10:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=80=9D=E8=80=83?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE=E5=B9=B6=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=8A=B6=E6=80=81=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 README.md 中添加 THINKING_MODELS 和 THINKING_BUDGET_MAP 环境变量文档。 - 修复 stats_service.py 中的 get_api_call_details 函数,以正确处理 status_code 为 None 的情况,确保状态判断的健壮性。 --- README.md | 2 ++ app/service/stats_service.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 435e592..c54f3c6 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,8 @@ app/ | `TOOLS_CODE_EXECUTION_ENABLED` | 可选,是否启用代码执行工具 | `false` | | `SHOW_SEARCH_LINK` | 可选,是否在响应中显示搜索结果链接 | `true` | | `SHOW_THINKING_PROCESS` | 可选,是否显示模型思考过程 | `true` | +| `THINKING_MODELS` | 可选,支持思考功能的模型列表 | `[]` | +| `THINKING_BUDGET_MAP` | 可选,思考功能预算映射 (模型名:预算值) | `{}` | | `BASE_URL` | 可选,Gemini API 基础 URL,默认无需修改 | `https://generativelanguage.googleapis.com/v1beta` | | `MAX_FAILURES` | 可选,允许单个key失败的次数 | `3` | | `MAX_RETRIES` | 可选,API 请求失败时的最大重试次数 | `3` | diff --git a/app/service/stats_service.py b/app/service/stats_service.py index faf30f9..45caa17 100644 --- a/app/service/stats_service.py +++ b/app/service/stats_service.py @@ -107,7 +107,9 @@ async def get_api_call_details(period: str) -> list[dict]: # Convert results to list of dicts and map status_code details = [] for row in results: - status = 'success' if 200 <= row['status_code'] < 300 else 'failure' + status = 'failure' # 默认状态为 failure,如果 status_code 有效且在 200-299 范围内则更新为 success + if row['status_code'] is not None: # 检查 status_code 是否为空 + status = 'success' if 200 <= row['status_code'] < 300 else 'failure' details.append({ "timestamp": row['timestamp'].isoformat(), # Use ISO format for JS compatibility "key": row['key'],