Implements comprehensive LLM usage tracking with analytics endpoints. Implementation: - Added LlmUsageLog model to Prisma schema - Created llm-usage module with service, controller, and DTOs - Added tracking for token usage, costs, and durations - Implemented analytics aggregation by provider, model, and task type - Added filtering by workspace, provider, model, user, and date range Testing: - 20 unit tests with 90.8% coverage (exceeds 85% requirement) - Tests for service and controller with full error handling - Tests use Vitest following project conventions API Endpoints: - GET /api/llm-usage/analytics - Aggregated usage analytics - GET /api/llm-usage/by-workspace/:workspaceId - Workspace usage logs - GET /api/llm-usage/by-workspace/:workspaceId/provider/:provider - Provider logs - GET /api/llm-usage/by-workspace/:workspaceId/model/:model - Model logs Database: - LlmUsageLog table with indexes for efficient queries - Relations to User, Workspace, and LlmProviderInstance - Ready for migration with: pnpm prisma migrate dev Refs #309 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
16 lines
625 B
TypeScript
16 lines
625 B
TypeScript
import { Module } from "@nestjs/common";
|
|
import { LlmController } from "./llm.controller";
|
|
import { LlmProviderAdminController } from "./llm-provider-admin.controller";
|
|
import { LlmService } from "./llm.service";
|
|
import { LlmManagerService } from "./llm-manager.service";
|
|
import { PrismaModule } from "../prisma/prisma.module";
|
|
import { LlmUsageModule } from "../llm-usage/llm-usage.module";
|
|
|
|
@Module({
|
|
imports: [PrismaModule, LlmUsageModule],
|
|
controllers: [LlmController, LlmProviderAdminController],
|
|
providers: [LlmService, LlmManagerService],
|
|
exports: [LlmService, LlmManagerService],
|
|
})
|
|
export class LlmModule {}
|