Transformers
Italian
English
semantic-search
explainable-ai
faiss
ai-ethics
responsible-ai
llm
prompt-engineering
multimodal-ai
ai-transparency
ethical-intelligence
explainable-llm
cognitive-ai
ethical-ai
scientific-retrieval
modular-ai
memory-augmented-llm
trustworthy-ai
reasoning-engine
ai-alignment
next-gen-llm
thinking-machines
open-source-ai
explainability
ai-research
semantic audit
cognitive agent
human-centered-ai
Create utils/setup.py
Browse files- 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
|