* Aggiorna gli agenti e il modello del team per utilizzare OLLAMA_QWEN_1B * Riorganizza e rinomina funzioni di estrazione in moduli di mercato e notizie; migliora la gestione delle importazioni * Spostato main nel corretto file __main__ e aggiornato il README.md * Aggiunta cartella per i modelli, agenti e team * Aggiornata la posizione delle istruzioni * Rimossi TODO e Aggiunto documentazione per metodi aggregated * Aggiornate le istruzioni del coordinatore del team * utils type checks * Rinominato BaseWrapper in MarketWrapper e fix type check markets * fix type checks di notizie e social. * Aggiunti type hints finali * Riorganizzati gli import * Refactoring architetturale e spostamento classi base - Eliminazione del file __init__.py obsoleto che importava ChatManager e Pipeline - Spostamento della classe Pipeline in agents/pipeline.py - Spostamento della classe ChatManager in utils/chat_manager.py - Aggiornamento di __main__.py per importare da app.utils e app.agents, e modifica della logica per utilizzare Pipeline invece di chat per la selezione di provider e stile - Creazione della cartella base con classi base comuni: markets.py (ProductInfo, Price, MarketWrapper), news.py (Article, NewsWrapper), social.py (SocialPost, SocialComment, SocialWrapper) - Aggiornamento di tutti gli import nel progetto (markets/, news/, social/, utils/, tests/) per utilizzare la nuova struttura base/ * Aggiornato Readme * Corretto il valore predefinito della valuta in BinanceWrapper da "USDT" a "USD" * fix type in tests * fix type per models * Rinominato 'quote_currency' in 'currency' e aggiornato il trattamento del timestamp in Price * fix errors found by Copilot * WrapperHandler: semplificata la logica di chiamata delle funzioni sui wrapper * fix docs * fix demos, semplificata logica lista ollama
57 lines
2.2 KiB
Python
57 lines
2.2 KiB
Python
import pytest
|
|
from app.agents import AppModels
|
|
from app.agents.predictor import PREDICTOR_INSTRUCTIONS, PredictorInput, PredictorOutput, PredictorStyle
|
|
from app.base.markets import ProductInfo
|
|
|
|
def unified_checks(model: AppModels, input: PredictorInput) -> None:
|
|
llm = model.get_agent(PREDICTOR_INSTRUCTIONS, output_schema=PredictorOutput) # type: ignore[arg-type]
|
|
result = llm.run(input) # type: ignore
|
|
content = result.content
|
|
|
|
assert isinstance(content, PredictorOutput)
|
|
assert content.strategy not in (None, "", "null")
|
|
assert isinstance(content.strategy, str)
|
|
assert isinstance(content.portfolio, list)
|
|
assert len(content.portfolio) > 0
|
|
for item in content.portfolio:
|
|
assert item.asset not in (None, "", "null")
|
|
assert isinstance(item.asset, str)
|
|
assert item.percentage >= 0.0
|
|
assert item.percentage <= 100.0
|
|
assert isinstance(item.percentage, (int, float))
|
|
assert item.motivation not in (None, "", "null")
|
|
assert isinstance(item.motivation, str)
|
|
# La somma delle percentuali deve essere esattamente 100
|
|
total_percentage = sum(item.percentage for item in content.portfolio)
|
|
assert abs(total_percentage - 100) < 0.01 # Permette una piccola tolleranza per errori di arrotondamento
|
|
|
|
class TestPredictor:
|
|
|
|
def inputs(self) -> PredictorInput:
|
|
data: list[ProductInfo] = []
|
|
for symbol, price in [("BTC", 60000.00), ("ETH", 3500.00), ("SOL", 150.00)]:
|
|
product_info = ProductInfo()
|
|
product_info.symbol = symbol
|
|
product_info.price = price
|
|
data.append(product_info)
|
|
|
|
return PredictorInput(data=data, style=PredictorStyle.AGGRESSIVE, sentiment="positivo")
|
|
|
|
def test_gemini_model_output(self):
|
|
inputs = self.inputs()
|
|
unified_checks(AppModels.GEMINI, inputs)
|
|
|
|
def test_ollama_qwen_4b_model_output(self):
|
|
inputs = self.inputs()
|
|
unified_checks(AppModels.OLLAMA_QWEN_4B, inputs)
|
|
|
|
@pytest.mark.slow
|
|
def test_ollama_qwen_latest_model_output(self):
|
|
inputs = self.inputs()
|
|
unified_checks(AppModels.OLLAMA_QWEN, inputs)
|
|
|
|
@pytest.mark.slow
|
|
def test_ollama_gpt_oss_model_output(self):
|
|
inputs = self.inputs()
|
|
unified_checks(AppModels.OLLAMA_GPT, inputs)
|