refactor(llm_models): 将用量记录函数改为异步以支持数据库写入

将 `LLMUsageRecorder` 中的 `record_usage_to_database` 和 `LLMRequest` 中的 `_record_usage` 方法从同步转换为异步。

此项重构是为了支持异步数据库操作,避免在记录模型用量时阻塞事件循环,从而提升应用的整体性能和响应能力。
This commit is contained in:
tt-P607
2025-09-26 21:59:38 +08:00
parent 50835498f0
commit 9608a040a6
2 changed files with 4 additions and 4 deletions

View File

@@ -145,7 +145,7 @@ class LLMUsageRecorder:
LLM使用情况记录器SQLAlchemy版本
"""
def record_usage_to_database(
async def record_usage_to_database(
self,
model_info: ModelInfo,
model_usage: UsageRecord,