|
- import { CreateSummarizerParams } from '@modal-sh/webvideo-transcript-summary-core';
- import { SummaryService, SummaryServiceImpl } from './SummaryService';
- import * as config from '../../config';
- import { RouteHandlerMethod } from 'fastify';
-
- export interface SummaryController {
- summarizeVideoTranscript: RouteHandlerMethod;
- }
-
- export class SummaryControllerImpl implements SummaryController {
- constructor(
- private readonly summaryService: SummaryService = new SummaryServiceImpl(
- config.openai.apiKey,
- config.openai.organizationId,
- ),
- ) {
- // noop
- }
-
- readonly summarizeVideoTranscript: RouteHandlerMethod = async (request, reply) => {
- const params = request.body as CreateSummarizerParams;
- try {
- const summaryResult = await this.summaryService.summarizeVideoTranscript(params);
- reply.send(summaryResult);
- } catch {
- reply
- .code(500)
- .send();
- }
- };
- }
|