Repository navigation
feat: add option to automatically create video chapters with AI - #11
Merged
its-gabo merged 2 commits intoNov 21, 2026
Merged
Conversation
its-gabo
deleted the
gs_feat_add_option_to_autogenerate_chapters_with_ai
branch
November 21, 2026 18:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Members can have chapters suggested from a video's caption track. An organization's provider writes them with the model the owner chooses for it,
gpt-6-lunaby default. The suggestions fill the chapter editor as a draft, so nothing is saved until the member reviews and saves them.Providers work like transcription providers. The owner connects OpenAI or an OpenAI-compatible server once per organization, picks its model, then chooses a provider per library. Both transcription and chapter generation providers can now have a monthly usage limit: minutes of audio for transcription, tokens for chapter generation.
What changed
Chapter generation (new
chapter-generationAPI module)chapter_generation_providerstable, with create, update, delete and connection-test routes for owners.gpt-6-lunaand must support structured output.libraries.chapter_generation_provider_id, read and changed withGET/PUT /libraries/:libraryId/chapter-generation. Only the owner can do this.POST /videos/:videoId/chapter-suggestions { captionId }. Any member can call it. It answers with draft chapters and saves nothing.Output.objectwith a zod schema):@ai-sdk/openai).@ai-sdk/openai-compatible).fetchreuses the transcription request helper. It refuses private addresses unless allowed, doesn't follow redirects, limits the answer's size and time, and passes abort signals through.[123] text, with long transcripts shortened evenly.CHAPTER_GENERATION_REQUEST_TIMEOUT_MSdefaults to 100s and config refuses anything over 110s, so it always ends before the server's 120s idle timeout. When the member's connection closes, the provider request is cancelled.Monthly usage limits
monthly_minute_limit):usage_limit_reached, and the failure webhook fires.transcribed_audio_seconds, records the audio the provider answered for, chunk by chunk and across attempts. A failed transcription counts that amount. Any other transcription counts the larger of the video's length and that amount, so audio sent again on a retry is included.monthly_token_limit):chapter_generation_usagesbefore the provider is asked: its input, counted withgpt-tokenizer(o200k) plus 10% and 200 for overhead, and room for the answer. The answer gets up to 16,000 tokens, or whatever the limit leaves.maxOutputTokensis capped to the reserved room.Fixes in existing code
node:httpignores thesignaloption.Web
gpt-6-luna.1.5is refused instead of being read as 15.Database
0015_add_chapter_generation_and_usage_limits, covering the new tables and columns, the activity actions and the failure reason.