farmax commited on
Commit
e413310
·
verified ·
1 Parent(s): 127553d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -17
app.py CHANGED
@@ -206,33 +206,27 @@ def create_collection_name(filepath):
206
  print('Collection name: ', collection_name)
207
  return collection_name
208
 
209
- # Inizializzazione database
210
  def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Progress()):
211
- # Check if a database already exists
212
- try:
213
- # Delete the existing database
214
- chromadb.delete()
215
- print("Existing database deleted successfully.")
216
- except Exception as e:
217
- print(f"Error deleting existing database: {str(e)}")
218
-
219
  # Create list of documents (when valid)
220
  list_file_path = [x.name for x in list_file_obj if x is not None]
221
-
222
  # Create collection_name for vector database
223
- progress(0.1, desc="Creazione collection name...")
224
  collection_name = create_collection_name(list_file_path[0])
225
- progress(0.25, desc="Caricamento documenti..")
226
-
227
  # Load document and create splits
228
  doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
229
-
230
  # Create or load vector database
231
- progress(0.5, desc="Generating vector database...")
 
232
  vector_db = create_db(doc_splits, collection_name)
233
- progress(0.9, desc="Fatto!")
234
  return vector_db, collection_name, "Completato!"
235
 
 
236
  def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db, progress=gr.Progress()):
237
  # print("llm_option",llm_option)
238
  llm_name = list_llm[llm_option]
@@ -326,7 +320,7 @@ def demo():
326
  label="LLM models", value = list_llm_simple[0], type="index", info="Scegli il tuo modello LLM")
327
  with gr.Accordion("Advanced options - LLM model", open=False):
328
  with gr.Row():
329
- slider_temperature = gr.Slider(minimum = 0.01, maximum = 1.0, value=0.7, step=0.1, label="Temperature", info="Model temperature", interactive=True)
330
  with gr.Row():
331
  slider_maxtokens = gr.Slider(minimum = 224, maximum = 4096, value=1024, step=32, label="Max Tokens", info="Model max tokens", interactive=True)
332
  with gr.Row():
 
206
  print('Collection name: ', collection_name)
207
  return collection_name
208
 
209
+ # Initialize database
210
  def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Progress()):
211
+ # Delete the existing database
212
+ chromadb.delete()
213
+ print("Existing database deleted successfully.")
 
 
 
 
 
214
  # Create list of documents (when valid)
215
  list_file_path = [x.name for x in list_file_obj if x is not None]
 
216
  # Create collection_name for vector database
217
+ progress(0.1, desc="Creating collection name...")
218
  collection_name = create_collection_name(list_file_path[0])
219
+ progress(0.25, desc="Loading document...")
 
220
  # Load document and create splits
221
  doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
 
222
  # Create or load vector database
223
+ progress(0.5, desc="Generazione vector database...")
224
+ # global vector_db
225
  vector_db = create_db(doc_splits, collection_name)
226
+ progress(0.9, desc="Done!")
227
  return vector_db, collection_name, "Completato!"
228
 
229
+
230
  def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db, progress=gr.Progress()):
231
  # print("llm_option",llm_option)
232
  llm_name = list_llm[llm_option]
 
320
  label="LLM models", value = list_llm_simple[0], type="index", info="Scegli il tuo modello LLM")
321
  with gr.Accordion("Advanced options - LLM model", open=False):
322
  with gr.Row():
323
+ slider_temperature = gr.Slider(minimum = 0.01, maximum = 1.0, value=0.3, step=0.1, label="Temperature", info="Model temperature", interactive=True)
324
  with gr.Row():
325
  slider_maxtokens = gr.Slider(minimum = 224, maximum = 4096, value=1024, step=32, label="Max Tokens", info="Model max tokens", interactive=True)
326
  with gr.Row():