Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,5 @@
|
|
| 1 |
-
import bs4
|
| 2 |
-
from langchain import hub
|
| 3 |
-
from langchain_chroma import Chroma
|
| 4 |
from langchain_community.document_loaders import WebBaseLoader
|
| 5 |
-
from langchain_core.output_parsers import StrOutputParser
|
| 6 |
from langchain_core.runnables import RunnablePassthrough
|
| 7 |
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
| 8 |
from langchain.embeddings import HuggingFaceEmbeddings
|
|
@@ -125,12 +122,14 @@ def source (radio, source1, source2):
|
|
| 125 |
with gr.Blocks() as demo:
|
| 126 |
vectorstore = gr.State()
|
| 127 |
with gr.Tab("Setup"):
|
|
|
|
|
|
|
| 128 |
with gr.Row():
|
| 129 |
source1 = gr.Textbox(label="Input website",)
|
| 130 |
-
source2 = gr.Files(label="Upload a PDF file", file_count="single", file_types=["pdf"])
|
| 131 |
-
radio = gr.Radio(["website", "PDF"], label="Select type of source", interactive=True)
|
| 132 |
-
path = gr.Textbox(lines=2, interactive=True, label="Path of source", visible=True )
|
| 133 |
radio.change(fn=source, inputs=[radio,source1,source2], outputs=path)
|
|
|
|
|
|
|
| 134 |
done = gr.Textbox(label="Progress")
|
| 135 |
setup_btn = gr.Button("Initialize vectorstore")
|
| 136 |
setup_btn.click(fn=vector_store, inputs=[path], outputs=[vectorstore, done])
|
|
|
|
| 1 |
+
# import bs4
|
|
|
|
|
|
|
| 2 |
from langchain_community.document_loaders import WebBaseLoader
|
|
|
|
| 3 |
from langchain_core.runnables import RunnablePassthrough
|
| 4 |
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
| 5 |
from langchain.embeddings import HuggingFaceEmbeddings
|
|
|
|
| 122 |
with gr.Blocks() as demo:
|
| 123 |
vectorstore = gr.State()
|
| 124 |
with gr.Tab("Setup"):
|
| 125 |
+
radio = gr.Radio(["website", "PDF"], label="Select type of source", interactive=True)
|
| 126 |
+
path = gr.Textbox(interactive=True, label="Path of source", visible=False)
|
| 127 |
with gr.Row():
|
| 128 |
source1 = gr.Textbox(label="Input website",)
|
| 129 |
+
source2 = gr.Files(label="Upload a PDF file", file_count="single", file_types=["pdf"])
|
|
|
|
|
|
|
| 130 |
radio.change(fn=source, inputs=[radio,source1,source2], outputs=path)
|
| 131 |
+
source1.change(fn=source, inputs=[radio,source1,source2], outputs=path)
|
| 132 |
+
source2.change(fn=source, inputs=[radio,source1,source2], outputs=path)
|
| 133 |
done = gr.Textbox(label="Progress")
|
| 134 |
setup_btn = gr.Button("Initialize vectorstore")
|
| 135 |
setup_btn.click(fn=vector_store, inputs=[path], outputs=[vectorstore, done])
|