Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,8 +24,14 @@ st.subheader("Upload a text file and ask questions. The app will maintain a conv
|
|
24 |
uploaded_file = st.file_uploader("Upload a text file", type=["txt"])
|
25 |
|
26 |
if uploaded_file:
|
27 |
-
#
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
document = text_loader.load()
|
30 |
|
31 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
|
|
|
24 |
uploaded_file = st.file_uploader("Upload a text file", type=["txt"])
|
25 |
|
26 |
if uploaded_file:
|
27 |
+
# Read the file content
|
28 |
+
file_content = uploaded_file.read().decode("utf-8")
|
29 |
+
|
30 |
+
# Convert the file content into a format compatible with LangChain
|
31 |
+
from langchain_community.document_loaders import TextLoader
|
32 |
+
from io import StringIO
|
33 |
+
|
34 |
+
text_loader = TextLoader(StringIO(file_content))
|
35 |
document = text_loader.load()
|
36 |
|
37 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
|