Add RoutingService that selects optimal LLM model based on task type, cost tier, capability requirements (reasoning, image, context window), and provider preference. Scoring algorithm ranks all available models. - RoutingService: route() for best match, rank() for scored list - POST /api/providers/route and /api/providers/rank endpoints - Routing types in @mosaic/types (CostTier, TaskType, RoutingCriteria) - Cost tier classification: cheap (<$1/M), standard (<$10/M), premium Closes #21 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
904 B
TypeScript
35 lines
904 B
TypeScript
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
|
import type { RoutingCriteria } from '@mosaic/types';
|
|
import { AuthGuard } from '../auth/auth.guard.js';
|
|
import { ProviderService } from './provider.service.js';
|
|
import { RoutingService } from './routing.service.js';
|
|
|
|
@Controller('api/providers')
|
|
@UseGuards(AuthGuard)
|
|
export class ProvidersController {
|
|
constructor(
|
|
private readonly providerService: ProviderService,
|
|
private readonly routingService: RoutingService,
|
|
) {}
|
|
|
|
@Get()
|
|
list() {
|
|
return this.providerService.listProviders();
|
|
}
|
|
|
|
@Get('models')
|
|
listModels() {
|
|
return this.providerService.listAvailableModels();
|
|
}
|
|
|
|
@Post('route')
|
|
route(@Body() criteria: RoutingCriteria) {
|
|
return this.routingService.route(criteria);
|
|
}
|
|
|
|
@Post('rank')
|
|
rank(@Body() criteria: RoutingCriteria) {
|
|
return this.routingService.rank(criteria);
|
|
}
|
|
}
|