diff --git a/service/task/worker.go b/service/task/worker.go index 7ae433b..79d7b2e 100644 --- a/service/task/worker.go +++ b/service/task/worker.go @@ -45,7 +45,7 @@ func (w *asyncWorker) handleOne(ctx context.Context, task *entity.ModelGatewayTa // ============================================ // 1) 查询余额 // ============================================ - surplus, _ = gateway.GetTenantSurplus(ctx, task.TenantId) + surplus, _ = gateway.GetTenantSurplus(ctx, model.TenantId) if surplus <= 0 { w.failTask(ctx, task, startTime, "租户余额不足") return @@ -401,6 +401,11 @@ func injectErrorMessage(payload map[string]any, err error) map[string]any { // InvokeModel 调用模型服务,返回二进制结果 // modelKey 用于覆盖/补充模型配置 head_msg(例如每次请求携带不同的 X-API-Key) func InvokeModel(ctx context.Context, model *entity.ModelGatewayModel, body map[string]any) ([]byte, error) { + //surplus, _ := gateway.GetTenantSurplus(ctx, model.TenantId) + //if surplus <= 0 { + // return nil, fmt.Errorf("租户余额不足") + //} + // 3)构建请求 URL 和超时 baseURL := strings.TrimRight(model.BaseURL, "/") timeout := time.Duration(model.TimeoutSeconds) * time.Second