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

View File

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