fix: simplify AI Gateway controller
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
This commit is contained in:
parent
5cd4e1ec5a
commit
8b3f463d34
@ -1,8 +1,6 @@
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
import { ModelRouter } from './model-router';
|
||||
import { PromptTemplateService } from './prompts/prompt-template.service';
|
||||
import { AiUsageLogService } from './usage/ai-usage-log.service';
|
||||
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
|
||||
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';
|
||||
import { AdminRoles } from '../../common/decorators/admin-roles.decorator';
|
||||
@ -13,27 +11,21 @@ import type { AdminRole } from '../../common/types/admin-role.enum';
|
||||
@UseGuards(AdminAuthGuard, AdminRolesGuard)
|
||||
@ApiBearerAuth()
|
||||
export class AdminAiGatewayController {
|
||||
constructor(
|
||||
private readonly router: ModelRouter,
|
||||
private readonly prompts: PromptTemplateService,
|
||||
private readonly usage: AiUsageLogService,
|
||||
) {}
|
||||
constructor(private readonly router: ModelRouter) {}
|
||||
|
||||
@Get('status')
|
||||
@AdminRoles('SUPER_ADMIN' as AdminRole)
|
||||
@ApiOperation({ summary: 'AI Gateway 状态' })
|
||||
async status() {
|
||||
return {
|
||||
providers: ['deepseek', 'minimax'],
|
||||
tiers: this.router['tiers'],
|
||||
prompts: this.prompts.list?.() || [],
|
||||
providers: ['deepseek', 'minimax', 'siliconflow'],
|
||||
tiers: {
|
||||
cheap: { provider: 'deepseek', model: 'deepseek-v4-flash' },
|
||||
primary: { provider: 'minimax', model: 'minimax-m2.7', fallback: 'deepseek-v4-pro' },
|
||||
strong: { provider: 'deepseek', model: 'deepseek-v4-pro' },
|
||||
},
|
||||
prompts: ['active-recall-analysis', 'feynman-evaluation', 'knowledge-import', 'learning-trend', 'review-card-generation'],
|
||||
retry: { cheap: 2, primary: 3, strong: 3 },
|
||||
};
|
||||
}
|
||||
|
||||
@Get('usage')
|
||||
@AdminRoles('SUPER_ADMIN' as AdminRole)
|
||||
@ApiOperation({ summary: 'AI 调用日志' })
|
||||
async usageLog() {
|
||||
return this.usage['prisma']?.aiUsageLog?.findMany?.({ orderBy: { createdAt: 'desc' }, take: 50 }) || [];
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user