Spaces:
Build error
Build error
Initial Draft
Browse files- shakesearch.py +12 -17
shakesearch.py
CHANGED
|
@@ -23,25 +23,20 @@ if uploaded_file is not None:
|
|
| 23 |
f.write(uploaded_file.getbuffer())
|
| 24 |
|
| 25 |
# Reload documents and index after file upload
|
| 26 |
-
documents = SimpleDirectoryReader(
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
print(f"- {attr}: {value}")
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
-
# nodes = [{"id": doc.name, "text": doc.text} for doc in documents]
|
| 39 |
-
|
| 40 |
-
# # Creating Index
|
| 41 |
-
# index = VectorStoreIndex(nodes=nodes, document_embeddings=document_embeddings)
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
|
| 46 |
query = st.text_input("Enter your search query:")
|
| 47 |
|
|
|
|
| 23 |
f.write(uploaded_file.getbuffer())
|
| 24 |
|
| 25 |
# Reload documents and index after file upload
|
| 26 |
+
documents = SimpleDirectoryReader(
|
| 27 |
+
input_dir=docs_path,
|
| 28 |
+
filename_as_id=True,
|
| 29 |
+
required_exts=[".txt"]
|
| 30 |
+
).load_data()
|
| 31 |
+
|
| 32 |
+
# Creating embedding
|
| 33 |
+
document_embeddings = [vectorizer(doc.text) for doc in documents]
|
|
|
|
| 34 |
|
| 35 |
+
# Creating Index
|
| 36 |
+
index = VectorStoreIndex(nodes=nodes, document_embeddings=document_embeddings)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
# Sucess message
|
| 39 |
+
st.success("File uploaded & processed successfully!")
|
| 40 |
|
| 41 |
query = st.text_input("Enter your search query:")
|
| 42 |
|