Get transcript summaries of Web videos.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
935 B

  1. import { CreateSummarizerParams } from '@modal-sh/webvideo-transcript-summary-core';
  2. import { SummaryService, SummaryServiceImpl } from './SummaryService';
  3. import * as config from '../../config';
  4. import { RouteHandlerMethod } from 'fastify';
  5. export interface SummaryController {
  6. summarizeVideoTranscript: RouteHandlerMethod;
  7. }
  8. export class SummaryControllerImpl implements SummaryController {
  9. constructor(
  10. private readonly summaryService: SummaryService = new SummaryServiceImpl(
  11. config.openai.apiKey,
  12. config.openai.organizationId,
  13. ),
  14. ) {
  15. // noop
  16. }
  17. readonly summarizeVideoTranscript: RouteHandlerMethod = async (request, reply) => {
  18. const params = request.body as CreateSummarizerParams;
  19. try {
  20. const summaryResult = await this.summaryService.summarizeVideoTranscript(params);
  21. reply.send(summaryResult);
  22. } catch {
  23. reply
  24. .code(500)
  25. .send();
  26. }
  27. };
  28. }