|
|
@@ -1,7 +1,7 @@ |
|
|
|
import { CreateSummarizerParams } from '@modal-sh/webvideo-transcript-summary-core'; |
|
|
|
import { SummaryService, SummaryServiceImpl } from './SummaryService'; |
|
|
|
import * as config from '../../config'; |
|
|
|
import { RouteHandlerMethod } from 'fastify'; |
|
|
|
import {CreateSummarizerParams} from '@modal-sh/webvideo-transcript-summary-core'; |
|
|
|
import * as config from '../../config'; |
|
|
|
import { SummaryService, SummaryServiceImpl } from './SummaryService'; |
|
|
|
|
|
|
|
export interface SummaryController { |
|
|
|
summarizeVideoTranscript: RouteHandlerMethod; |
|
|
@@ -9,10 +9,7 @@ export interface SummaryController { |
|
|
|
|
|
|
|
export class SummaryControllerImpl implements SummaryController { |
|
|
|
constructor( |
|
|
|
private readonly summaryService: SummaryService = new SummaryServiceImpl( |
|
|
|
config.openai.apiKey, |
|
|
|
config.openai.organizationId, |
|
|
|
), |
|
|
|
private readonly summaryService: SummaryService = new SummaryServiceImpl(), |
|
|
|
) { |
|
|
|
// noop |
|
|
|
} |
|
|
@@ -20,9 +17,22 @@ export class SummaryControllerImpl implements SummaryController { |
|
|
|
readonly summarizeVideoTranscript: RouteHandlerMethod = async (request, reply) => { |
|
|
|
const params = request.body as CreateSummarizerParams; |
|
|
|
try { |
|
|
|
const summaryResult = await this.summaryService.summarizeVideoTranscript(params); |
|
|
|
const summaryResult = await this.summaryService.summarizeVideoTranscript({ |
|
|
|
url: params.url, |
|
|
|
type: params.type, |
|
|
|
openAiParams: { |
|
|
|
apiKey: config.openAi.apiKey, |
|
|
|
organizationId: config.openAi.organizationId, |
|
|
|
temperature: params.openAiParams?.temperature ?? 0.6, |
|
|
|
model: params.openAiParams?.model ?? 'gpt-3.5-turbo', |
|
|
|
}, |
|
|
|
language: params.language ?? 'en', |
|
|
|
country: params.country ?? 'US', |
|
|
|
}); |
|
|
|
reply.send(summaryResult); |
|
|
|
} catch { |
|
|
|
} catch (errRaw) { |
|
|
|
const err = errRaw as Error; |
|
|
|
request.server.log.error(err); |
|
|
|
reply |
|
|
|
.code(500) |
|
|
|
.send(); |
|
|
|