From f2d099f54750e320a2a9e3821e575542f999ac84 Mon Sep 17 00:00:00 2001 From: Berack96 Date: Sun, 12 Oct 2025 17:08:46 +0200 Subject: [PATCH] pattern singleton per AppConfig. --- configs.yaml | 4 ++++ src/app/configs.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/configs.yaml b/configs.yaml index 7dd259d..e2f444d 100644 --- a/configs.yaml +++ b/configs.yaml @@ -33,6 +33,10 @@ api: retry_attempts: 3 retry_delay_seconds: 2 currency: EUR + # TODO Magari implementare un sistema per settare i providers + market_providers: [BinanceWrapper, YFinanceWrapper] + news_providers: [GoogleNewsWrapper, DuckDuckGoWrapper] + social_providers: [RedditWrapper] agents: strategy: Conservative diff --git a/src/app/configs.py b/src/app/configs.py index 2687671..09728c1 100644 --- a/src/app/configs.py +++ b/src/app/configs.py @@ -1,4 +1,5 @@ import os +from typing import Any import ollama import yaml import logging.config @@ -104,6 +105,11 @@ class AppConfig(BaseModel): log.info(f"Loaded configuration from {file_path}") return configs + def __new__(cls, *args: Any, **kwargs: Any) -> 'AppConfig': + if not hasattr(cls, 'instance'): + cls.instance = super(AppConfig, cls).__new__(cls) + return cls.instance + def get_model_by_name(self, name: str) -> AppModel: """ Retrieve a model configuration by its name.