Spaces:
Runtime error
Runtime error
Salvatore Rossitto
commited on
Commit
·
00636a0
1
Parent(s):
b7a9171
some minor ui fix
Browse files- RBotReloaded.py +6 -13
- agent_llama_ui.py +8 -0
RBotReloaded.py
CHANGED
@@ -175,14 +175,11 @@ class StorageRetrievalLLM:
|
|
175 |
|
176 |
# Load file
|
177 |
file_path = doc if os.path.exists(doc) else os.path.join("data", doc)
|
|
|
178 |
# loader = DirectoryLoader(file_path, glob="**/*.pdf", loader_cls=PyMuPDFLoader)
|
179 |
-
# documents = loader.load()
|
180 |
-
loader =
|
181 |
-
documents = loader.
|
182 |
-
|
183 |
-
# Split and add
|
184 |
-
splitter = RecursiveCharacterTextSplitter()
|
185 |
-
documents = splitter.split_documents(documents)
|
186 |
self.vectorstore.add_documents(documents)
|
187 |
|
188 |
# Update chain
|
@@ -198,12 +195,8 @@ class StorageRetrievalLLM:
|
|
198 |
def addTextFileToMemory(self, file_path : str, summarize = True):
|
199 |
|
200 |
# Load file
|
201 |
-
loader =
|
202 |
-
documents = loader.
|
203 |
-
|
204 |
-
# Split and add
|
205 |
-
splitter = RecursiveCharacterTextSplitter()
|
206 |
-
documents = splitter.split_documents(documents)
|
207 |
self.vectorstore.add_documents(documents)
|
208 |
|
209 |
# Update chain
|
|
|
175 |
|
176 |
# Load file
|
177 |
file_path = doc if os.path.exists(doc) else os.path.join("data", doc)
|
178 |
+
self.stored_pages_folder
|
179 |
# loader = DirectoryLoader(file_path, glob="**/*.pdf", loader_cls=PyMuPDFLoader)
|
180 |
+
# documents = loader.load()
|
181 |
+
loader = PyPDFLoader(file_path)
|
182 |
+
documents = loader.load_and_split()
|
|
|
|
|
|
|
|
|
183 |
self.vectorstore.add_documents(documents)
|
184 |
|
185 |
# Update chain
|
|
|
195 |
def addTextFileToMemory(self, file_path : str, summarize = True):
|
196 |
|
197 |
# Load file
|
198 |
+
loader = PyPDFLoader(file_path)
|
199 |
+
documents = loader.load_and_split()
|
|
|
|
|
|
|
|
|
200 |
self.vectorstore.add_documents(documents)
|
201 |
|
202 |
# Update chain
|
agent_llama_ui.py
CHANGED
@@ -185,6 +185,14 @@ def render_simple_chat():
|
|
185 |
|
186 |
uploaded_file = st.sidebar.file_uploader("Drag and Drop a File to ./knowledge_base/", type=["txt", "pdf", "docx"])
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
if st.sidebar.button("Reset Long Term Memory", disabled=not (current_agent() is not None and get_index_size() > 0)) and current_agent() is not None:
|
189 |
current_agent().reset_knowledge()
|
190 |
|
|
|
185 |
|
186 |
uploaded_file = st.sidebar.file_uploader("Drag and Drop a File to ./knowledge_base/", type=["txt", "pdf", "docx"])
|
187 |
|
188 |
+
knowledge_files = glob.glob(f"./knowledge_base/*.*")
|
189 |
+
st.sidebar.subheader("Knowledge Files")
|
190 |
+
for file_path in knowledge_files:
|
191 |
+
if not "index." in file_path.lower():
|
192 |
+
file_path = file_path.replace("\\", "/")
|
193 |
+
file_name = file_path.split("/")[-1]
|
194 |
+
st.sidebar.markdown(f"[{file_name}](/{file_path})", unsafe_allow_html=True)
|
195 |
+
|
196 |
if st.sidebar.button("Reset Long Term Memory", disabled=not (current_agent() is not None and get_index_size() > 0)) and current_agent() is not None:
|
197 |
current_agent().reset_knowledge()
|
198 |
|