All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { Body, Controller, Get, Inject, 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';
|
|
import type { TestConnectionDto, TestConnectionResultDto } from './provider.dto.js';
|
|
|
|
@Controller('api/providers')
|
|
@UseGuards(AuthGuard)
|
|
export class ProvidersController {
|
|
constructor(
|
|
@Inject(ProviderService) private readonly providerService: ProviderService,
|
|
@Inject(RoutingService) private readonly routingService: RoutingService,
|
|
) {}
|
|
|
|
@Get()
|
|
list() {
|
|
return this.providerService.listProviders();
|
|
}
|
|
|
|
@Get('models')
|
|
listModels() {
|
|
return this.providerService.listAvailableModels();
|
|
}
|
|
|
|
@Post('test')
|
|
testConnection(@Body() body: TestConnectionDto): Promise<TestConnectionResultDto> {
|
|
return this.providerService.testConnection(body.providerId, body.baseUrl);
|
|
}
|
|
|
|
@Post('route')
|
|
route(@Body() criteria: RoutingCriteria) {
|
|
return this.routingService.route(criteria);
|
|
}
|
|
|
|
@Post('rank')
|
|
rank(@Body() criteria: RoutingCriteria) {
|
|
return this.routingService.rank(criteria);
|
|
}
|
|
}
|