Spaces:
Sleeping
Sleeping
Commit
·
46e1c73
1
Parent(s):
c433c37
updated pom file
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ import pprint
|
|
23 |
radioButtonList = ["E-commerce CSV (https://www.kaggle.com/datasets/mervemenekse/ecommerce-dataset)",
|
24 |
"Upload my own CSV",
|
25 |
"Upload my own PDF",
|
26 |
-
"URL Chat with Google Alphabet's 2022 Q2 Earnings Report (https://tinyurl.com/
|
27 |
"Enter my own URL"]
|
28 |
genre = st.radio(
|
29 |
"Choose dataset to finetune", radioButtonList, index=0
|
@@ -64,7 +64,7 @@ elif genre==radioButtonList[4]:
|
|
64 |
pdfCSVURLText = "URL"
|
65 |
|
66 |
isCustomURL = genre==radioButtonList[4]
|
67 |
-
urlInput = st.text_input('Enter your own URL', '', placeholder="Type your URL here (e.g. https://tinyurl.com/
|
68 |
|
69 |
isCustomPDF = genre==radioButtonList[1] or genre==radioButtonList[2]
|
70 |
uploaded_file = st.file_uploader(f"Upload your own {pdfCSVURLText} here", type=pdfCSVURLText.lower(), disabled=not isCustomPDF)
|
@@ -123,5 +123,15 @@ if st.button(chatWithPDFButton, disabled=not enableChatBox and not chatTextStr):
|
|
123 |
st.write(answer)
|
124 |
|
125 |
elif genre==radioButtonList[4]: # Custom URL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
answer = chain.run(chatTextStr)
|
127 |
st.write(answer)
|
|
|
23 |
radioButtonList = ["E-commerce CSV (https://www.kaggle.com/datasets/mervemenekse/ecommerce-dataset)",
|
24 |
"Upload my own CSV",
|
25 |
"Upload my own PDF",
|
26 |
+
"URL Chat with Google Alphabet's 2022 Q2 Earnings Report (https://tinyurl.com/f85wujsj)",
|
27 |
"Enter my own URL"]
|
28 |
genre = st.radio(
|
29 |
"Choose dataset to finetune", radioButtonList, index=0
|
|
|
64 |
pdfCSVURLText = "URL"
|
65 |
|
66 |
isCustomURL = genre==radioButtonList[4]
|
67 |
+
urlInput = st.text_input('Enter your own URL', '', placeholder="Type your URL here (e.g. https://tinyurl.com/f85wujsj)", disabled=not isCustomURL)
|
68 |
|
69 |
isCustomPDF = genre==radioButtonList[1] or genre==radioButtonList[2]
|
70 |
uploaded_file = st.file_uploader(f"Upload your own {pdfCSVURLText} here", type=pdfCSVURLText.lower(), disabled=not isCustomPDF)
|
|
|
123 |
st.write(answer)
|
124 |
|
125 |
elif genre==radioButtonList[4]: # Custom URL
|
126 |
+
urls = [urlInput]
|
127 |
+
loader = [UnstructuredURLLoader(urls=urls)]
|
128 |
+
index = VectorstoreIndexCreator(
|
129 |
+
embedding=GooglePalmEmbeddings(),
|
130 |
+
text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)).from_loaders(loader)
|
131 |
+
|
132 |
+
chain = RetrievalQA.from_chain_type(llm=llm,
|
133 |
+
chain_type="stuff",
|
134 |
+
retriever=index.vectorstore.as_retriever(),
|
135 |
+
input_key="question")
|
136 |
answer = chain.run(chatTextStr)
|
137 |
st.write(answer)
|