llamazookeeper commited on
Commit
7afc766
1 Parent(s): f9bb6b3
Files changed (1) hide show
  1. pages/Tesla_Alerts.py +18 -18
pages/Tesla_Alerts.py CHANGED
@@ -109,29 +109,29 @@ if OPENAI_API_KEY:
109
  if st.sidebar.button("Process Document"):
110
  with st.spinner("Processing Document..."):
111
 
112
- data_dir = "./data"
113
- if not os.path.exists(data_dir):
114
- os.makedirs(data_dir)
115
 
116
- for file in files_uploaded:
117
- print(f'file named {file.name}')
118
- fname=f'{data_dir}/{file.name}'
119
- with open(fname, 'wb') as f:
120
- f.write(file.read())
121
 
122
- def fmetadata(dummy: str): return {"file_path": ""}
123
 
124
- PptxReader = download_loader("PptxReader")
125
- loader = SimpleDirectoryReader(input_dir=data_dir, file_extractor={".pptx": PptxReader(),}, file_metadata=fmetadata)
126
 
127
- documents = loader.load_data()
128
- for doc in documents:
129
- doc.metadata["file_path"]=""
130
 
131
- st.session_state.index = get_vector_index(documents, vector_store="faiss")
132
- #st.session_state.index = get_vector_index(documents, vector_store="simple")
133
- st.session_state.process_doc = True
134
- st.toast("Document Processsed!")
135
 
136
  #st.session_state.process_doc = True
137
 
 
109
  if st.sidebar.button("Process Document"):
110
  with st.spinner("Processing Document..."):
111
 
112
+ data_dir = "./data"
113
+ if not os.path.exists(data_dir):
114
+ os.makedirs(data_dir)
115
 
116
+ for file in files_uploaded:
117
+ print(f'file named {file.name}')
118
+ fname=f'{data_dir}/{file.name}'
119
+ with open(fname, 'wb') as f:
120
+ f.write(file.read())
121
 
122
+ def fmetadata(dummy: str): return {"file_path": ""}
123
 
124
+ PptxReader = download_loader("PptxReader")
125
+ loader = SimpleDirectoryReader(input_dir=data_dir, file_extractor={".pptx": PptxReader(),}, file_metadata=fmetadata)
126
 
127
+ documents = loader.load_data()
128
+ for doc in documents:
129
+ doc.metadata["file_path"]=""
130
 
131
+ st.session_state.index = get_vector_index(documents, vector_store="faiss")
132
+ #st.session_state.index = get_vector_index(documents, vector_store="simple")
133
+ st.session_state.process_doc = True
134
+ st.toast("Document Processsed!")
135
 
136
  #st.session_state.process_doc = True
137