Spaces:
Sleeping
Sleeping
File size: 1,866 Bytes
b2638ec 47e4aa2 352ebdd b2638ec ac52d7a 47e4aa2 ac52d7a 352ebdd 47e4aa2 352ebdd b2638ec 352ebdd 47e4aa2 ac52d7a b2638ec 47e4aa2 352ebdd b2638ec ac52d7a b2638ec ac52d7a b2638ec ac52d7a b2638ec ac52d7a 47e4aa2 352ebdd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# app.py
import gradio as gr
import logging
from watchdog.observers import Observer
from app.logging_config import configure_logging
from app.functions.database_handling import list_databases, setup_db_observer
from ui.chatbot_tab import create_chatbot_tab
from ui.db_management_tab import create_db_management_tab
from ui.document_management_tab import create_document_management_tab
from ui.new_features_tab import create_new_features_tab
# Configura il logging
configure_logging()
def update_all_dropdowns():
"""
Aggiorna tutti i dropdown in tutte le tab.
"""
databases = list_databases()
logging.info(f"Aggiornamento dropdown con databases: {databases}")
return [gr.update(choices=databases, value=databases[0] if databases else None) for _ in range(6)]
def main():
"""Funzione principale che crea e lancia l'app Gradio."""
logging.info("Avvio applicazione")
try:
with gr.Blocks() as rag_chatbot:
# Configura l'observer per la cartella db
observer = setup_db_observer(update_all_dropdowns)
gr.Markdown("# Chatbot basato su RAG")
logging.info("Interfaccia Gradio inizializzata")
# Crea i vari tab dell'interfaccia
create_chatbot_tab()
create_db_management_tab(update_all_dropdowns)
create_document_management_tab(update_all_dropdowns)
create_new_features_tab()
logging.info("Tab dell'interfaccia creati con successo")
# Avvia l'app
rag_chatbot.launch()
except Exception as e:
logging.error(f"Errore durante l'avvio: {str(e)}")
finally:
# Assicurati che l'observer venga fermato
if 'observer' in locals():
observer.stop()
observer.join()
if __name__ == "__main__":
main()
|