Update app.py
Browse files12345678910111213142 unmodified lines171819102021221323242526272829303132333435361537383940414243444546471920212223242526272829303148495051525393 unmodified lines14714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121266 unmodified lines279280281203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253282283284290 unmodified lines575576577550551552553554555556557558559560561562563564565566567568569570571572573574578579580112 unmodified lines693694695693696import streamlit as st
# UWAGA: st.set_page_config() MUSI być pierwszą komendą Streamlit!st.set_page_config( page_title="QualiInsightLab", page_icon="🎙️", layout="wide", initial_sidebar_state="expanded")
# Teraz importy i reszta koduimport sysimport osfrom datetime import datetime2 unmodified linesimport threadingimport queue
# Sprawdzenie zależności# Sprawdzenie zależności BEZ używania st.success/st.error przed set_page_configtry: import openai st.success("✅ OpenAI library loaded successfully") OPENAI_AVAILABLE = True openai_status = "✅ OpenAI library loaded successfully"except ImportError as e: OPENAI_AVAILABLE = False openai_status = f"❌ OpenAI library missing: {e}"
# Import modułów (bez używania Streamlit commands)try: from transcription import AudioTranscriber from report_generator import ReportGenerator from file_handler import FileHandler from config import NVIDIA_THEME, DEFAULT_SETTINGS modules_loaded = Trueexcept ImportError as e: st.error(f"❌ OpenAI library missing: {e}") modules_loaded = False import_error = str(e)
# Teraz możemy użyć komend Streamlitif OPENAI_AVAILABLE: st.success(openai_status)else: st.error(openai_status) st.info("HuggingFace is installing dependencies... Refresh page in 30 seconds.") st.stop()
# Import modułówfrom transcription import AudioTranscriberfrom report_generator import ReportGeneratorfrom file_handler import FileHandlerfrom config import NVIDIA_THEME, DEFAULT_SETTINGS
# Konfiguracja stronyst.set_page_config( page_title="QualiInsightLab", page_icon="🎙️", layout="wide", initial_sidebar_state="expanded")if not modules_loaded: st.error(f"❌ Błąd importu modułów: {import_error}") st.stop()
# Custom CSS - kolorystyka NVIDIAst.markdown(f"""93 unmodified lines print(f"LOG ERROR: {log_entry}") print(f"LOG ERROR DETAILS: {e}") def update_progress_safe(self, progress_value, status_message): """Thread-safe aktualizacja postępu""" try: st.session_state.overall_progress = progress_value st.session_state.current_file_progress = status_message except: # Fallback - wyświetl w konsoli print(f"PROGRESS: {progress_value:.1%} - {status_message}") def update_transcriptions_safe(self, filename, transcription): """Thread-safe aktualizacja transkrypcji""" try: st.session_state.transcriptions[filename] = transcription except: # Fallback - zapisz do lokalnej zmiennej if not hasattr(self, 'local_transcriptions'): self.local_transcriptions = {} self.local_transcriptions[filename] = transcription print(f"TRANSCRIPTION: {filename} completed locally") def sync_local_data(self): """Synchronizuj dane lokalne z session_state""" try: # Przenies logi lokalne do session_state if hasattr(self, 'local_logs'): for log in self.local_logs: if 'logs' in st.session_state: st.session_state.logs.append(log) self.local_logs = [] # Przenies transkrypcje lokalne do session_state if hasattr(self, 'local_transcriptions'): for filename, transcription in self.local_transcriptions.items(): st.session_state.transcriptions[filename] = transcription self.local_transcriptions = {} # Przenies raport lokalny do session_state if hasattr(self, 'local_final_report'): st.session_state.final_report = self.local_final_report st.session_state.processing_status = 'completed' delattr(self, 'local_final_report') except Exception as e: print(f"SYNC ERROR: {e}") def cleanup_session(self): """Wyczyść sesję i pliki tymczasowe""" # Zatrzymaj przetwarzanie jeśli trwa if st.session_state.processing_status == 'running': st.session_state.processing_status = 'stopped' # Wyczyść pliki tymczasowe self.file_handler.cleanup_temp_files() # Wyczyść session state for key in list(st.session_state.keys()): del st.session_state[key] self.initialize_session_state() def render_sidebar(self): """Renderuj sidebar z konfiguracją""" st.sidebar.title("🎙️ QualiInsightLab")66 unmodified lines 'language': language } def update_progress_safe(self, progress_value, status_message): """Thread-safe aktualizacja postępu""" try: st.session_state.overall_progress = progress_value st.session_state.current_file_progress = status_message except: # Fallback - wyświetl w konsoli print(f"PROGRESS: {progress_value:.1%} - {status_message}") def update_transcriptions_safe(self, filename, transcription): """Thread-safe aktualizacja transkrypcji""" try: st.session_state.transcriptions[filename] = transcription except: # Fallback - zapisz do lokalnej zmiennej if not hasattr(self, 'local_transcriptions'): self.local_transcriptions = {} self.local_transcriptions[filename] = transcription print(f"TRANSCRIPTION: {filename} completed locally") def sync_local_data(self): """Synchronizuj dane lokalne z session_state""" try: # Przenies logi lokalne do session_state if hasattr(self, 'local_logs'): for log in self.local_logs: st.session_state.logs.append(log) self.local_logs = [] # Przenies transkrypcje lokalne do session_state if hasattr(self, 'local_transcriptions'): for filename, transcription in self.local_transcriptions.items(): st.session_state.transcriptions[filename] = transcription self.local_transcriptions = {} except Exception as e: print(f"SYNC ERROR: {e}") """Wyczyść sesję i pliki tymczasowe""" # Zatrzymaj przetwarzanie jeśli trwa if st.session_state.processing_status == 'running': st.session_state.processing_status = 'stopped' # Wyczyść pliki tymczasowe self.file_handler.cleanup_temp_files() # Wyczyść session state for key in list(st.session_state.keys()): del st.session_state[key] self.initialize_session_state() def render_file_upload(self, settings): """Renderuj sekcję upload plików""" st.header("📁 Upload plików audio/video")290 unmodified lines except: print(f"CRITICAL ERROR: {e}") def sync_local_data(self): """Synchronizuj dane lokalne z session_state""" try: # Przenies logi lokalne do session_state if hasattr(self, 'local_logs'): for log in self.local_logs: if 'logs' in st.session_state: st.session_state.logs.append(log) self.local_logs = [] # Przenies transkrypcje lokalne do session_state if hasattr(self, 'local_transcriptions'): for filename, transcription in self.local_transcriptions.items(): st.session_state.transcriptions[filename] = transcription self.local_transcriptions = {} # Przenies raport lokalny do session_state if hasattr(self, 'local_final_report'): st.session_state.final_report = self.local_final_report st.session_state.processing_status = 'completed' delattr(self, 'local_final_report') except Exception as e: print(f"SYNC ERROR: {e}") def render_results(self): """Renderuj wyniki""" if not st.session_state.transcriptions and not st.session_state.final_report:112 unmodified lines # Emergency restart if st.button("🚨 Awaryjny restart"): st.experimental_rerun() st.rerun()app.py+96-93