Spaces:
Runtime error
Runtime error
Commit
·
ca0a8d3
1
Parent(s):
7da2edb
update summary
Browse files
app.py
CHANGED
@@ -330,6 +330,23 @@ def process_documents_2(ignored_files: List[str] = []) -> List[Document]:
|
|
330 |
print(f"Split into {len(texts)} chunks of text (max. {chunk_size} tokens each)")
|
331 |
return texts
|
332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
def UpdateDb():
|
334 |
global vectordb_p
|
335 |
global index_name
|
@@ -352,7 +369,7 @@ def SummarizeDoc():
|
|
352 |
# collection = vectordb_p.get()
|
353 |
# split_docs = process_documents([metadata['source'] for metadata in collection['metadatas']])
|
354 |
# split_docs = process_documents()
|
355 |
-
split_docs =
|
356 |
tt = len(split_docs)
|
357 |
print(split_docs[tt-1])
|
358 |
sum_text=""
|
@@ -1351,7 +1368,7 @@ with gr.Blocks() as demo:
|
|
1351 |
"""
|
1352 |
|
1353 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
1354 |
-
|
1355 |
retry_button.click(retry, chatbot, chatbot).success(playsound1, None, voice_output).\
|
1356 |
success(HMI_Wait, None, [submit_button, stop_button])#.\
|
1357 |
# success(ClearAudio, None, voice_output)
|
@@ -1383,7 +1400,7 @@ with gr.Blocks() as demo:
|
|
1383 |
then(HMI_Wait, None, [submit_button, stop_button])
|
1384 |
# stop_button.click(read_logs, None, logs, cancels=[inf2])
|
1385 |
upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
|
1386 |
-
summary_file_button.upload(Summary_upload_file, [summary_file_button, chatbot], chatbot)
|
1387 |
agentchoice.change(SetAgent, agentchoice, None)
|
1388 |
frash_logs.click(read_logs, None, logs)
|
1389 |
voice_input.stop_recording(SingleTalk, [voice_input, chatbot], [voice_input, voice_output, chatbot]).\
|
@@ -1391,6 +1408,7 @@ with gr.Blocks() as demo:
|
|
1391 |
success(playsound1, None, voice_output) #.\
|
1392 |
# success(HMI_Wait, None, [submit_button, stop_button]).\
|
1393 |
# success(ClearAudio, None, voice_output)
|
|
|
1394 |
# voice_output.end(ClearAudio, None, voice_output)
|
1395 |
# def clear_voice():
|
1396 |
# print("clear audio ...")
|
|
|
330 |
print(f"Split into {len(texts)} chunks of text (max. {chunk_size} tokens each)")
|
331 |
return texts
|
332 |
|
333 |
+
def process_documents_3(ignored_files: List[str] = []) -> List[Document]:
|
334 |
+
"""
|
335 |
+
Load documents and split in chunks
|
336 |
+
"""
|
337 |
+
global file_list_loaded
|
338 |
+
print(f"Loading documents from {source_directory}")
|
339 |
+
print("File Path to start processing:", file_list_loaded)
|
340 |
+
documents = load_documents_2(file_list_loaded, ignored_files)
|
341 |
+
if not documents:
|
342 |
+
print("No new documents to load")
|
343 |
+
exit(0)
|
344 |
+
print(f"Loaded {len(documents)} new documents from {source_directory}")
|
345 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=2000, chunk_overlap=500)
|
346 |
+
texts = text_splitter.split_documents(documents)
|
347 |
+
print(f"Split into {len(texts)} chunks of text (max. {chunk_size} tokens each)")
|
348 |
+
return texts
|
349 |
+
|
350 |
def UpdateDb():
|
351 |
global vectordb_p
|
352 |
global index_name
|
|
|
369 |
# collection = vectordb_p.get()
|
370 |
# split_docs = process_documents([metadata['source'] for metadata in collection['metadatas']])
|
371 |
# split_docs = process_documents()
|
372 |
+
split_docs = process_documents_3()
|
373 |
tt = len(split_docs)
|
374 |
print(split_docs[tt-1])
|
375 |
sum_text=""
|
|
|
1368 |
"""
|
1369 |
|
1370 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
1371 |
+
|
1372 |
retry_button.click(retry, chatbot, chatbot).success(playsound1, None, voice_output).\
|
1373 |
success(HMI_Wait, None, [submit_button, stop_button])#.\
|
1374 |
# success(ClearAudio, None, voice_output)
|
|
|
1400 |
then(HMI_Wait, None, [submit_button, stop_button])
|
1401 |
# stop_button.click(read_logs, None, logs, cancels=[inf2])
|
1402 |
upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
|
1403 |
+
sum1 = summary_file_button.upload(Summary_upload_file, [summary_file_button, chatbot], chatbot)
|
1404 |
agentchoice.change(SetAgent, agentchoice, None)
|
1405 |
frash_logs.click(read_logs, None, logs)
|
1406 |
voice_input.stop_recording(SingleTalk, [voice_input, chatbot], [voice_input, voice_output, chatbot]).\
|
|
|
1408 |
success(playsound1, None, voice_output) #.\
|
1409 |
# success(HMI_Wait, None, [submit_button, stop_button]).\
|
1410 |
# success(ClearAudio, None, voice_output)
|
1411 |
+
clear_button.click(clearall, None, [chatbot, submit_button, stop_button], voice_output, cancels=[inf4,inf3,sum1])
|
1412 |
# voice_output.end(ClearAudio, None, voice_output)
|
1413 |
# def clear_voice():
|
1414 |
# print("clear audio ...")
|