File size: 764 Bytes
12361d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Setting up logging to monitor system behavior
'''Sets the format and logging level to track events, errors, and important operations'''
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")

# Decorator for error handling
# This function catches any exceptions raised by other functions

def gestisci_errori(func):
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            logging.error(f"Error in {func.__name__}: {e}")
            return None
    return wrapper



# Carica le variabili d'ambiente dal file .env
load_dotenv()

# Recupera la chiave API in modo sicuro
api_key = os.getenv("GROQ_API_KEY")

# Inizializza il modello Groq
llm = ChatGroq