Spaces:
Runtime error
Runtime error
Commit ·
aa1bbfb
1
Parent(s): 7429bf2
second
Browse files
app.py
CHANGED
|
@@ -12,10 +12,6 @@ from langchain.prompts import PromptTemplate
|
|
| 12 |
|
| 13 |
import streamlit as st
|
| 14 |
|
| 15 |
-
|
| 16 |
-
#def ingest(file_path,embeddings,vectordb,persist_directory):
|
| 17 |
-
|
| 18 |
-
|
| 19 |
def retrieve(query,llm,retriever):
|
| 20 |
|
| 21 |
template = """
|
|
@@ -42,10 +38,6 @@ def main():
|
|
| 42 |
# Main title of the application
|
| 43 |
st.title("Q&A BOT")
|
| 44 |
|
| 45 |
-
persist_directory = "./myVectorDB"
|
| 46 |
-
print('persist dict: ')
|
| 47 |
-
print(persist_directory)
|
| 48 |
-
|
| 49 |
if 'counter' not in st.session_state:
|
| 50 |
st.session_state['counter'] = 0
|
| 51 |
|
|
@@ -69,19 +61,19 @@ def main():
|
|
| 69 |
uploaded_file = st.file_uploader("Upload a file to ingest", type=["txt"])
|
| 70 |
|
| 71 |
if uploaded_file is not None:
|
| 72 |
-
file_path = uploaded_file.name
|
| 73 |
|
|
|
|
|
|
|
| 74 |
print(file_path)
|
| 75 |
|
|
|
|
|
|
|
| 76 |
file_contents = uploaded_file.read()
|
| 77 |
save_path = uploaded_file.name
|
| 78 |
with open(save_path, "wb") as f:
|
| 79 |
f.write(file_contents)
|
| 80 |
print(save_path)
|
| 81 |
|
| 82 |
-
|
| 83 |
-
#ingest(file_path,embeddings,vectordb,persist_directory)
|
| 84 |
-
|
| 85 |
loader = TextLoader(save_path,autodetect_encoding=True)
|
| 86 |
documents = loader.load()
|
| 87 |
text_splitter = CharacterTextSplitter(chunk_size=1000) #Splitting the text and creating chunks
|
|
@@ -111,9 +103,7 @@ def main():
|
|
| 111 |
|
| 112 |
elif (not api_key):
|
| 113 |
st.info("Please add configuration details in left panel")
|
| 114 |
-
st.stop()
|
| 115 |
-
|
| 116 |
-
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
| 119 |
main()
|
|
|
|
| 12 |
|
| 13 |
import streamlit as st
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
def retrieve(query,llm,retriever):
|
| 16 |
|
| 17 |
template = """
|
|
|
|
| 38 |
# Main title of the application
|
| 39 |
st.title("Q&A BOT")
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
if 'counter' not in st.session_state:
|
| 42 |
st.session_state['counter'] = 0
|
| 43 |
|
|
|
|
| 61 |
uploaded_file = st.file_uploader("Upload a file to ingest", type=["txt"])
|
| 62 |
|
| 63 |
if uploaded_file is not None:
|
|
|
|
| 64 |
|
| 65 |
+
|
| 66 |
+
file_path = uploaded_file.name
|
| 67 |
print(file_path)
|
| 68 |
|
| 69 |
+
# this is a necessary step to read the file content and save it
|
| 70 |
+
# in the webservers location
|
| 71 |
file_contents = uploaded_file.read()
|
| 72 |
save_path = uploaded_file.name
|
| 73 |
with open(save_path, "wb") as f:
|
| 74 |
f.write(file_contents)
|
| 75 |
print(save_path)
|
| 76 |
|
|
|
|
|
|
|
|
|
|
| 77 |
loader = TextLoader(save_path,autodetect_encoding=True)
|
| 78 |
documents = loader.load()
|
| 79 |
text_splitter = CharacterTextSplitter(chunk_size=1000) #Splitting the text and creating chunks
|
|
|
|
| 103 |
|
| 104 |
elif (not api_key):
|
| 105 |
st.info("Please add configuration details in left panel")
|
| 106 |
+
st.stop()
|
|
|
|
|
|
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
main()
|