Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from utils import update_db_hub
|
3 |
-
from preprocessing import read_file
|
4 |
import datetime
|
5 |
|
6 |
def process_file(files, topic):
|
@@ -52,10 +52,12 @@ def process_file(files, topic):
|
|
52 |
# Read the file content
|
53 |
file_path = file.name
|
54 |
text = read_file(file_path)
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
59 |
# Spl
|
60 |
# Save chunks to database
|
61 |
|
@@ -66,7 +68,7 @@ def process_file(files, topic):
|
|
66 |
|
67 |
print("save in db")
|
68 |
update_db_hub(texts, topics, dates)
|
69 |
-
print('saved')
|
70 |
# progress(1.0, desc="Processing complete!")
|
71 |
return "\n".join(log_history)
|
72 |
|
|
|
1 |
import gradio as gr
|
2 |
from utils import update_db_hub
|
3 |
+
from preprocessing import read_file, smart_chunking
|
4 |
import datetime
|
5 |
|
6 |
def process_file(files, topic):
|
|
|
52 |
# Read the file content
|
53 |
file_path = file.name
|
54 |
text = read_file(file_path)
|
55 |
+
chucnks = smart_chunking(text)
|
56 |
+
# print(f"for file {file_path}", text[:1000])
|
57 |
+
for chunk in chucnks:
|
58 |
+
texts.append(text)
|
59 |
+
topics.append(topic)
|
60 |
+
dates.append(datetime.datetime.now().isoformat())
|
61 |
# Spl
|
62 |
# Save chunks to database
|
63 |
|
|
|
68 |
|
69 |
print("save in db")
|
70 |
update_db_hub(texts, topics, dates)
|
71 |
+
# print('saved')
|
72 |
# progress(1.0, desc="Processing complete!")
|
73 |
return "\n".join(log_history)
|
74 |
|