chore: enable ai feature in dev (#6618)

This commit is contained in:
darkskygit
2024-04-19 08:12:52 +00:00
parent 6d5dbbd7f4
commit 97669acb40
5 changed files with 35 additions and 22 deletions

View File

@@ -3,7 +3,7 @@ import { randomUUID } from 'node:crypto';
import { Injectable, Logger } from '@nestjs/common';
import { AiPromptRole, PrismaClient } from '@prisma/client';
import { FeatureManagementService, FeatureType } from '../../core/features';
import { FeatureManagementService } from '../../core/features';
import { QuotaService } from '../../core/quota';
import { PaymentRequiredException } from '../../fundamentals';
import { ChatMessageCache } from './message';
@@ -379,12 +379,10 @@ export class ChatSessionService {
}
async getQuota(userId: string) {
const hasCopilotFeature = await this.feature
.getActivatedUserFeatures(userId)
.then(f => f.includes(FeatureType.UnlimitedCopilot));
const isCopilotUser = await this.feature.isCopilotUser(userId);
let limit: number | undefined;
if (!hasCopilotFeature) {
if (!isCopilotUser) {
const quota = await this.quota.getUserQuota(userId);
limit = quota.feature.copilotActionLimit;
}