diff --git a/src/app/agents/__init__.py b/src/app/agents/__init__.py index 2e78f1b..efb10a0 100644 --- a/src/app/agents/__init__.py +++ b/src/app/agents/__init__.py @@ -1,4 +1,4 @@ -from app.agents.predictor import PredictorInput, PredictorOutput from app.agents.pipeline import Pipeline, PipelineInputs, PipelineEvent +from app.agents.core import PipelineInputs, QueryOutputs -__all__ = ["PredictorInput", "PredictorOutput", "Pipeline", "PipelineInputs", "PipelineEvent"] +__all__ = ["Pipeline", "PipelineInputs", "PipelineEvent", "QueryOutputs"] diff --git a/src/app/agents/core.py b/src/app/agents/core.py new file mode 100644 index 0000000..35c1c79 --- /dev/null +++ b/src/app/agents/core.py @@ -0,0 +1,72 @@ +from pydantic import BaseModel +from app.configs import AppConfig + + + + +class QueryOutputs(BaseModel): + response: str + is_ok: bool + + + +class PipelineInputs: + """ + Classe necessaria per passare gli input alla Pipeline. + Serve per raggruppare i parametri e semplificare l'inizializzazione. + """ + + def __init__(self, configs: AppConfig | None = None) -> None: + """ + Inputs per la Pipeline di agenti. + Setta i valori di default se non specificati. + """ + self.configs = configs if configs else AppConfig() + + agents = self.configs.agents + self.team_model = self.configs.get_model_by_name(agents.team_model) + self.team_leader_model = self.configs.get_model_by_name(agents.team_leader_model) + self.predictor_model = self.configs.get_model_by_name(agents.predictor_model) + self.strategy = self.configs.get_strategy_by_name(agents.strategy) + self.user_query = "" + + # ====================== + # Dropdown handlers + # ====================== + def choose_team_leader(self, index: int): + """ + Sceglie il modello LLM da usare per il Team Leader. + """ + self.leader_model = self.configs.models.all_models[index] + + def choose_team(self, index: int): + """ + Sceglie il modello LLM da usare per il Team. + """ + self.team_model = self.configs.models.all_models[index] + + def choose_strategy(self, index: int): + """ + Sceglie la strategia da usare per il Team. + """ + self.strategy = self.configs.strategies[index] + + # ====================== + # Helpers + # ====================== + def list_models_names(self) -> list[str]: + """ + Restituisce la lista dei nomi dei modelli disponibili. + """ + return [model.label for model in self.configs.models.all_models] + + def list_strategies_names(self) -> list[str]: + """ + Restituisce la lista delle strategie disponibili. + """ + return [strat.label for strat in self.configs.strategies] + + + + + diff --git a/src/app/agents/pipeline.py b/src/app/agents/pipeline.py index cf8de3e..93f11d4 100644 --- a/src/app/agents/pipeline.py +++ b/src/app/agents/pipeline.py @@ -12,7 +12,7 @@ from agno.workflow.workflow import Workflow from app.api.tools import * from app.agents.prompts import * -from app.configs import AppConfig +from app.agents.core import PipelineInputs logging = logging.getLogger("pipeline") @@ -28,63 +28,6 @@ class PipelineEvent(str, Enum): return event == self.value or (WorkflowRunEvent.step_completed and step_name == self.value) -class PipelineInputs: - """ - Classe necessaria per passare gli input alla Pipeline. - Serve per raggruppare i parametri e semplificare l'inizializzazione. - """ - - def __init__(self, configs: AppConfig | None = None) -> None: - """ - Inputs per la Pipeline di agenti. - Setta i valori di default se non specificati. - """ - self.configs = configs if configs else AppConfig() - - agents = self.configs.agents - self.team_model = self.configs.get_model_by_name(agents.team_model) - self.team_leader_model = self.configs.get_model_by_name(agents.team_leader_model) - self.predictor_model = self.configs.get_model_by_name(agents.predictor_model) - self.strategy = self.configs.get_strategy_by_name(agents.strategy) - self.user_query = "" - - # ====================== - # Dropdown handlers - # ====================== - def choose_team_leader(self, index: int): - """ - Sceglie il modello LLM da usare per il Team Leader. - """ - self.leader_model = self.configs.models.all_models[index] - - def choose_team(self, index: int): - """ - Sceglie il modello LLM da usare per il Team. - """ - self.team_model = self.configs.models.all_models[index] - - def choose_strategy(self, index: int): - """ - Sceglie la strategia da usare per il Team. - """ - self.strategy = self.configs.strategies[index] - - # ====================== - # Helpers - # ====================== - def list_models_names(self) -> list[str]: - """ - Restituisce la lista dei nomi dei modelli disponibili. - """ - return [model.label for model in self.configs.models.all_models] - - def list_strategies_names(self) -> list[str]: - """ - Restituisce la lista delle strategie disponibili. - """ - return [strat.label for strat in self.configs.strategies] - - class Pipeline: """ Coordina gli agenti di servizio (Market, News, Social) e il Predictor finale. diff --git a/src/app/agents/predictor.py b/src/app/agents/predictor.py deleted file mode 100644 index 2073947..0000000 --- a/src/app/agents/predictor.py +++ /dev/null @@ -1,16 +0,0 @@ -from pydantic import BaseModel, Field -from app.api.core.markets import ProductInfo - -class PredictorInput(BaseModel): - data: list[ProductInfo] = Field(..., description="Market data as a list of ProductInfo") - style: str = Field(..., description="Prediction style") - sentiment: str = Field(..., description="Aggregated sentiment from news and social analysis") - -class ItemPortfolio(BaseModel): - asset: str = Field(..., description="Name of the asset") - percentage: float = Field(..., description="Percentage allocation to the asset") - motivation: str = Field(..., description="Motivation for the allocation") - -class PredictorOutput(BaseModel): - strategy: str = Field(..., description="Concise operational strategy in Italian") - portfolio: list[ItemPortfolio] = Field(..., description="List of portfolio items with allocations")