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 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 ollama
import yaml import yaml
import logging.config import logging.config
import agno.utils.log # type: ignore
from typing import Any
from pydantic import BaseModel from pydantic import BaseModel
from agno.agent import Agent from agno.agent import Agent
from agno.tools import Toolkit from agno.tools import Toolkit
@@ -86,6 +88,8 @@ class AppConfig(BaseModel):
models: ModelsConfig = ModelsConfig() models: ModelsConfig = ModelsConfig()
agents: AgentsConfigs = AgentsConfigs() agents: AgentsConfigs = AgentsConfigs()
__lock = threading.Lock()
@classmethod @classmethod
def load(cls, file_path: str = "configs.yaml") -> 'AppConfig': def load(cls, file_path: str = "configs.yaml") -> 'AppConfig':
""" """
@@ -106,9 +110,10 @@ class AppConfig(BaseModel):
return configs return configs
def __new__(cls, *args: Any, **kwargs: Any) -> 'AppConfig': def __new__(cls, *args: Any, **kwargs: Any) -> 'AppConfig':
if not hasattr(cls, 'instance'): with cls.__lock:
cls.instance = super(AppConfig, cls).__new__(cls) if not hasattr(cls, 'instance'):
return cls.instance cls.instance = super(AppConfig, cls).__new__(cls)
return cls.instance
def get_model_by_name(self, name: str) -> AppModel: def get_model_by_name(self, name: str) -> AppModel:
""" """
@@ -146,7 +151,7 @@ class AppConfig(BaseModel):
""" """
logging.config.dictConfig({ logging.config.dictConfig({
'version': 1, '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': { 'formatters': {
'colored': { 'colored': {
'()': 'colorlog.ColoredFormatter', '()': 'colorlog.ColoredFormatter',
@@ -160,17 +165,16 @@ class AppConfig(BaseModel):
'level': self.logging_level, 'level': self.logging_level,
}, },
}, },
'root': { # Configura il logger root 'root': { # Configure the root logger
'handlers': ['console'], 'handlers': ['console'],
'level': self.logging_level, 'level': self.logging_level,
}, },
'loggers': { 'loggers': {
'httpx': {'level': 'WARNING'}, # Troppo spam per INFO 'httpx': {'level': 'WARNING'}, # Too much spam for INFO
} }
}) })
# Modifichiamo i logger di agno # Modify the agno loggers
import agno.utils.log # type: ignore
agno_logger_names = ["agno", "agno-team", "agno-workflow"] agno_logger_names = ["agno", "agno-team", "agno-workflow"]
for logger_name in agno_logger_names: for logger_name in agno_logger_names:
logger = logging.getLogger(logger_name) logger = logging.getLogger(logger_name)