Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -96,22 +96,25 @@ def initialize_llmchain(llm_model, temperature, max_tokens, top_k, vector_db, pr
|
|
96 |
|
97 |
# Initialize database
|
98 |
def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Progress()):
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
115 |
|
116 |
|
117 |
def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db, progress=gr.Progress()):
|
|
|
96 |
|
97 |
# Initialize database
|
98 |
def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Progress()):
|
99 |
+
CreaDB = False
|
100 |
+
if CreaDB:
|
101 |
+
list_file_path = [x.name for x in list_file_obj if x is not None]
|
102 |
+
collection_name = Path(list_file_path[0]).stem
|
103 |
+
print('list_file_path: ', list_file_path)
|
104 |
+
print('Collection name: ', collection_name)
|
105 |
+
progress(0.25, desc="Loading document...")
|
106 |
+
# Load document and create splits
|
107 |
+
doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
|
108 |
+
# Create or load Vector database
|
109 |
+
progress(0.5, desc="Generating vector database...")
|
110 |
+
# global vector_db
|
111 |
+
vector_db = create_db(doc_splits, collection_name)
|
112 |
+
progress(0.9, desc="Done!")
|
113 |
+
return vector_db, collection_name, "Complete!"
|
114 |
+
else:
|
115 |
+
collection_name = 'Documenti'
|
116 |
+
vector_db = load_db()
|
117 |
+
return vector_db, collection_name, "Complete!"
|
118 |
|
119 |
|
120 |
def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db, progress=gr.Progress()):
|