ffb-production.controller.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Controller, Get, Post, Delete, Body, Param, Query, BadRequestException } from '@nestjs/common';
  2. import { FFBProduction } from './ffb-production.schema';
  3. import { FFBProductionService } from './services/ffb-production.service';
  4. import { FFBLangChainService } from './services/ffb-langchain.service';
  5. @Controller('ffb-production')
  6. export class FFBProductionController {
  7. constructor(
  8. private readonly ffbService: FFBProductionService,
  9. private readonly ffbLangChainService: FFBLangChainService,
  10. ) { }
  11. @Post('chat')
  12. async query(@Body('message') message: string, @Body('sessionId') sessionId?: string) {
  13. throw new BadRequestException('HTTP Chat endpoint is deprecated. Please use WebSocket connection on namespace /ffb with event "chat".');
  14. }
  15. /** Vector search endpoint */
  16. @Get('search')
  17. async search(@Query('q') q: string, @Query('k') k?: string) {
  18. console.log(`GET /ffb-production/search?q=${q}&k=${k}`);
  19. const topK = k ? parseInt(k, 10) : 5;
  20. return this.ffbService.search(q, topK);
  21. }
  22. /** Create a new FFB production record (with embedding) */
  23. @Post()
  24. async create(@Body() body: FFBProduction) {
  25. console.log('POST /ffb-production');
  26. return this.ffbService.create(body);
  27. }
  28. /** Find all records */
  29. @Get()
  30. async findAll(@Query() query: any) {
  31. console.log('GET /ffb-production', query);
  32. return this.ffbService.findAll(query);
  33. }
  34. /** Find a record by ID */
  35. @Get(':id')
  36. async findById(@Param('id') id: string) {
  37. console.log(`GET /ffb-production/${id}`);
  38. return this.ffbService.findById(id);
  39. }
  40. /** Delete a record by ID */
  41. @Delete(':id')
  42. async delete(@Param('id') id: string) {
  43. console.log(`DELETE /ffb-production/${id}`);
  44. return this.ffbService.delete(id);
  45. }
  46. }