更新智慧的王接口前的关键保命备份

This commit is contained in:
zhanggangyong
2026-01-11 09:21:25 +00:00
parent f01c0053e7
commit d221d9db04
20 changed files with 1643 additions and 3919 deletions
+27
View File
@@ -1328,9 +1328,36 @@ async def allocate_channel_resources(
)
# 更新自定义Agent资源(旧格式,保留兼容)
# Bug 修复:customAgentResources 也需要创建 ChannelCustomAgentQuota 记录
if req.customAgentResources:
channel.custom_agent_cpu = req.customAgentResources.cpu
channel.custom_agent_memory = req.customAgentResources.memory
# 同时更新新格式字段
channel.custom_agent_cpu_quota = req.customAgentResources.cpu
channel.custom_agent_memory_quota = req.customAgentResources.memory
# 查找或创建渠道配额记录
channel_quota_result = await db.execute(
select(ChannelCustomAgentQuota).where(
ChannelCustomAgentQuota.channel_id == channel_id
)
)
channel_quota = channel_quota_result.scalar_one_or_none()
if channel_quota:
# 更新现有配额
channel_quota.cpu_quota = req.customAgentResources.cpu
channel_quota.memory_quota = req.customAgentResources.memory
else:
# 创建新配额记录
channel_quota = ChannelCustomAgentQuota(
channel_id=channel_id,
cpu_quota=req.customAgentResources.cpu,
memory_quota=req.customAgentResources.memory,
cpu_allocated=0,
memory_allocated=0,
)
db.add(channel_quota)
# 更新自定义 Agent 配额(新格式)
if req.customAgentQuota: