Skip to content

Commit

Permalink
feat: update to use English prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 8, 2023
1 parent 04ea0c6 commit 113cdba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/openai/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ export function getSystemPrompt(promptConfig: PromptConfig) {
console.log('prompt config: ', promptConfig);

const { language = '中文', shouldShowTimestamp } = promptConfig
const betterPrompt = `我希望你是一名专业的视频内容编辑,帮我用${language}总结视频的内容精华。请你将视频字幕文本进行总结(字幕中可能有错别字,如果你发现了错别字请改正),然后以无序列表的方式返回,不要超过5条。记得不要重复句子,确保所有的句子都足够精简,清晰完整,祝你好运!`
// @ts-ignore
const enLanguage = PROMPT_LANGUAGE_MAP[language]
// 我希望你是一名专业的视频内容编辑,帮我用${language}总结视频的内容精华。请你将视频字幕文本进行总结(字幕中可能有错别字,如果你发现了错别字请改正),然后以无序列表的方式返回,不要超过5条。记得不要重复句子,确保所有的句子都足够精简,清晰完整,祝你好运!
const betterPrompt = `I would like you to be a professional video content editor and help me summarize the content highlights of the video in ${enLanguage}. Please summarize the video subtitle text (there may be typos in the subtitles, so please correct them if you find them) and return it as an unordered list of no more than 5 sentences. Remember not to repeat sentences, make sure all sentences are concise enough to be clear and complete. Good luck!`
const timestamp = '' //`(类似 10:24)`;
const promptWithTimestamp = `我希望你是一名专业的视频内容编辑,帮我用${language}总结视频的内容精华。请先用一句简短的话总结视频梗概。然后再请你将视频字幕文本进行总结(字幕中可能有错别字,如果你发现了错别字请改正),在每句话的最前面加上时间戳${timestamp},每句话开头只需要一个开始时间。请你以无序列表的方式返回,请注意不要超过5条哦,确保所有的句子都足够精简,清晰完整,祝你好运!`;
// 我希望你是一名专业的视频内容编辑,帮我用${language}总结视频的内容精华。请先用一句简短的话总结视频梗概。然后再请你将视频字幕文本进行总结(字幕中可能有错别字,如果你发现了错别字请改正),在每句话的最前面加上时间戳${timestamp},每句话开头只需要一个开始时间。请你以无序列表的方式返回,请注意不要超过5条哦,确保所有的句子都足够精简,清晰完整,祝你好运!
const promptWithTimestamp = `I would like you to be a professional video content editor and help me summarize the content highlights of the video in ${language}. Please summarize the video subtitle text (there may be typos in the subtitles, so please correct them if you find them) and return it as an unordered list of no more than 5 sentences. Remember not to repeat sentences, make sure all sentences are concise enough to be clear and complete. Good luck!`;

return shouldShowTimestamp ? promptWithTimestamp : betterPrompt
}
Expand Down
5 changes: 4 additions & 1 deletion pages/api/sumup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ export default async function handler(
shouldShowTimestamp: subtitlesArray ? shouldShowTimestamp : false,
});
const userPrompt = getUserSubtitlePrompt(title, inputText);
if (isDev) {
console.log("final system prompt: ", systemPrompt);
console.log("final user prompt: ", userPrompt);
}

try {
isDev && console.log("final user prompt", userPrompt);
const payload = {
model: "gpt-3.5-turbo",
messages: [
Expand Down

1 comment on commit 113cdba

@vercel
Copy link

@vercel vercel bot commented on 113cdba Mar 8, 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.