Illia56 commited on
Commit
365894c
1 Parent(s): 10acb2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -36,7 +36,7 @@ st.markdown(DESCRIPTION)
36
  def get_video_title(youtube_url: str) -> str:
37
  yt = YouTube(youtube_url)
38
  embed_url = f"https://www.youtube.com/embed/{yt.video_id}"
39
- embed_html = f'<iframe width="560" height="315" src="{embed_url}" frameborder="0" allowfullscreen></iframe>'
40
  return yt.title, embed_html
41
 
42
 
@@ -152,7 +152,7 @@ if st.session_state.youtube_url and not st.session_state.setup_done:
152
  retriever.search_kwargs['k'] = 4
153
  with st.status("Running RetrievalQA..."):
154
  llama_instance = LlamaLLM()
155
- st.session_state.qa = RetrievalQA.from_chain_type(llm=llama_instance, chain_type="stuff", retriever=retriever,return_source_documents=True,chain_type_kwargs={"prompt": prompt})
156
 
157
  st.session_state.doneYoutubeurl = st.session_state.youtube_url
158
  st.session_state.setup_done = True # Mark the setup as done for this URL
@@ -170,9 +170,8 @@ if prompt := textinput:
170
  st.chat_message("human",avatar = "🧑‍💻").markdown(prompt)
171
  st.session_state.messages.append({"role": "human", "content": prompt})
172
  with st.status("Requesting Client..."):
173
- response = st.session_state.qa(
174
- {"query": prompt})
175
  with st.chat_message("assistant", avatar='🦙'):
176
- st.markdown(str(response["result"])+'\n'+str(response["source_documents"]))
177
  # Add assistant response to chat history
178
  st.session_state.messages.append({"role": "assistant", "content": response})
 
36
  def get_video_title(youtube_url: str) -> str:
37
  yt = YouTube(youtube_url)
38
  embed_url = f"https://www.youtube.com/embed/{yt.video_id}"
39
+ embed_html = f'<iframe src="{embed_url}" frameborder="0" allowfullscreen></iframe>'
40
  return yt.title, embed_html
41
 
42
 
 
152
  retriever.search_kwargs['k'] = 4
153
  with st.status("Running RetrievalQA..."):
154
  llama_instance = LlamaLLM()
155
+ st.session_state.qa = RetrievalQA.from_chain_type(llm=llama_instance, chain_type="stuff", retriever=retriever,chain_type_kwargs={"prompt": prompt})
156
 
157
  st.session_state.doneYoutubeurl = st.session_state.youtube_url
158
  st.session_state.setup_done = True # Mark the setup as done for this URL
 
170
  st.chat_message("human",avatar = "🧑‍💻").markdown(prompt)
171
  st.session_state.messages.append({"role": "human", "content": prompt})
172
  with st.status("Requesting Client..."):
173
+ response = st.session_state.qa.run(prompt)
 
174
  with st.chat_message("assistant", avatar='🦙'):
175
+ st.markdown(response)
176
  # Add assistant response to chat history
177
  st.session_state.messages.append({"role": "assistant", "content": response})