jyotiguptahk commited on
Commit
64e59d0
·
1 Parent(s): 4296b37
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -70,15 +70,24 @@ def main():
70
 
71
  if uploaded_file is not None:
72
  file_path = uploaded_file.name
 
73
  print(file_path)
 
 
 
 
 
 
 
 
74
  #ingest(file_path,embeddings,vectordb,persist_directory)
75
 
76
- loader = TextLoader(file_path,autodetect_encoding=True)
77
  documents = loader.load()
78
  text_splitter = CharacterTextSplitter(chunk_size=1000) #Splitting the text and creating chunks
79
  docs = text_splitter.split_documents(documents)
80
 
81
- persist_directory = file_path[:-4]
82
  vectordb = Chroma.from_documents(documents=docs,
83
  embedding=embeddings,
84
  persist_directory=persist_directory)
 
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
88
  docs = text_splitter.split_documents(documents)
89
 
90
+ persist_directory = save_path[:-4]
91
  vectordb = Chroma.from_documents(documents=docs,
92
  embedding=embeddings,
93
  persist_directory=persist_directory)