Refactor market system and improve app configuration

- Refactor market system from singleton function to class-based architecture with MarketAPIs
- Add automatic API key detection for Coinbase and CryptoCompare wrappers
- Improve error handling and logging with agno.utils.log throughout the application
- Split Models class into separate methods for online and local model availability
- Add proper JSON response extraction with thinking pattern support
- Enhance ToolAgent with better state management for provider and style selection
- Update Gradio app with proper server configuration and logging
This commit is contained in:
2025-09-27 17:49:32 +02:00
parent a51ec67ac1
commit 03d8523a5a
8 changed files with 143 additions and 73 deletions

View File

@@ -1,5 +1,5 @@
from agno.tools import Toolkit
from app.markets import get_first_available_market_api
from app.markets import MarketAPIs
# TODO (?) in futuro fare in modo che la LLM faccia da sé per il mercato
# Non so se può essere utile, per ora lo lascio qui
@@ -8,7 +8,7 @@ from app.markets import get_first_available_market_api
# in base alle sue proprie chiamate API
class MarketToolkit(Toolkit):
def __init__(self):
self.market_agent = get_first_available_market_api("USD") # change currency if needed
self.market_api = MarketAPIs("USD") # change currency if needed
super().__init__(
name="Market Toolkit",
@@ -19,10 +19,10 @@ class MarketToolkit(Toolkit):
)
def get_historical_data(self, symbol: str):
return self.market_agent.get_historical_prices(symbol)
return self.market_api.get_historical_prices(symbol)
def get_current_price(self, symbol: str):
return self.market_agent.get_products(symbol)
return self.market_api.get_products(symbol)
def prepare_inputs():
pass