elly99 commited on
Commit
12361d5
·
verified ·
1 Parent(s): e8deaa1

Create utils/setup.py

Browse files
Files changed (1) hide show
  1. src/utils/setup.py +26 -0
src/utils/setup.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Setting up logging to monitor system behavior
2
+ '''Sets the format and logging level to track events, errors, and important operations'''
3
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
4
+
5
+ # Decorator for error handling
6
+ # This function catches any exceptions raised by other functions
7
+
8
+ def gestisci_errori(func):
9
+ def wrapper(*args, **kwargs):
10
+ try:
11
+ return func(*args, **kwargs)
12
+ except Exception as e:
13
+ logging.error(f"Error in {func.__name__}: {e}")
14
+ return None
15
+ return wrapper
16
+
17
+
18
+
19
+ # Carica le variabili d'ambiente dal file .env
20
+ load_dotenv()
21
+
22
+ # Recupera la chiave API in modo sicuro
23
+ api_key = os.getenv("GROQ_API_KEY")
24
+
25
+ # Inizializza il modello Groq
26
+ llm = ChatGroq