Skip to content

Commit

Permalink
feat: enabled settings for timestamp mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 13, 2023
1 parent aa59f0a commit 722377b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 0 additions & 3 deletions components/PromptOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function PromptOptions({
<select
id="outputLanguage"
className="block w-full rounded-md border border-gray-300 bg-gray-50 text-sm text-gray-900 focus:border-sky-500 focus:ring-sky-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-sky-500 dark:focus:ring-sky-500"
disabled={shouldShowTimestamp}
{...register("outputLanguage")}
>
{Object.keys(PROMPT_LANGUAGE_MAP).map((k: string) => (
Expand All @@ -71,7 +70,6 @@ export function PromptOptions({
max={10}
step={1}
className="h-2 w-full cursor-pointer accent-black rounded-lg bg-gray-200 dark:bg-gray-700"
disabled={shouldShowTimestamp}
{...register("sentenceNumber")}
/>
</div>
Expand Down Expand Up @@ -109,7 +107,6 @@ export function PromptOptions({
max={1000}
step={10}
className="h-2 w-full accent-black cursor-pointer rounded-lg bg-gray-200 dark:bg-gray-700"
disabled={shouldShowTimestamp}
{...register("detailLevel")}
/>
</div>
Expand Down
14 changes: 8 additions & 6 deletions lib/openai/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export function getUserSubtitlePrompt(
const videoTranscript = limitTranscriptByteLength(transcript)
.replace(/\n+/g, " ")
.trim();
const language = videoConfig.outputLanguage;
const sentenceCount = videoConfig.sentenceNumber;
const language = videoConfig.outputLanguage|| 'Chinese';
const sentenceCount = videoConfig.sentenceNumber|| 7;
const emojiTemplateText = videoConfig.showEmoji ? "[Emoji] " : ""
const emojiDescriptionText = videoConfig.showEmoji ? "Choose an appropriate emoji for each bullet point. " : ""
const shouldShowAsOutline = Number(videoConfig.outlineLevel) > 1;
Expand All @@ -60,15 +60,17 @@ export function getUserSubtitlePrompt(

export function getUserSubtitleWithTimestampPrompt(
title: string,
transcript: any
transcript: any,
videoConfig: VideoConfig
) {
const videoTitle = title?.replace(/\n+/g, " ").trim();
const videoTranscript = limitTranscriptByteLength(transcript)
.replace(/\n+/g, " ")
.trim();
const language = "Chinese";
const sentenceCount = "7";
const promptWithTimestamp = `Act as the author and provide exactly 5 bullet points all in ${language} language for the text transcript given in the format [seconds] - [text] \nMake sure that:\n - Please start by summarizing the whole video in one short sentence\n - Then, please summarize with not more than ${sentenceCount} bullet points\n - each bullet_point is at least 15 words\n - each bullet_point start with \"- \" or a number or a bullet point symbol\n - each bullet_point should has the start timestamp, e.g. seconds - [Emoji] [bullet_point]\n - there may be typos in the subtitles, please correct them`;
const language = videoConfig.outputLanguage || 'Chinese';
const sentenceCount = videoConfig.sentenceNumber || 7;
const wordsCount = videoConfig.detailLevel ? (Number(videoConfig.detailLevel)/10)*2 : 15;
const promptWithTimestamp = `Act as the author and provide exactly ${sentenceCount} bullet points all in ${language} language for the text transcript given in the format [seconds] - [text] \nMake sure that:\n - Please start by summarizing the whole video in one short sentence\n - Then, please summarize with each bullet_point is at least ${wordsCount} words\n - each bullet_point start with \"- \" or a number or a bullet point symbol\n - each bullet_point should has the start timestamp, e.g. seconds - [Emoji] [bullet_point]\n - there may be typos in the subtitles, please correct them`;
const videoTranscripts = limitTranscriptByteLength(
JSON.stringify(videoTranscript)
);
Expand Down
2 changes: 1 addition & 1 deletion pages/api/sumup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default async function handler(
// });
// const examplePrompt = getExamplePrompt();
const userPrompt = shouldShowTimestamp
? getUserSubtitleWithTimestampPrompt(title, inputText)
? getUserSubtitleWithTimestampPrompt(title, inputText, videoConfig)
: getUserSubtitlePrompt(title, inputText, videoConfig);
if (isDev) {
// console.log("final system prompt: ", systemPrompt);
Expand Down

1 comment on commit 722377b

@vercel
Copy link

@vercel vercel bot commented on 722377b Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.