Get transcript summaries of Web videos.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

33 řádky
937 B

  1. import {
  2. createSummarizer,
  3. SummarizerEventEmitter,
  4. OPENAI_API_VERSION,
  5. } from '@modal-sh/webvideo-transcript-summary-core';
  6. import { Readable } from '../../packages/event-emitter-to-readable-stream';
  7. import * as config from '../../config';
  8. export interface SummaryService {
  9. createSummaryStream(transcriptText: string): NodeJS.ReadableStream;
  10. }
  11. export class SummaryServiceImpl implements SummaryService {
  12. private readonly summarizer: SummarizerEventEmitter;
  13. constructor() {
  14. // noop
  15. this.summarizer = createSummarizer({
  16. apiKey: config.openAi.apiKey,
  17. organizationId: config.openAi.organizationId,
  18. apiVersion: OPENAI_API_VERSION,
  19. });
  20. }
  21. createSummaryStream(transcriptText: string) {
  22. const stream = Readable.fromEventEmitter(
  23. this.summarizer,
  24. ) as unknown as NodeJS.ReadableStream & { tokenCount: number };
  25. this.summarizer.summarize(transcriptText);
  26. return stream;
  27. }
  28. }