Tool #15

Merged
trojanhorse47 merged 7 commits from tool into main 2025-10-03 11:42:11 +02:00
2 changed files with 13 additions and 14 deletions
Showing only changes of commit 1206972bb6 - Show all commits

View File

@@ -71,17 +71,16 @@ class MarketAgent(Agent):
results = [] results = []
products: List[ProductInfo] = [] products: List[ProductInfo] = []
for sym in symbols:
try: try:
product = self.toolkit.get_current_price(sym) # supponiamo ritorni un ProductInfo o simile products.extend(self.toolkit.get_current_prices(symbols)) # supponiamo ritorni un ProductInfo o simile
if isinstance(product, list): # Usa list comprehension per iterare symbols e products insieme
products.extend(product) results.extend([
else: f"{symbol}: ${product.price:.2f}" if hasattr(product,
products.append(product) 'price') and product.price else f"{symbol}: N/A"
for symbol, product in zip(symbols, products)
results.append(f"{sym}: {product.price if hasattr(product, 'price') else product}") ])
except Exception as e: except Exception as e:
results.append(f"{sym}: errore ({e})") results.extend(f"Errore: impossibile recuperare i dati di mercato\n {e}")
# 4. Preparo output leggibile + metadati strutturati # 4. Preparo output leggibile + metadati strutturati
output_text = "📊 Dati di mercato:\n" + "\n".join(results) output_text = "📊 Dati di mercato:\n" + "\n".join(results)

View File

@@ -16,15 +16,15 @@ class MarketToolkit(Toolkit):
name="Market Toolkit", name="Market Toolkit",
tools=[ tools=[
self.get_historical_data, self.get_historical_data,
self.get_current_price, self.get_current_prices,
], ],
) )
def get_historical_data(self, symbol: str): def get_historical_data(self, symbol: str):
return self.market_api.get_historical_prices(symbol) return self.market_api.get_historical_prices(symbol)
def get_current_price(self, symbol: str): def get_current_prices(self, symbols: list):
return self.market_api.get_products(symbol) return self.market_api.get_products(symbols)
def prepare_inputs(): def prepare_inputs():
pass pass