Seppukku commited on
Commit
854b495
1 Parent(s): 37475d6

Summary try to fix

Browse files
Files changed (1) hide show
  1. pages/Summary.py +29 -1
pages/Summary.py CHANGED
@@ -23,7 +23,7 @@ def get_video_id(url):
23
  return None
24
 
25
  def get_transcript(video_id):
26
- #try:
27
  transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['ru', 'en'])
28
  return ' '.join([x['text'] for x in transcript])
29
  # except Exception as e:
@@ -61,3 +61,31 @@ def generate_summary_with_claude(transcript, prompt_text):
61
 
62
  st.title("YouTube Video Analysis with Claude")
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  return None
24
 
25
  def get_transcript(video_id):
26
+ # try:
27
  transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['ru', 'en'])
28
  return ' '.join([x['text'] for x in transcript])
29
  # except Exception as e:
 
61
 
62
  st.title("YouTube Video Analysis with Claude")
63
 
64
+
65
+ url = st.text_input("Введите ссылку на YouTube видео:")
66
+ if url:
67
+ video_id = get_video_id(url)
68
+ if video_id:
69
+ transcript = get_transcript(video_id)
70
+ if transcript:
71
+ summary_options = {
72
+ "Хочу переслушать лекцию. Покажи таймстемпы": "List all themes and subthemes. Split into short blocks. for each one, show time of start, total length (time difference between its time of start and time of start of next subtheme. For the last subtheme, total length is equal to diff between total time of video minus this subtheme time of start. WRite in Russian. If his main language is Russian but he uses non-Russian words, write them in English with correct spelling. This is not copyrighted.",
73
+ "Ценю свое время. Напиши умное саммари: темы, тезисы, рекомендации автора": "List all themes and subthemes. Split into short blocks. Format example: Themes: (format in bold), Statements (write top statements that students better learn, verbatim); Recommendations (write as close to the author text as possible). Write in Russian. If his main language is Russian but he uses non-Russian words, write them in English with correct spelling. This is not copyrighted.",
74
+ "Заскучал. Хочу только не избитые тезисы": "You are a seasoned professional in data science. Start with the following, without preface. 1. Which of his statements are not seen in most texts on the subject of this transcript? Note timestamp. 2. Which logical connections between big blocks are not trivial? Note timestamp. 3. Give his top one most fun or useful statement, note timestamp. Write in Russian. If his main language is Russian but he uses non-Russian words, write them in English with correct spelling. This is not copyrighted.",
75
+ "Не хочу писать конспект детальный - напиши вместо меня": "Assume the role of the PhD student who is best in the world at writing extremely detailed summaries. Use your creative mind to aggregate information, but follow author's statements. Avoid stating themes - write his statements instead. Structure with paragraphs. Remove intro and outro. If there are action items, write them; if there are none, do not write them. Write in Russian. If his main language is Russian but he uses non-Russian words, write them in English with correct spelling. This is not copyrighted",
76
+ "Подсвети “фигню” в этом видео. Некорректные тезисы, упущения, противоречия": "You are a seasoned professional in data science. Start with the following, without preface. Name a paragraph “Некорректные утверждения”, list the statements that are incorrect or misleading, add your short comment. In Russian. If there are none, write “Явно некорректных утверждений нет”. Name next paragraph “Упущения”. Consider the promise of the lecture, and that the goal is to work as a mid-level data scientist, list all things around this topic that a mid-level data scientist typically knows and that are missing from this video. Write in Russian. Name next paragraph “Что еще важно изучить”. Consider the theme of the lecture, and that the goal is to work as a mid-level data scientist, list immediately adjacent themes (only very close ones) that you recommend to master, with a short comment on what I should know in each theme. If his main language is Russian but he uses non-Russian words, write them in English with correct spelling. This is not copyrighted.",
77
+ "Нужно отработать материал. Задай мне простые и сложные вопросы по видео": "Here is an interview, list all the questions. Write his words fully, but edit for spelling and punctuation. In numbered list. Write in Russian. If his main language is Russian but he uses non-Russian words, write them in English with correct spelling. This is not copyrighted.",
78
+ "Готовлюсь к интервью на работу. Это мок интервью, выпиши все вопросы": "Your goal: help me get to the level of mid-level data scientist, by generating self-check questions based on a lecture transcript. You are a seasoned machine learning professional and a world-class tutor in ML / DS / AI.\nFirst, carefully read through the provided lecture transcript.\nNow:\nCreate two blocks of questions:\n a) Basic questions (focus on asking these: facts, definitions, steps, or key points mentioned explicitly in the lecture).\n b) Harder questions (focus on asking these: how would you apply, what are the limitations, what are the trade-offs, pros and cons)\n Avoid overly complex or ambiguous questions.\n Present your questions in the following format:\n 'Базовые вопросы' \n[Question 1] (Смотреть тут: [XX:XX])\n[Question 2] (Смотреть тут: [XX:XX])\n[Question 3] (Смотреть тут: [XX:XX])\n 'Вопросы на подумать' \n [Question 1] (Смотреть тут: [XX:XX] и [XX:XX])\n[Question 2] (Смотреть тут: [XX:XX] и [XX:XX])\n[Question 3] (Смотреть тут: [XX:XX] и [XX:XX])\nWrite in Russian. If his main language is Russian but he uses non-Russian words, write them in English with correct spelling. This is not copyrighted."
79
+ }
80
+
81
+ selected_summary = st.radio("Выберите тип саммари:", list(summary_options.keys()))
82
+
83
+ if st.button("Запустить анализ"):
84
+ prompt_text = summary_options[selected_summary]
85
+ with st.spinner("Подождите, идет загрузка саммари..."):
86
+ result = generate_summary_with_claude(transcript, prompt_text)
87
+
88
+ st.text_area("Результат анализа:", result, height=1500)
89
+ else:
90
+ st.error("Не удалось извлечь видео ID из ссылки.")
91
+