Configurazioni dell'app #27

Merged
Berack96 merged 16 commits from configs into main 2025-10-12 18:05:43 +02:00
Showing only changes of commit a69afbb052 - Show all commits

View File

@@ -1,8 +1,10 @@
import os
copilot-pull-request-reviewer[bot] commented 2025-10-12 17:56:25 +02:00 (Migrated from github.com)
Review

This singleton implementation is not thread-safe and can cause issues in concurrent environments. Consider using a proper singleton pattern with locks or removing the singleton behavior if it's not strictly necessary.

This singleton implementation is not thread-safe and can cause issues in concurrent environments. Consider using a proper singleton pattern with locks or removing the singleton behavior if it's not strictly necessary.
copilot-pull-request-reviewer[bot] commented 2025-10-12 17:56:25 +02:00 (Migrated from github.com)
Review

Import statements should be placed at the top of the file, not within method bodies. Move this import to the top-level imports section.

Import statements should be placed at the top of the file, not within method bodies. Move this import to the top-level imports section.
copilot-pull-request-reviewer[bot] commented 2025-10-12 17:56:25 +02:00 (Migrated from github.com)
Review

Comment should be in English to maintain consistency with code comments throughout the project.

            'disable_existing_loggers': False, # Keeps existing loggers (e.g., third-party loggers)
Comment should be in English to maintain consistency with code comments throughout the project. ```suggestion 'disable_existing_loggers': False, # Keeps existing loggers (e.g., third-party loggers) ```
copilot-pull-request-reviewer[bot] commented 2025-10-12 17:56:25 +02:00 (Migrated from github.com)
Review

Comment should be in English to maintain consistency with code comments throughout the project.

                'httpx': {'level': 'WARNING'}, # Too much spam for INFO
Comment should be in English to maintain consistency with code comments throughout the project. ```suggestion 'httpx': {'level': 'WARNING'}, # Too much spam for INFO ```
from typing import Any
import threading
import ollama
import yaml
import logging.config
import agno.utils.log # type: ignore
from typing import Any
from pydantic import BaseModel
from agno.agent import Agent
from agno.tools import Toolkit
@@ -86,6 +88,8 @@ class AppConfig(BaseModel):
models: ModelsConfig = ModelsConfig()
agents: AgentsConfigs = AgentsConfigs()
__lock = threading.Lock()
@classmethod
def load(cls, file_path: str = "configs.yaml") -> 'AppConfig':
"""
@@ -106,6 +110,7 @@ class AppConfig(BaseModel):
return configs
def __new__(cls, *args: Any, **kwargs: Any) -> 'AppConfig':
with cls.__lock:
if not hasattr(cls, 'instance'):
cls.instance = super(AppConfig, cls).__new__(cls)
return cls.instance
@@ -146,7 +151,7 @@ class AppConfig(BaseModel):
"""
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False, # Mantiene i logger esistenti (es. di terze parti)
'disable_existing_loggers': False, # Keep existing loggers (e.g. third-party loggers)
'formatters': {
'colored': {
'()': 'colorlog.ColoredFormatter',
@@ -160,17 +165,16 @@ class AppConfig(BaseModel):
'level': self.logging_level,
},
},
'root': { # Configura il logger root
'root': { # Configure the root logger
'handlers': ['console'],
'level': self.logging_level,
},
'loggers': {
'httpx': {'level': 'WARNING'}, # Troppo spam per INFO
'httpx': {'level': 'WARNING'}, # Too much spam for INFO
}
})
# Modifichiamo i logger di agno
import agno.utils.log # type: ignore
# Modify the agno loggers
agno_logger_names = ["agno", "agno-team", "agno-workflow"]
for logger_name in agno_logger_names:
logger = logging.getLogger(logger_name)