Spaces:
Sleeping
Sleeping
Commit
·
980beb7
1
Parent(s):
46e1c73
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
|
27 |
"Enter my own URL"]
|
28 |
genre = st.radio(
|
29 |
"Choose dataset to finetune", radioButtonList, index=0
|
@@ -50,7 +50,7 @@ elif genre==radioButtonList[2]:
|
|
50 |
pdfCSVURLText = "PDF"
|
51 |
elif genre==radioButtonList[3]:
|
52 |
pdfCSVURLText = "URL"
|
53 |
-
urls = ['https://
|
54 |
loader = [UnstructuredURLLoader(urls=urls)]
|
55 |
index = VectorstoreIndexCreator(
|
56 |
embedding=GooglePalmEmbeddings(),
|
@@ -62,9 +62,19 @@ elif genre==radioButtonList[3]:
|
|
62 |
input_key="question")
|
63 |
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://
|
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,15 +133,5 @@ if st.button(chatWithPDFButton, disabled=not enableChatBox and not chatTextStr):
|
|
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)
|
|
|
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 Latest Earnings (https://abc.xyz/investor/)",
|
27 |
"Enter my own URL"]
|
28 |
genre = st.radio(
|
29 |
"Choose dataset to finetune", radioButtonList, index=0
|
|
|
50 |
pdfCSVURLText = "PDF"
|
51 |
elif genre==radioButtonList[3]:
|
52 |
pdfCSVURLText = "URL"
|
53 |
+
urls = ['https://abc.xyz/investor/']
|
54 |
loader = [UnstructuredURLLoader(urls=urls)]
|
55 |
index = VectorstoreIndexCreator(
|
56 |
embedding=GooglePalmEmbeddings(),
|
|
|
62 |
input_key="question")
|
63 |
elif genre==radioButtonList[4]:
|
64 |
pdfCSVURLText = "URL"
|
65 |
+
urls = [urlInput]
|
66 |
+
loader = [UnstructuredURLLoader(urls=urls)]
|
67 |
+
index = VectorstoreIndexCreator(
|
68 |
+
embedding=GooglePalmEmbeddings(),
|
69 |
+
text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)).from_loaders(loader)
|
70 |
+
|
71 |
+
chain = RetrievalQA.from_chain_type(llm=llm,
|
72 |
+
chain_type="stuff",
|
73 |
+
retriever=index.vectorstore.as_retriever(),
|
74 |
+
input_key="question")
|
75 |
|
76 |
isCustomURL = genre==radioButtonList[4]
|
77 |
+
urlInput = st.text_input('Enter your own URL', '', placeholder="Type your URL here (e.g. https://abc.xyz/investor/)", disabled=not isCustomURL)
|
78 |
|
79 |
isCustomPDF = genre==radioButtonList[1] or genre==radioButtonList[2]
|
80 |
uploaded_file = st.file_uploader(f"Upload your own {pdfCSVURLText} here", type=pdfCSVURLText.lower(), disabled=not isCustomPDF)
|
|
|
133 |
st.write(answer)
|
134 |
|
135 |
elif genre==radioButtonList[4]: # Custom URL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
answer = chain.run(chatTextStr)
|
137 |
st.write(answer)
|