mutea commited on
Commit
dcdddb7
1 Parent(s): 24c32a2

create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import langchain_helper as lch
2
+ import streamlit as st
3
+ import textwrap
4
+
5
+
6
+ st.title("YouTube Assistant(Question Answering app based on youtube video)")
7
+
8
+ with st.sidebar:
9
+ with st.form(key='my_form'):
10
+ youtube_url = st.sidebar.text_area(
11
+ label="Paste the youtube video URL",
12
+ max_chars=50
13
+ )
14
+
15
+ query = st.sidebar.text_area(
16
+ label="Ask me anything based on the video",
17
+ max_chars=50,
18
+ key="query"
19
+ )
20
+
21
+ "[Get an OpenAI API key](https://platform.openai.com/account/api-keys)"
22
+
23
+ with st.sidebar:
24
+ submit_btn = st.form_submit_button(label="Ask")
25
+
26
+
27
+ if query and youtube_url and submit_btn:
28
+ with st.spinner("Wait while I query the video..."):
29
+ db = lch.create_vector_db_from_ytUrl(youtube_url)
30
+ response, docs = lch.get_response_from_query(db, query)
31
+
32
+ st.subheader(f"You asked: {query}. Here is what I got:")
33
+ st.text(textwrap.fill(response, width=80))