forked from xiaohei/taiji-AI-PAD
更新agent DNS
This commit is contained in:
@@ -748,3 +748,4 @@ interface TenantsResourcesSummaryResponse {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+8
-5
@@ -85,15 +85,18 @@ spec:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8000
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 5
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 5
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 多阶段构建Dockerfile for MCP Server
|
||||
FROM python:3.11-slim@sha256:158caf0e080e2cd74ef2879ed3c4e697792ee65251c8208b7afb56683c32ea6c as builder
|
||||
FROM python:3.11-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -15,8 +15,7 @@ COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir --user -r requirements.txt
|
||||
|
||||
# 最终镜像
|
||||
# 使用 amd64 架构的基础镜像
|
||||
FROM python:3.11-slim@sha256:158caf0e080e2cd74ef2879ed3c4e697792ee65251c8208b7afb56683c32ea6c
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
@@ -563,7 +563,7 @@ async def get_channel_quota_summary(
|
||||
)
|
||||
monthly_usage = Decimal(str(usage_result.scalar() or 0))
|
||||
|
||||
channel_credit = Decimal(str(channel.credit_limit or 0))
|
||||
channel_credit = Decimal(str(channel.channel_credit or 0)) # 修复:使用正确的字段名 channel_credit
|
||||
usage_percent = float(monthly_usage / channel_credit * 100) if channel_credit > 0 else 0
|
||||
|
||||
# 3. 检查活跃预警
|
||||
|
||||
@@ -19,7 +19,7 @@ from models import (
|
||||
ChannelProviderAccess, ProviderApplication,
|
||||
ChannelCustomAgentQuota, ResourceApplication, PlatformAgentQuota,
|
||||
PlatformAgentTemplateConfig, AgentBillingRecord, ModelBillingRecord,
|
||||
TenantCustomAgentQuota, TenantModelKey
|
||||
TenantCustomAgentQuota, TenantModelKey, Balance
|
||||
)
|
||||
from app.auth import require_auth, get_password_hash
|
||||
from app.schemas import (
|
||||
@@ -640,6 +640,13 @@ async def get_admin_tenants(
|
||||
result = await db.execute(query)
|
||||
tenants = result.scalars().all()
|
||||
|
||||
# 获取所有租户的余额(从 Balance 表)
|
||||
tenant_ids = [tenant.id for tenant in tenants]
|
||||
balance_result = await db.execute(
|
||||
select(Balance).where(Balance.user_id.in_(tenant_ids))
|
||||
)
|
||||
balances = {b.user_id: float(b.eu_balance) for b in balance_result.scalars().all()}
|
||||
|
||||
data = [
|
||||
{
|
||||
"id": str(tenant.id),
|
||||
@@ -648,7 +655,7 @@ async def get_admin_tenants(
|
||||
"channelId": str(tenant.channel_id) if tenant.channel_id else None,
|
||||
"channelName": channel.name,
|
||||
"subscriptionTier": tenant.subscription_tier,
|
||||
"balance": float(tenant.balance or 0),
|
||||
"balance": balances.get(tenant.id, 0.0), # 从 Balance 表获取余额
|
||||
"creditLimit": float(tenant.credit_limit or 0),
|
||||
"status": tenant.status,
|
||||
"permissions": tenant.permissions if hasattr(tenant, 'permissions') else [],
|
||||
|
||||
@@ -147,13 +147,20 @@ async def list_tenants(
|
||||
)
|
||||
tenants = result.scalars().all()
|
||||
|
||||
# 获取所有租户的余额(从 Balance 表)
|
||||
tenant_ids = [tenant.id for tenant in tenants]
|
||||
balance_result = await db.execute(
|
||||
select(Balance).where(Balance.user_id.in_(tenant_ids))
|
||||
)
|
||||
balances = {b.user_id: float(b.eu_balance) for b in balance_result.scalars().all()}
|
||||
|
||||
data = [
|
||||
{
|
||||
"id": str(tenant.id),
|
||||
"name": tenant.name,
|
||||
"email": tenant.email,
|
||||
"subscriptionTier": tenant.subscription_tier,
|
||||
"balance": float(tenant.balance),
|
||||
"balance": balances.get(tenant.id, 0.0), # 从 Balance 表获取余额
|
||||
"creditLimit": float(tenant.credit_limit),
|
||||
"status": tenant.status,
|
||||
"createdAt": tenant.created_at.isoformat(),
|
||||
@@ -997,11 +1004,17 @@ async def delete_tenant(
|
||||
detail="租户不存在或不属于该渠道"
|
||||
)
|
||||
|
||||
# 检查租户是否还有余额
|
||||
if float(tenant.balance) > 0:
|
||||
# 检查租户是否还有余额(从 Balance 表获取)
|
||||
balance_result = await db.execute(
|
||||
select(Balance).where(Balance.user_id == tenant.id)
|
||||
)
|
||||
balance_obj = balance_result.scalar_one_or_none()
|
||||
tenant_balance = float(balance_obj.eu_balance) if balance_obj else 0.0
|
||||
|
||||
if tenant_balance > 0:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"租户还有余额 {float(tenant.balance):.2f},请先处理余额后再删除"
|
||||
detail=f"租户还有余额 {tenant_balance:.2f},请先处理余额后再删除"
|
||||
)
|
||||
|
||||
# 软删除:标记为不活跃
|
||||
@@ -3722,6 +3735,13 @@ async def get_channel_tenants_resources_summary(
|
||||
)
|
||||
tenants = tenants_result.scalars().all()
|
||||
|
||||
# 获取所有租户的余额(从 Balance 表)
|
||||
tenant_ids = [tenant.id for tenant in tenants]
|
||||
balance_result = await db.execute(
|
||||
select(Balance).where(Balance.user_id.in_(tenant_ids))
|
||||
)
|
||||
balances = {b.user_id: float(b.eu_balance) for b in balance_result.scalars().all()}
|
||||
|
||||
# 构建租户资源数据
|
||||
tenants_resources = []
|
||||
|
||||
@@ -3732,7 +3752,7 @@ async def get_channel_tenants_resources_summary(
|
||||
"tenantEmail": tenant.email,
|
||||
"status": tenant.status,
|
||||
"subscriptionTier": tenant.subscription_tier,
|
||||
"balance": float(tenant.balance) if tenant.balance else 0,
|
||||
"balance": balances.get(tenant.id, 0.0), # 从 Balance 表获取余额
|
||||
"createdAt": tenant.created_at.isoformat() if tenant.created_at else None,
|
||||
}
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ async def get_agent_resource_stats(
|
||||
select(
|
||||
func.count(AgentTrace.id).label("total_executions"),
|
||||
func.avg(AgentTrace.duration_ms).label("avg_duration"),
|
||||
func.sum(AgentTrace.total_eu_consumed).label("total_eu"),
|
||||
func.sum(AgentTrace.eu_consumed).label("total_eu"), # 修复:使用正确的字段名 eu_consumed
|
||||
func.sum(
|
||||
func.case(
|
||||
(AgentTrace.status == "success", 1),
|
||||
|
||||
@@ -389,7 +389,7 @@ async def get_billing_overview(
|
||||
|
||||
if balance is None:
|
||||
# 如果余额记录不存在,创建一个新的(初始余额为0)
|
||||
balance = Balance(user_id=user_id, eu_balance=0.0, cash_balance=0.0)
|
||||
balance = Balance(user_id=user_id, eu_balance=0.0)
|
||||
db.add(balance)
|
||||
await db.commit()
|
||||
await db.refresh(balance)
|
||||
@@ -752,7 +752,7 @@ async def get_billing_overview(
|
||||
# 余额信息
|
||||
"balance": {
|
||||
"eu": float(balance.eu_balance),
|
||||
"cash": float(balance.cash_balance) if hasattr(balance, 'cash_balance') else 0
|
||||
"cash": 0 # cash_balance 字段已移除,保留字段以兼容前端
|
||||
},
|
||||
# EU消费历史(图表数据)
|
||||
"euHistory": eu_history,
|
||||
|
||||
Reference in New Issue
Block a user