themanas021 commited on
Commit
71fe4db
·
verified ·
1 Parent(s): 6d257d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
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
- # Load and split the text file
28
- text_loader = TextLoader(uploaded_file)
 
 
 
 
 
 
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)