4545display_link_to_repo ("summary" )
4646# --- end ---
4747
48- # variable for holding the Video object
49- saved_video : None | Video = None
48+
49+ @st .dialog (title = "Transcript too long" , width = "large" )
50+ def display_dialog (message : str ):
51+ st .warning (message )
5052
5153
5254def save_summary_to_lib ():
5355 """Wrapper func for saving summaries to the library."""
5456 try :
57+ saved_video = Video .create (
58+ yt_video_id = extract_youtube_video_id (url_input ),
59+ link = url_input ,
60+ title = vid_metadata ["name" ],
61+ channel = vid_metadata ["channel" ],
62+ saved_on = dt .now (),
63+ )
5564 save_library_entry (
5665 entry_type = "S" ,
5766 question_text = None ,
@@ -65,11 +74,6 @@ def save_summary_to_lib():
6574 st .success ("Saved summary to library successfully!" )
6675
6776
68- @st .dialog (title = "Transcript too long" , width = "large" )
69- def display_dialog (message : str ):
70- st .warning (message )
71-
72-
7377if is_api_key_set () and is_api_key_valid (st .session_state .openai_api_key ):
7478
7579 # --- rest of the sidebar, which requires an api key to be set ---
@@ -113,13 +117,6 @@ def display_dialog(message: str):
113117 with col2 :
114118 if summarize_button :
115119 try :
116- saved_video = Video .create (
117- yt_video_id = extract_youtube_video_id (url_input ),
118- link = url_input ,
119- title = vid_metadata ["name" ],
120- channel = vid_metadata ["channel" ],
121- saved_on = dt .now (),
122- )
123120 transcript = fetch_youtube_transcript (url_input )
124121 cb = OpenAICallbackHandler ()
125122 llm = ChatOpenAI (
@@ -133,10 +130,14 @@ def display_dialog(message: str):
133130 with st .spinner ("Summarizing video :gear: Hang on..." ):
134131 if custom_prompt :
135132 resp = get_transcript_summary (
136- transcript , llm , custom_prompt = custom_prompt
133+ transcript_text = transcript ,
134+ llm = llm ,
135+ custom_prompt = custom_prompt ,
137136 )
138137 else :
139- resp = get_transcript_summary (transcript , llm )
138+ resp = get_transcript_summary (
139+ transcript_text = transcript , llm = llm
140+ )
140141 st .session_state .summary = resp
141142 st .markdown (st .session_state .summary )
142143
0 commit comments