Illia56 commited on
Commit
6fe7bd1
1 Parent(s): fbe56d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -3
app.py CHANGED
@@ -11,6 +11,9 @@ from langchain.callbacks.manager import CallbackManagerForLLMRun
11
  from langchain.llms.base import LLM
12
  from langchain.chains import RetrievalQA
13
  import streamlit as st
 
 
 
14
 
15
  models = '''| Model | Llama2 | Llama2-hf | Llama2-chat | Llama2-chat-hf |
16
  |---|---|---|---|---|
@@ -29,6 +32,9 @@ To get started, simply paste a YouTube video URL in the sidebar and start chatti
29
  st.title("YouTube Video Chatbot")
30
  st.markdown(DESCRIPTION)
31
 
 
 
 
32
 
33
  def transcribe_video(youtube_url: str, path: str) -> List[Document]:
34
  """
@@ -88,12 +94,23 @@ def initialize_session_state():
88
  st.session_state.doneYoutubeurl = ""
89
 
90
  def sidebar():
 
91
  with st.sidebar:
92
- st.markdown(
93
- "Enter the YouTube Video URL below🔗\n"
94
- )
95
  st.session_state.youtube_url = st.text_input("YouTube Video URL:")
96
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  sidebar()
99
  initialize_session_state()
 
11
  from langchain.llms.base import LLM
12
  from langchain.chains import RetrievalQA
13
  import streamlit as st
14
+ from pytube import YouTube
15
+
16
+
17
 
18
  models = '''| Model | Llama2 | Llama2-hf | Llama2-chat | Llama2-chat-hf |
19
  |---|---|---|---|---|
 
32
  st.title("YouTube Video Chatbot")
33
  st.markdown(DESCRIPTION)
34
 
35
+ def get_video_title(youtube_url: str) -> str:
36
+ yt = YouTube(youtube_url)
37
+ return yt.title
38
 
39
  def transcribe_video(youtube_url: str, path: str) -> List[Document]:
40
  """
 
94
  st.session_state.doneYoutubeurl = ""
95
 
96
  def sidebar():
97
+ def sidebar():
98
  with st.sidebar:
99
+ st.markdown("Enter the YouTube Video URL below🔗\n")
 
 
100
  st.session_state.youtube_url = st.text_input("YouTube Video URL:")
101
 
102
+ if st.session_state.youtube_url:
103
+ # Get the video title
104
+ video_title = get_video_title(st.session_state.youtube_url)
105
+ st.markdown(f"### {video_title}")
106
+
107
+ # Embed the video
108
+ st.markdown(
109
+ f'<iframe min-width="300" min-height="200" src="{st.session_state.youtube_url.replace("watch?v=", "embed/")}" frameborder="0" allowfullscreen></iframe>',
110
+ unsafe_allow_html=True
111
+ )
112
+
113
+
114
 
115
  sidebar()
116
  initialize_session_state()